Skip to content

git_checkout_index doesn't respect GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH checkout parameter #5377

Closed
@lapfelix

Description

@lapfelix

Reproduction steps

Use git_checkout_index to checkout multiple modified files (where we want to revert the changes that were made) with the GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH flag enabled in the checkout_strategy where the files all have the same prefix as other modified files.

For example, I modified test9.txt, test10.txt, test11.txt and test12.txt and I want to discard the changes from test10.txt and test11.txt by using git_checkout_index.

Expected behavior

Only the files specified in the git_checkout_options's paths should be checked out.

In my example, that would be only test10.txt and test11.txt.

Actual behavior

All of the files with the same prefix as the two checked out files have their changes discarded too.

In my example, the changes made to test12.txt would also be discarded because test12.txt has test1 as prefix.

I created a test case in checkout/index.c in a branch in my libgit2 fork that demonstrates the issue: f37c77b

Version of libgit2 (release number or SHA1)

5597517 (which is the latest commit on master).
Also reproduced on 15e1193 (which dates back from 2017)

Operating system(s) tested

macOS 10.15.2 (build 19C57)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions