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>
Alexandr Miloslavskiy committed
Dec 31, 2019 at 10:15 UTC
568cabb2fed8e5e61057ac678a70a565dffd0763
5 files changed
+45
-11
t/t2026-checkout-pathspec-file.sh
+9
-2
@@ -109,7 +109,11 @@ test_expect_success 'CRLF delimiters' '
109
test_expect_success 'quotes' '
110
restore_checkpoint &&
111
112
- printf "\"file\\101.t\"" | git checkout --pathspec-from-file=- HEAD^1 &&
112
+ cat >list <<-\EOF &&
113
+ "file\101.t"
114
+ EOF
115
+
116
+ git checkout --pathspec-from-file=list HEAD^1 &&
117
118
cat >expect <<-\EOF &&
119
M fileA.t
@@ -120,7 +124,10 @@ test_expect_success 'quotes' '
124
test_expect_success 'quotes not compatible with --pathspec-file-nul' '
125
restore_checkpoint &&
126
123
- printf "\"file\\101.t\"" >list &&
127
+ cat >list <<-\EOF &&
128
+ "file\101.t"
129
+ EOF
130
+
131
test_must_fail git checkout --pathspec-from-file=list --pathspec-file-nul HEAD^1
132
'
133
t/t2072-restore-pathspec-file.sh
+9
-2
@@ -109,7 +109,11 @@ test_expect_success 'CRLF delimiters' '
109
test_expect_success 'quotes' '
110
restore_checkpoint &&
111
112
- printf "\"file\\101.t\"" | git restore --pathspec-from-file=- --source=HEAD^1 &&
112
+ cat >list <<-\EOF &&
113
+ "file\101.t"
114
+ EOF
115
+
116
+ git restore --pathspec-from-file=list --source=HEAD^1 &&
117
118
cat >expect <<-\EOF &&
119
M fileA.t
@@ -120,7 +124,10 @@ test_expect_success 'quotes' '
124
test_expect_success 'quotes not compatible with --pathspec-file-nul' '
125
restore_checkpoint &&
126
123
- printf "\"file\\101.t\"" >list &&
127
+ cat >list <<-\EOF &&
128
+ "file\101.t"
129
+ EOF
130
+
131
test_must_fail git restore --pathspec-from-file=list --pathspec-file-nul --source=HEAD^1
132
'
133
t/t3704-add-pathspec-file.sh
+9
-2
@@ -97,7 +97,11 @@ test_expect_success 'CRLF delimiters' '
97
test_expect_success 'quotes' '
98
restore_checkpoint &&
99
100
- printf "\"file\\101.t\"" | git add --pathspec-from-file=- &&
100
+ cat >list <<-\EOF &&
101
+ "file\101.t"
102
+ EOF
103
+
104
+ git add --pathspec-from-file=list &&
105
106
cat >expect <<-\EOF &&
107
A fileA.t
@@ -108,7 +112,10 @@ test_expect_success 'quotes' '
112
test_expect_success 'quotes not compatible with --pathspec-file-nul' '
113
restore_checkpoint &&
114
111
- printf "\"file\\101.t\"" >list &&
115
+ cat >list <<-\EOF &&
116
+ "file\101.t"
117
+ EOF
118
+
119
test_must_fail git add --pathspec-from-file=list --pathspec-file-nul
120
'
121
t/t7107-reset-pathspec-file.sh
+9
-3
@@ -105,8 +105,12 @@ test_expect_success 'CRLF delimiters' '
105
test_expect_success 'quotes' '
106
restore_checkpoint &&
107
108
+ cat >list <<-\EOF &&
109
+ "file\101.t"
110
+ EOF
111
+
112
git rm fileA.t &&
109
- printf "\"file\\101.t\"" | git reset --pathspec-from-file=- &&
113
+ git reset --pathspec-from-file=list &&
114
115
cat >expect <<-\EOF &&
116
D fileA.t
@@ -117,8 +121,10 @@ test_expect_success 'quotes' '
121
test_expect_success 'quotes not compatible with --pathspec-file-nul' '
122
restore_checkpoint &&
123
120
- git rm fileA.t &&
121
- printf "\"file\\101.t\"" >list &&
124
+ cat >list <<-\EOF &&
125
+ "file\101.t"
126
+ EOF
127
+
128
# Note: "git reset" has not yet learned to fail on wrong pathspecs
129
git reset --pathspec-from-file=list --pathspec-file-nul &&
130
t/t7526-commit-pathspec-file.sh
+9
-2
@@ -100,7 +100,11 @@ test_expect_success 'CRLF delimiters' '
100
test_expect_success 'quotes' '
101
restore_checkpoint &&
102
103
- printf "\"file\\101.t\"" | git commit --pathspec-from-file=- -m "Commit" &&
103
+ cat >list <<-\EOF &&
104
+ "file\101.t"
105
+ EOF
106
+
107
+ git commit --pathspec-from-file=list -m "Commit" &&
108
109
cat >expect <<-\EOF &&
110
A fileA.t
@@ -111,7 +115,10 @@ test_expect_success 'quotes' '
115
test_expect_success 'quotes not compatible with --pathspec-file-nul' '
116
restore_checkpoint &&
117
114
- printf "\"file\\101.t\"" >list &&
118
+ cat >list <<-\EOF &&
119
+ "file\101.t"
120
+ EOF
121
+
122
test_must_fail git commit --pathspec-from-file=list --pathspec-file-nul -m "Commit"
123
'
124