Skip to content

v5: Ensure Chmod behaviour across BoundOS and ChrootOS#187

Merged
pjbgf merged 3 commits intogo-git:releases/v5.xfrom
pjbgf:windows-rename
Feb 24, 2026
Merged

v5: Ensure Chmod behaviour across BoundOS and ChrootOS#187
pjbgf merged 3 commits intogo-git:releases/v5.xfrom
pjbgf:windows-rename

Conversation

@pjbgf
Copy link
Member

@pjbgf pjbgf commented Feb 24, 2026

These are changes required in order to fix go-git/go-git#55. During the investigation of the issue it became clear that the osfs implementations were having slightly misaligned behaviour:

  • ChrootOS was unable to identify Chmod support due to the underlying polyfill not supporting it.
  • BoundOS would error if the tempdir path didn't exist ahead of TempFile() being called.

Supersedes #186.

Copilot AI review requested due to automatic review settings February 24, 2026 16:48
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #55 in go-git/go-git by aligning the behavior of BoundOS and ChrootOS filesystem implementations. The changes ensure that both implementations handle Chmod capabilities consistently and that BoundOS.TempFile() can create temporary files even when the target directory doesn't exist.

Changes:

  • Added Chmod capability detection to the polyfill helper to allow ChrootOS to properly identify Chmod support
  • Modified BoundOS.TempFile() to automatically create the target directory if it doesn't exist before creating the temporary file
  • Updated CI workflow to test against Go 1.24.x, oldstable, and stable versions

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
.github/workflows/test.yml Updated Go version matrix to use 1.24.x, oldstable, and stable references
osfs/os_bound.go Added directory creation logic in TempFile method to handle non-existent directories
osfs/os_bound_test.go Updated test expectations to reflect new TempFile behavior and fixed minor formatting issues
helper/polyfill/polyfill.go Added Chmod capability tracking and implementation to polyfill wrapper

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Previously if the dir didn't already exist an error would be returned,
which meant that some go-git features would break when changing ChrootOS
with BoundOS.

Signed-off-by: Paulo Gomes <[email protected]>
This is a follow-up to go-git#171.

Signed-off-by: Paulo Gomes <[email protected]>
@pjbgf pjbgf merged commit 8662784 into go-git:releases/v5.x Feb 24, 2026
11 checks passed
pjbgf added a commit to pjbgf/go-git that referenced this pull request Feb 24, 2026
Loose object files are content-addressable and imutable. They should be
created on demand and deleted on repacking. However, they should not be
overwritten - assuming the initial file isn't corrupted.

The previous lack of validation meant those files were being overwritten
when in fact they could just be ignored. In Linux, this was a non-issue,
however, in Windows this operation led to Access Denied errors.

Some additional moving parts of this fix:

