Skip to content

Fix handling of GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH flag.#4054

Merged
ethomson merged 1 commit into
libgit2:masterfrom
jfultz:jfultz/fix_GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH
Jan 14, 2017
Merged

Fix handling of GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH flag.#4054
ethomson merged 1 commit into
libgit2:masterfrom
jfultz:jfultz/fix_GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH

Conversation

@jfultz
Copy link
Copy Markdown
Contributor

@jfultz jfultz commented Dec 30, 2016

git_checkout_tree() sets up its working directory iterator to respect the
pathlist if GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH is present, which is great.
What's not so great is that this iterator is then used side-by-side with
an iterator created by git_checkout_iterator(), which did not set up its
pathlist appropriately (although the iterator mirrors all other iterator
options).

This could cause git_checkout_tree() to delete working tree files which
were not specified in the pathlist when GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH
was used, as the unsynchronized iterators causes git_checkout_tree() to think
that files have been deleted between the two trees. Oops.

And added a test which fails without this fix (specifically, the final check
for "testrepo/README" to still be present fails).

git_checkout_tree() sets up its working directory iterator to respect the
pathlist if GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH is present, which is great.
What's not so great is that this iterator is then used side-by-side with
an iterator created by git_checkout_iterator(), which did not set up its
pathlist appropriately (although the iterator mirrors all other iterator
options).

This could cause git_checkout_tree() to delete working tree files which
were not specified in the pathlist when GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH
was used, as the unsynchronized iterators causes git_checkout_tree() to think
that files have been deleted between the two trees.  Oops.

And added a test which fails without this fix (specifically, the final check
for "testrepo/README" to still be present fails).
@ethomson
Copy link
Copy Markdown
Member

Thanks, @jfultz for catching this and the fix. Thanks especially for including a unit test. ❤️

@ethomson ethomson merged commit cb76eed into libgit2:master Jan 14, 2017
@jfultz jfultz deleted the jfultz/fix_GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH branch January 14, 2017 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants