Repository navigation
Conversation
The tree and index iterators walk the sorted pathlist alongside the sorted entries, and `pathlist_walk_idx` points to the first pathlist entry that can still match. When a pathlist entry sorts before the current path, the walk increments this index even if that entry is not the first one. This drops the first entry, although it can match a later path. For example, with the pathlist "foo" and "foo-bar/b", the path "foo-bar/c" moves the index past "foo", so "foo/y" is not returned. A diff misses "foo/y", status reports "foo/" as untracked, and a checkout of these paths does not update "foo/y", or removes it with GIT_CHECKOUT_FORCE. Increment the index only when the entry that sorts before the path is the first one.
yerseg
force-pushed
the
fix-iterator-pathlist-walk
branch
from
September 30, 2026 10:21
4ef56b7 to
f76b520
Compare
This branch has not been deployed
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.
Fixes #7391.
iterator_pathlist_next_isadvancedpathlist_walk_idxwhenever any pathlist entry sorted before the current path. That could skip the first entry even though it could still match a later path. For example, with the pathlistfoo,foo-bar/b, the pathfoo-bar/cmade it skipfoo, andfoo/ywas never returned.With this change the index only advances when the entry that sorts before the path is the one the index points to. I added tests for the tree and index iterators and for checkout. They all fail without the fix, the checkout one because
foo/ygets deleted.This can also change the staged-changes check in
git_merge, which uses a pathlist of the staged paths. With a staged deletion offooand a merge that addsfoo/child, the merge was refused, except when other staged paths likefoo-bar/bmade the iterator dropfoo. Now it's refused in both cases.