- [go-billy](go-git/go-billy#187): Align
  behaviour supporting dir.NewObject():
    - Add support for Chmod in polyfill so that ChrootOS is able to
      chmod files.
    - Ensure temporary directories are created for BoundOS to avoid
      errors when trying to create the temporary file used for loose
      files.
- This PR:
    - Ensure that in Windows, packed and loose object files are created
      as read-only, which in this case means setting the flag
      windows.FILE_ATTRIBUTE_READONLY via x/sys/windows.
    - Skip renaming the temporary file into the existing loose object,
      instead simply delete the temporary file.

Relates to:
- Southclaws/sampctl#422
- git-bug/git-bug#1142
- entireio/cli#455

Signed-off-by: Paulo Gomes <[email protected]>
pjbgf added a commit to pjbgf/go-git that referenced this pull request Feb 24, 2026
Loose object files are content-addressable and imutable. They should be
created on demand and deleted on repacking. However, they should not be
overwritten - assuming the initial file isn't corrupted.

The previous lack of validation meant those files were being overwritten
when in fact they could just be ignored. In Linux, this was a non-issue,
however, in Windows this operation led to Access Denied errors.

Some additional moving parts of this fix:

- [go-billy](go-git/go-billy#187): Align
  behaviour supporting dir.NewObject():
    - Add support for Chmod in polyfill so that ChrootOS is able to
      chmod files.
    - Ensure temporary directories are created for BoundOS to avoid
      errors when trying to create the temporary file used for loose
      files.
- This PR:
    - Ensure that in Windows, packed and loose object files are created
      as read-only, which in this case means setting the flag
      windows.FILE_ATTRIBUTE_READONLY via x/sys/windows.
    - Skip renaming the temporary file into the existing loose object,
      instead simply delete the temporary file.

Relates to:
- Southclaws/sampctl#422
- git-bug/git-bug#1142
- entireio/cli#455

Signed-off-by: Paulo Gomes <[email protected]>
pjbgf added a commit to pjbgf/go-git that referenced this pull request Feb 25, 2026
Loose object files are content-addressable and imutable. They should be
created on demand and deleted on repacking. However, they should not be
overwritten - assuming the initial file isn't corrupted.

The previous lack of validation meant those files were being overwritten
when in fact they could just be ignored. In Linux, this was a non-issue,
however, in Windows this operation led to Access Denied errors.

Some additional moving parts of this fix:

- [go-billy](go-git/go-billy#187): Align
  behaviour supporting dir.NewObject():
    - Add support for Chmod in polyfill so that ChrootOS is able to
      chmod files.
    - Ensure temporary directories are created for BoundOS to avoid
      errors when trying to create the temporary file used for loose
      files.
- This PR:
    - Ensure that in Windows, packed and loose object files are created
      as read-only, which in this case means setting the flag
      windows.FILE_ATTRIBUTE_READONLY via x/sys/windows.
    - Skip renaming the temporary file into the existing loose object,
      instead simply delete the temporary file.

Relates to:
- Southclaws/sampctl#422
- git-bug/git-bug#1142
- entireio/cli#455

Signed-off-by: Paulo Gomes <[email protected]>
Maks1mS pushed a commit to stplr-dev/stplr that referenced this pull request Feb 25, 2026
This PR contains the following updates:

| Package | Type | Update | Change | OpenSSF |
|---|---|---|---|---|
| [github.com/go-git/go-billy/v5](https://github.com/go-git/go-billy) | require | minor | `v5.7.0` → `v5.8.0` | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/go-git/go-billy/badge)](https://securityscorecards.dev/viewer/?uri=github.com/go-git/go-billy) |

---

> ⚠️ **Warning**
>
> Some dependencies could not be looked up. Check the Dependency Dashboard for more information.

---

### Release Notes

<details>
<summary>go-git/go-billy (github.com/go-git/go-billy/v5)</summary>

### [`v5.8.0`](https://github.com/go-git/go-billy/releases/tag/v5.8.0)

[Compare Source](go-git/go-billy@v5.7.0...v5.8.0)

#### What's Changed

- build: Update module golang.org/x/net to v0.45.0 \[SECURITY] (releases/v5.x) by [@&#8203;go-git-renovate](https://github.com/go-git-renovate)\[bot] in [#&#8203;183](go-git/go-billy#183)
- v5: Ensure Chmod behaviour across BoundOS and ChrootOS by [@&#8203;pjbgf](https://github.com/pjbgf) in [#&#8203;187](go-git/go-billy#187)

**Full Changelog**: <go-git/go-billy@v5.7.0...v5.8.0>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At 12:00 AM through 04:59 AM and 10:00 PM through 11:59 PM, Monday through Friday ( * 0-4,22-23 * * 1-5 ), Only on Sunday and Saturday ( * * * * 0,6 ) (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xNS4yIiwidXBkYXRlZEluVmVyIjoiNDMuMTUuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiS2luZC9EZXBlbmRlbmNpZXMiXX0=-->

Reviewed-on: https://altlinux.space/stapler/stplr/pulls/318
Co-authored-by: Renovate Bot <[email protected]>
Co-committed-by: Renovate Bot <[email protected]>
pjbgf added a commit to pjbgf/go-git that referenced this pull request Feb 26, 2026
Loose object files are content-addressable and imutable. They should be
created on demand and deleted on repacking. However, they should not be
overwritten - assuming the initial file isn't corrupted.

The previous lack of validation meant those files were being overwritten
when in fact they could just be ignored. In Linux, this was a non-issue,
however, in Windows this operation led to Access Denied errors.

Some additional moving parts of this fix:

- [go-billy](go-git/go-billy#187): Align
  behaviour supporting dir.NewObject():
    - Add support for Chmod in polyfill so that ChrootOS is able to
      chmod files.
    - Ensure temporary directories are created for BoundOS to avoid
      errors when trying to create the temporary file used for loose
      files.
- This PR:
    - Ensure that in Windows, packed and loose object files are created
      as read-only, which in this case means setting the flag
      windows.FILE_ATTRIBUTE_READONLY via x/sys/windows.
    - Skip renaming the temporary file into the existing loose object,
      instead simply delete the temporary file.

Relates to:
- Southclaws/sampctl#422
- git-bug/git-bug#1142
- entireio/cli#455

Signed-off-by: Paulo Gomes <[email protected]>
pjbgf added a commit to pjbgf/go-git that referenced this pull request Feb 26, 2026
Loose object files are content-addressable and imutable. They should be
created on demand and deleted on repacking. However, they should not be
overwritten - assuming the initial file isn't corrupted.

The previous lack of validation meant those files were being overwritten
when in fact they could just be ignored. In Linux, this was a non-issue,
however, in Windows this operation led to Access Denied errors.

Some additional moving parts of this fix:

- [go-billy](go-git/go-billy#187): Align
  behaviour supporting dir.NewObject():
    - Add support for Chmod in polyfill so that ChrootOS is able to
      chmod files.
    - Ensure temporary directories are created for BoundOS to avoid
      errors when trying to create the temporary file used for loose
      files.
- This PR:
    - Ensure that in Windows, packed and loose object files are created
      as read-only, which in this case means setting the flag
      windows.FILE_ATTRIBUTE_READONLY via x/sys/windows.
    - Skip renaming the temporary file into the existing loose object,
      instead simply delete the temporary file.

Relates to:
- Southclaws/sampctl#422
- git-bug/git-bug#1142
- entireio/cli#455

Signed-off-by: Paulo Gomes <[email protected]>
arthurzam pushed a commit to gentoo-golang-dist/forgejo-runner that referenced this pull request Feb 27, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [github.com/go-git/go-billy/v5](https://github.com/go-git/go-billy) | `v5.6.2` -> `v5.8.0` | ![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fgo-git%2fgo-billy%2fv5/v5.8.0?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fgo-git%2fgo-billy%2fv5/v5.6.2/v5.8.0?slim=true) |

---

### Release Notes

<details>
<summary>go-git/go-billy (github.com/go-git/go-billy/v5)</summary>

### [`v5.8.0`](https://github.com/go-git/go-billy/releases/tag/v5.8.0)

[Compare Source](go-git/go-billy@v5.7.0...v5.8.0)

#### What's Changed

- build: Update module golang.org/x/net to v0.45.0 \[SECURITY] (releases/v5.x) by [@&#8203;go-git-renovate](https://github.com/go-git-renovate)\[bot] in [#&#8203;183](go-git/go-billy#183)
- v5: Ensure Chmod behaviour across BoundOS and ChrootOS by [@&#8203;pjbgf](https://github.com/pjbgf) in [#&#8203;187](go-git/go-billy#187)

**Full Changelog**: <go-git/go-billy@v5.7.0...v5.8.0>

### [`v5.7.0`](https://github.com/go-git/go-billy/releases/tag/v5.7.0)

[Compare Source](go-git/go-billy@v5.6.2...v5.7.0)

#### What's Changed

- Add support for Chmod on billy.Filesystem by [@&#8203;bitfehler](https://github.com/bitfehler) in [#&#8203;171](go-git/go-billy#171)
- build: Update module golang.org/x/net to v0.38.0 \[SECURITY] (releases/v5.x) by [@&#8203;go-git-renovate](https://github.com/go-git-renovate)\[bot] in [#&#8203;177](go-git/go-billy#177)

**Full Changelog**: <go-git/go-billy@v5.6.2...v5.7.0>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC), Automerge - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My41LjAiLCJ1cGRhdGVkSW5WZXIiOiI0My41LjAiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbIktpbmQvRGVwZW5kZW5jeVVwZGF0ZSIsInJ1bi1lbmQtdG8tZW5kLXRlc3RzIl19-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/1409
Reviewed-by: Mathieu Fenniak <[email protected]>
Co-authored-by: Renovate Bot <[email protected]>
Co-committed-by: Renovate Bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants