Repository navigation
Conversation
DiffTree walks each tree through treeNoder.Children -> transformChildren -> TreeWalker.Next, which validated every entry name with pathutil.ValidTreePath. That validator rejects control characters and .git-shaped names so that callers materialising entries into a worktree or archive stay safe. DiffTree does neither: it computes a diff in memory and never writes a name to disk. The effect was that a diff over a tree containing an entry name upstream Git accepts — e.g. one with an embedded newline, which verify_path permits since only '/' and NUL are forbidden in a path component — failed the whole diff with "invalid path: contains control character" instead of reporting the change. Add an unexported skipPathValidation flag to TreeWalker and set it for the diff walk so the tree is enumerated faithfully. The flag defaults to off, so the materialising callers (archive, FileIter, FindEntry, TreeEntryFile) keep validating exactly as before. Signed-off-by: Paulo Gomes <[email protected]>
hiddeco
approved these changes
Jun 26, 2026
pjbgf
pushed a commit
that referenced
this pull request
Aug 8, 2026
iterateCommitTrees enumerates every reachable tree entry through
TreeWalker.Next, which validates each name with pathutil.ValidTreePath.
That validator exists so callers materialising entries into a worktree or
archive stay safe. The revlist walk does neither: it only collects hashes
to decide which objects to send.
The effect was that a single tree entry whose name upstream Git accepts —
one containing a control character, which verify_path permits since only
'/' and NUL are forbidden in a component — aborted the whole walk, so
Push failed with
invalid path "\x1b\x1b\x1b": contains control character
even when the offending entry existed only in history, was already present
on the remote, and would never be sent.
TreeWalker gains SkipPathValidation, which revlist calls. This is the same
reasoning applied to the tree diff walk in #2222; that fix set the flag
in-package, whereas revlist is a separate package and needs an exported
entry point.
Note the seen-set check in Next runs before validation, so an entry whose
blob is still reachable from a newer tree never reaches the validator.
Deleted content has a blob nothing else references, which is why the
reported case involved history rather than the pushed commit.
pjbgf
pushed a commit
that referenced
this pull request
Aug 8, 2026
Backport of #2222, which landed on main but not on this branch. DiffTree walks each tree through treeNoder.Children -> transformChildren -> TreeWalker.Next, which validated every entry name with pathutil.ValidTreePath. That validator protects callers materialising entries into a worktree or archive; DiffTree does neither, computing a diff in memory without ever writing a name to disk. So a diff over a tree containing an entry name upstream Git accepts — one with a control character, which verify_path permits since only '/' and NUL are forbidden in a component — failed with from: invalid path "\x1b\x1b\x1b": contains control character instead of reporting the change. This is the same defect as the revlist walk fixed in the previous commit, at the sibling call site. It is split out so it can be dropped or landed separately.
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.
DiffTreewalks each tree throughtreeNoder.Children -> transformChildren -> TreeWalker.Next, which validated every entry name withpathutil.ValidTreePath. That validator rejects control characters and .git-shaped names so that callers materialising entries into a worktree or archive stay safe.DiffTreedoes neither: it computes a diff in memory and never writes a name to disk.The effect was that a diff over a tree containing an entry name upstream Git accepts — e.g. one with an embedded newline, which verify_path permits since only '/' and NUL are forbidden in a path component — failed the whole diff with "invalid path: contains control character" instead of reporting the change.
Add an unexported
skipPathValidationflag toTreeWalkerand set it for the diff walk so the tree is enumerated faithfully. The flag defaults to off, so the materialising callers (archive,FileIter,FindEntry,TreeEntryFile) keep validating exactly as before.Follow-up from #2105.