summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorAlexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>2019-12-31 10:15:11 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-01-15 20:14:20 (GMT)
commit568cabb2fed8e5e61057ac678a70a565dffd0763 (patch)
tree5ae4d2967f70ac05d15fe6c5db1e0dc2cff09472 /t
parentd0654dc308b0ba76dd8ed7bbb33c8d8f7aacd783 (diff)
downloadgit-568cabb2fed8e5e61057ac678a70a565dffd0763.zip
git-568cabb2fed8e5e61057ac678a70a565dffd0763.tar.gz
git-568cabb2fed8e5e61057ac678a70a565dffd0763.tar.bz2
t: fix quotes tests for --pathspec-from-file
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>
Diffstat (limited to 't')
-rwxr-xr-xt/t2026-checkout-pathspec-file.sh11
-rwxr-xr-xt/t2072-restore-pathspec-file.sh11
-rwxr-xr-xt/t3704-add-pathspec-file.sh11
-rwxr-xr-xt/t7107-reset-pathspec-file.sh12
-rwxr-xr-xt/t7526-commit-pathspec-file.sh11
5 files changed, 45 insertions, 11 deletions
diff --git a/t/t2026-checkout-pathspec-file.sh b/t/t2026-checkout-pathspec-file.sh
index f62fd27..adad71f 100755
--- a/t/t2026-checkout-pathspec-file.sh
+++ b/t/t2026-checkout-pathspec-file.sh
@@ -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
'
diff --git a/t/t2072-restore-pathspec-file.sh b/t/t2072-restore-pathspec-file.sh
index db58e83..b407f6b 100755
--- a/t/t2072-restore-pathspec-file.sh
+++ b/t/t2072-restore-pathspec-file.sh
@@ -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
'
diff --git a/t/t3704-add-pathspec-file.sh b/t/t3704-add-pathspec-file.sh
index 3cfdb66..61b6e51 100755
--- a/t/t3704-add-pathspec-file.sh
+++ b/t/t3704-add-pathspec-file.sh
@@ -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
'
diff --git a/t/t7107-reset-pathspec-file.sh b/t/t7107-reset-pathspec-file.sh
index 6b1a731..b0e84cd 100755
--- a/t/t7107-reset-pathspec-file.sh
+++ b/t/t7107-reset-pathspec-file.sh
@@ -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 &&
diff --git a/t/t7526-commit-pathspec-file.sh b/t/t7526-commit-pathspec-file.sh
index 4b58901..4a7c113 100755
--- a/t/t7526-commit-pathspec-file.sh
+++ b/t/t7526-commit-pathspec-file.sh
@@ -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"
'