Repository navigation
plumbing: revlist, Add regression tests for control-char tree names - #2527
Merged
pjbgf merged 1 commit intoOct 23, 2026
Merged
Conversation
Upstream Git accepts tree entry names with control characters: verify_path forbids only '/' and NUL in a path component, and Git pushes such history without complaint. go-git's push rejected these names until the object walk stopped validating them: fixed on v5 via TreeWalker.SkipPathValidation, and no longer applicable on main since the revlist rewrite, which collects hashes straight from Tree.Entries without a TreeWalker. Cover the scenario on main so a walk that reintroduces name validation fails loudly: the offending entry only in history, in the pushed commit itself, and arriving as haves already present on the remote. Refs go-git#2251 Signed-off-by: Ars Golushkov <[email protected]> Assisted-by: pi
pjbgf
approved these changes
Oct 23, 2026
pjbgf
left a comment
Member
There was a problem hiding this comment.
@arseniy-gl Thanks for working on this. 🙇
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.
Why
#2251 reported that
Pushfailed withinvalid path "\x1b\x1b\x1b": contains control characterwhenever a tree entry with a control character existed anywhere in reachable history, even when the objects were already present on the remote. Upstream Git accepts such names (verify_pathforbids only/and NUL in a path component) and pushes that history without complaint. I verified this locally against git 2.39.5 with a repository whose history contains a\x1b-prefixed entry: both a first push and a push where the offending objects were already on the remote succeed.The bug itself is already fixed: on
releases/v5.xby 707175a (TreeWalker.SkipPathValidation), and onmainthe revlist rewrite no longer usesTreeWalkerat all, collecting hashes straight fromTree.Entries. Whatmainlacks is a regression test: a future object walk that reintroduces entry-name validation would break push again.What
Three regression tests in
plumbing/revlistcovering the scenarios from #2251:The tests store the tree by writing its wire format directly, because
Tree.Encoderejects these names on the producer side. A tree fetched from a remote bypasses that gate, andEncode's doc comment documents the direct write as the way to store such objects.AI disclosure
Prepared with AI assistance (pi coding agent), per the AI Contribution Policy. Upstream git behaviour was verified locally as described above.
Refs #2251