Repository navigation
fix: RemoveRef removes empty parent directories - #2342
Open
VedantMadane wants to merge 3 commits into
Open
VedantMadane wants to merge 3 commits into
VedantMadane wants to merge 3 commits into
Conversation
- RemoveRef cleans up empty parent directories under refs/ Fixes go-git#1822 Signed-off-by: Vedant Madane <[email protected]>
VedantMadane
force-pushed
the
fix/issue-1822
branch
from
September 7, 2026 07:07
9681d16 to
9648f57
Compare
pjbgf
requested changes
Oct 1, 2026
pjbgf
left a comment
Member
There was a problem hiding this comment.
@VedantMadane thanks for looking into this. Please note that this fix also removes refs/heads. Please fix that and add a test to confirm that is no longer the case - so that it aligns with upstream Git.
This was referenced Oct 1, 2026
…rents Upstream Git's try_remove_empty_parents spares refs/ and its immediate subdirectories (such as refs/heads, refs/tags, refs/remotes). Update removeEmptyRefParents to break when the parent directory is refs/ (or root), avoiding accidental removal of refs/heads when the last loose branch is deleted. Add test coverage ensuring refs/heads is preserved when deleting the sole branch, nested empty parents are cleaned up, sibling branches keep parent dirs intact, and creating a conflicting ref succeeds after cleanup (fixes go-git#1822). Signed-off-by: Vedant Madane <[email protected]>
Author
|
@pjbgf Thanks for the review and catching that! I've updated Added test coverage in storage/filesystem/dotgit/dotgit_test.go covering:
|
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.
Summary
RemoveRef removes empty parent directories
Changes
Fixes #1822