diff options
| author | Segev Finer <segev@codeocean.com> | 2019-06-03 18:35:08 +0300 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2020-05-11 00:15:06 +0100 |
| commit | d62e44cb8218840a0291fb5fbb7c5106e1e35a12 (patch) | |
| tree | d46e7faea4ce7774eb4094a7bc55ceb2c31971ef /src | |
| parent | 2a1d97e6e7ca0fee3fcc5e86e8bf61ab2f182d64 (diff) | |
| download | libgit2-d62e44cb8218840a0291fb5fbb7c5106e1e35a12.tar.gz | |
checkout: Fix removing untracked files by path in subdirectories
The checkout code didn't iterate into a subdir if it didn't match the
pathspec, but since the pathspec might match files in the subdir we
should recurse into it (In contrast to gitignore handling).
Fixes #5089
Diffstat (limited to 'src')
| -rw-r--r-- | src/checkout.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/checkout.c b/src/checkout.c index f0dd736dc..59ff873dd 100644 --- a/src/checkout.c +++ b/src/checkout.c @@ -371,8 +371,13 @@ static int checkout_action_wd_only( if (!git_pathspec__match( pathspec, wd->path, (data->strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH) != 0, - git_iterator_ignore_case(workdir), NULL, NULL)) - return git_iterator_advance(wditem, workdir); + git_iterator_ignore_case(workdir), NULL, NULL)) { + + if (wd->mode == GIT_FILEMODE_TREE) + return git_iterator_advance_into(wditem, workdir); + else + return git_iterator_advance(wditem, workdir); + } /* check if item is tracked in the index but not in the checkout diff */ if (data->index != NULL) { |
