storage: filesystem, Avoid overwriting loose obj files#1864
Merged
pjbgf merged 2 commits intogo-git:releases/v5.xfrom Feb 25, 2026
Merged
storage: filesystem, Avoid overwriting loose obj files#1864pjbgf merged 2 commits intogo-git:releases/v5.xfrom
pjbgf merged 2 commits intogo-git:releases/v5.xfrom
Conversation
Align behaviour with upstream and v6, whereby all loose and packed objects are saved on disk as read-only as they are not meant to be modified due to their nature, as they are content addressable files. Signed-off-by: Paulo Gomes <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the storage/filesystem/dotgit writers to better respect the immutability of content-addressed Git object storage and to avoid Windows “Access Denied” failures when attempting to overwrite existing loose objects.
Changes:
- Add OS-specific helpers to mark written pack/idx and loose object files as read-only (Windows file attribute vs Unix perms).
- Update pack/object writer save paths to apply read-only permissions and avoid overwriting existing loose objects.
- Expand/adjust tests to validate permissions and reproduce Issue #55; bump
go-billydependency to include required filesystem behavior.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| storage/filesystem/dotgit/writers_windows.go | Adds Windows-specific permission handling via FILE_ATTRIBUTE_READONLY. |
| storage/filesystem/dotgit/writers_unix.go | Adds Unix permission handling via Chmod(0444) where supported. |
| storage/filesystem/dotgit/writers.go | Applies permission fixes after writing pack/idx and loose objects; skips overwriting loose objects. |
| storage/filesystem/dotgit/writers_test.go | Adds new permission-focused tests for pack and loose object writers across OSFS variants. |
| storage/filesystem/dotgit/dotgit_test.go | Adds regression test intended to reproduce Issue #55 behavior. |
| go.mod | Bumps github.com/go-git/go-billy/v5 to v5.8.0. |
| go.sum | Updates sums for the go-billy version bump. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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-git/v5](https://github.com/go-git/go-git) | `v5.16.5` -> `v5.17.0` |  |  | --- ### Release Notes <details> <summary>go-git/go-git (github.com/go-git/go-git/v5)</summary> ### [`v5.17.0`](https://github.com/go-git/go-git/releases/tag/v5.17.0) [Compare Source](go-git/go-git@v5.16.5...v5.17.0) #### What's Changed - build: Update module github.com/go-git/go-git/v5 to v5.16.5 \[SECURITY] (releases/v5.x) by [@​go-git-renovate](https://github.com/go-git-renovate)\[bot] in [#​1839](go-git/go-git#1839) - git: worktree, optimize infiles function for very large repos by [@​k-anshul](https://github.com/k-anshul) in [#​1853](go-git/go-git#1853) - git: Add strict checks for supported extensions by [@​pjbgf](https://github.com/pjbgf) in [#​1861](go-git/go-git#1861) - backport, git: Improve Status() speed with new index.ModTime check by [@​cedric-appdirect](https://github.com/cedric-appdirect) in [#​1862](go-git/go-git#1862) - storage: filesystem, Avoid overwriting loose obj files by [@​pjbgf](https://github.com/pjbgf) in [#​1864](go-git/go-git#1864) **Full Changelog**: <go-git/go-git@v5.16.5...v5.17.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/1410 Reviewed-by: Mathieu Fenniak <[email protected]> Co-authored-by: Renovate Bot <[email protected]> Co-committed-by: Renovate Bot <[email protected]>
Maks1mS
pushed a commit
to stplr-dev/stplr
that referenced
this pull request
Feb 28, 2026
This PR contains the following updates: | Package | Type | Update | Change | OpenSSF | |---|---|---|---|---| | [github.com/go-git/go-git/v5](https://github.com/go-git/go-git) | require | minor | `v5.16.5` → `v5.17.0` | [](https://securityscorecards.dev/viewer/?uri=github.com/go-git/go-git) | --- >⚠️ **Warning** > > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>go-git/go-git (github.com/go-git/go-git/v5)</summary> ### [`v5.17.0`](https://github.com/go-git/go-git/releases/tag/v5.17.0) [Compare Source](go-git/go-git@v5.16.5...v5.17.0) #### What's Changed - build: Update module github.com/go-git/go-git/v5 to v5.16.5 \[SECURITY] (releases/v5.x) by [@​go-git-renovate](https://github.com/go-git-renovate)\[bot] in [#​1839](go-git/go-git#1839) - git: worktree, optimize infiles function for very large repos by [@​k-anshul](https://github.com/k-anshul) in [#​1853](go-git/go-git#1853) - git: Add strict checks for supported extensions by [@​pjbgf](https://github.com/pjbgf) in [#​1861](go-git/go-git#1861) - backport, git: Improve Status() speed with new index.ModTime check by [@​cedric-appdirect](https://github.com/cedric-appdirect) in [#​1862](go-git/go-git#1862) - storage: filesystem, Avoid overwriting loose obj files by [@​pjbgf](https://github.com/pjbgf) in [#​1864](go-git/go-git#1864) **Full Changelog**: <go-git/go-git@v5.16.5...v5.17.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/333 Co-authored-by: Renovate Bot <[email protected]> Co-committed-by: Renovate Bot <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 Deniederrors.Some additional moving parts of this fix:
dir.NewObject():Chmodin polyfill so that ChrootOS is able tochmodfiles.windows.FILE_ATTRIBUTE_READONLYviax/sys/windows.Relates to:
Fixes #55.