]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t: fix quotes tests for --pathspec-from-file
authorAlexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Tue, 31 Dec 2019 10:15:11 +0000 (10:15 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 15 Jan 2020 20:14:20 +0000 (12:14 -0800)
While working on the next patch, I also noticed that quotes testing via
`"\"file\\101.t\""` was somewhat incorrect: I escaped `\` one time while
I had to escape it two times! Tests still worked due to `"` being
preserved which in turn prevented pathspec from matching files.

Fix this by using here-doc instead.

Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t2026-checkout-pathspec-file.sh
t/t2072-restore-pathspec-file.sh
t/t3704-add-pathspec-file.sh
t/t7107-reset-pathspec-file.sh
t/t7526-commit-pathspec-file.sh

index f62fd274404e1e5e5265bdc2b6b367a1d984a7f8..adad71f631edccbffe1fa7083416d644705091f0 100755 (executable)
@@ -109,7 +109,11 @@ test_expect_success 'CRLF delimiters' '
 test_expect_success 'quotes' '
        restore_checkpoint &&
 
-       printf "\"file\\101.t\"" | git checkout --pathspec-from-file=- HEAD^1 &&
+       cat >list <<-\EOF &&
+       "file\101.t"
+       EOF
+
+       git checkout --pathspec-from-file=list HEAD^1 &&
 
        cat >expect <<-\EOF &&
        M  fileA.t
@@ -120,7 +124,10 @@ test_expect_success 'quotes' '
 test_expect_success 'quotes not compatible with --pathspec-file-nul' '
        restore_checkpoint &&
 
-       printf "\"file\\101.t\"" >list &&
+       cat >list <<-\EOF &&
+       "file\101.t"
+       EOF
+
        test_must_fail git checkout --pathspec-from-file=list --pathspec-file-nul HEAD^1
 '
 
index db58e83735080269a85f80716678ab19838c434b..b407f6b779c8d63ded06fb9c2ca6d011cd853ca0 100755 (executable)
@@ -109,7 +109,11 @@ test_expect_success 'CRLF delimiters' '
 test_expect_success 'quotes' '
        restore_checkpoint &&
 
-       printf "\"file\\101.t\"" | git restore --pathspec-from-file=- --source=HEAD^1 &&
+       cat >list <<-\EOF &&
+       "file\101.t"
+       EOF
+
+       git restore --pathspec-from-file=list --source=HEAD^1 &&
 
        cat >expect <<-\EOF &&
         M fileA.t
@@ -120,7 +124,10 @@ test_expect_success 'quotes' '
 test_expect_success 'quotes not compatible with --pathspec-file-nul' '
        restore_checkpoint &&
 
-       printf "\"file\\101.t\"" >list &&
+       cat >list <<-\EOF &&
+       "file\101.t"
+       EOF
+
        test_must_fail git restore --pathspec-from-file=list --pathspec-file-nul --source=HEAD^1
 '
 
index 3cfdb669b7a5a1bc4b915abb0c880f067bfbd7b9..61b6e51009a26e827c2c84aac379d2d337a810bd 100755 (executable)
@@ -97,7 +97,11 @@ test_expect_success 'CRLF delimiters' '
 test_expect_success 'quotes' '
        restore_checkpoint &&
 
-       printf "\"file\\101.t\"" | git add --pathspec-from-file=- &&
+       cat >list <<-\EOF &&
+       "file\101.t"
+       EOF
+
+       git add --pathspec-from-file=list &&
 
        cat >expect <<-\EOF &&
        A  fileA.t
@@ -108,7 +112,10 @@ test_expect_success 'quotes' '
 test_expect_success 'quotes not compatible with --pathspec-file-nul' '
        restore_checkpoint &&
 
-       printf "\"file\\101.t\"" >list &&
+       cat >list <<-\EOF &&
+       "file\101.t"
+       EOF
+
        test_must_fail git add --pathspec-from-file=list --pathspec-file-nul
 '
 
index 6b1a731fffe65f10259a5200e071c4767181d759..b0e84cdb42acdf7f1f4fe0cc73b1ee3e343e980f 100755 (executable)
@@ -105,8 +105,12 @@ test_expect_success 'CRLF delimiters' '
 test_expect_success 'quotes' '
        restore_checkpoint &&
 
+       cat >list <<-\EOF &&
+       "file\101.t"
+       EOF
+
        git rm fileA.t &&
-       printf "\"file\\101.t\"" | git reset --pathspec-from-file=- &&
+       git reset --pathspec-from-file=list &&
 
        cat >expect <<-\EOF &&
         D fileA.t
@@ -117,8 +121,10 @@ test_expect_success 'quotes' '
 test_expect_success 'quotes not compatible with --pathspec-file-nul' '
        restore_checkpoint &&
 
-       git rm fileA.t &&
-       printf "\"file\\101.t\"" >list &&
+       cat >list <<-\EOF &&
+       "file\101.t"
+       EOF
+
        # Note: "git reset" has not yet learned to fail on wrong pathspecs
        git reset --pathspec-from-file=list --pathspec-file-nul &&
 
index 4b58901ed67c1349b255dd54977692f36cac988c..4a7c11368dff83156465b8f59d5aa6d8f488a7de 100755 (executable)
@@ -100,7 +100,11 @@ test_expect_success 'CRLF delimiters' '
 test_expect_success 'quotes' '
        restore_checkpoint &&
 
-       printf "\"file\\101.t\"" | git commit --pathspec-from-file=- -m "Commit" &&
+       cat >list <<-\EOF &&
+       "file\101.t"
+       EOF
+
+       git commit --pathspec-from-file=list -m "Commit" &&
 
        cat >expect <<-\EOF &&
        A       fileA.t
@@ -111,7 +115,10 @@ test_expect_success 'quotes' '
 test_expect_success 'quotes not compatible with --pathspec-file-nul' '
        restore_checkpoint &&
 
-       printf "\"file\\101.t\"" >list &&
+       cat >list <<-\EOF &&
+       "file\101.t"
+       EOF
+
        test_must_fail git commit --pathspec-from-file=list --pathspec-file-nul -m "Commit"
 '