Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2020-08-22 11:57:59 +0300
committerJunio C Hamano <gitster@pobox.com>2020-08-22 23:37:43 +0300
commitbfda204ade8a19357cf073c98dc3a5043533b4c4 (patch)
treebe3bb1b81c3ead7c0753dd907079848114dd5faa /t/t2072-restore-pathspec-file.sh
parent135365dd991f9520406012e30ab27a8d22951df8 (diff)
checkout, restore: make pathspec recursive
The pathspec given to git checkout and git restore is used with both tree_entry_interesting (via read_tree_recursive) and match_pathspec (via ce_path_match). The latter effectively only supports recursive matching regardless of the value of the pathspec flag "recursive", which is unset here. That causes different match results for pathspecs with wildcards, and can lead checkout and restore in no-overlay mode to remove entries instead of modifying them. Enable recursive matching for both checkout and restore to make matching consistent. Setting the flag in checkout_main() technically also affects git switch, but since that command doesn't accept pathspecs at all this has no actual consequence. Reported-by: Sergii Shkarnikov <sergii.shkarnikov@globallogic.com> Initial-test-by: Sergii Shkarnikov <sergii.shkarnikov@globallogic.com> Helped-by: Jeff King <peff@peff.net> Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t2072-restore-pathspec-file.sh')
-rwxr-xr-xt/t2072-restore-pathspec-file.sh19
1 files changed, 16 insertions, 3 deletions
diff --git a/t/t2072-restore-pathspec-file.sh b/t/t2072-restore-pathspec-file.sh
index db58e83735..5468f7a7b3 100755
--- a/t/t2072-restore-pathspec-file.sh
+++ b/t/t2072-restore-pathspec-file.sh
@@ -9,18 +9,21 @@ test_tick
test_expect_success setup '
test_commit file0 &&
+ mkdir dir1 &&
+ echo 1 >dir1/file &&
echo 1 >fileA.t &&
echo 1 >fileB.t &&
echo 1 >fileC.t &&
echo 1 >fileD.t &&
- git add fileA.t fileB.t fileC.t fileD.t &&
+ git add dir1 fileA.t fileB.t fileC.t fileD.t &&
git commit -m "files 1" &&
+ echo 2 >dir1/file &&
echo 2 >fileA.t &&
echo 2 >fileB.t &&
echo 2 >fileC.t &&
echo 2 >fileD.t &&
- git add fileA.t fileB.t fileC.t fileD.t &&
+ git add dir1 fileA.t fileB.t fileC.t fileD.t &&
git commit -m "files 2" &&
git tag checkpoint
@@ -31,7 +34,7 @@ restore_checkpoint () {
}
verify_expect () {
- git status --porcelain --untracked-files=no -- fileA.t fileB.t fileC.t fileD.t >actual &&
+ git status --porcelain --untracked-files=no -- dir1 fileA.t fileB.t fileC.t fileD.t >actual &&
test_cmp expect actual
}
@@ -136,4 +139,14 @@ test_expect_success 'only touches what was listed' '
verify_expect
'
+test_expect_success 'wildcard pathspec matches file in subdirectory' '
+ restore_checkpoint &&
+
+ echo "*file" | git restore --pathspec-from-file=- --source=HEAD^1 &&
+ cat >expect <<-\EOF &&
+ M dir1/file
+ EOF
+ verify_expect
+'
+
test_done