@@ -16,7 +16,8 @@ commit_msg_is () {
16
16
# Arguments: [<prefix] [<commit message>] [<commit options>]
17
17
check_summary_oneline () {
18
18
test_tick &&
19
- git commit ${3+" $3 " } -m " $2 " | head -1 > act &&
19
+ git commit ${3+" $3 " } -m " $2 " > raw &&
20
+ head -n 1 raw > act &&
20
21
21
22
# branch name
22
23
SUMMARY_PREFIX=" $( git name-rev --name-only HEAD) " &&
@@ -68,7 +69,7 @@ test_expect_success 'output summary format for merges' '
68
69
git checkout recursive-a &&
69
70
test_must_fail git merge recursive-b &&
70
71
# resolve the conflict
71
- echo commit-a > file1 &&
72
+ echo commit-a >file1 &&
72
73
git add file1 &&
73
74
check_summary_oneline "" "Merge"
74
75
'
@@ -142,9 +143,11 @@ test_expect_success 'sign off' '
142
143
>positive &&
143
144
git add positive &&
144
145
git commit -s -m "thank you" &&
145
- actual=$(git cat-file commit HEAD | sed -ne "s/Signed-off-by: //p") &&
146
- expected=$(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/") &&
147
- test "z$actual" = "z$expected"
146
+ git cat-file commit HEAD >commit.msg &&
147
+ sed -ne "s/Signed-off-by: //p" commit.msg >actual &&
148
+ git var GIT_COMMITTER_IDENT >ident &&
149
+ sed -e "s/>.*/>/" ident >expected &&
150
+ test_cmp expected actual
148
151
149
152
'
150
153
@@ -153,8 +156,8 @@ test_expect_success 'multiple -m' '
153
156
>negative &&
154
157
git add negative &&
155
158
git commit -m "one" -m "two" -m "three" &&
156
- actual=$(git cat-file commit HEAD | sed -e "1,/^\$/d") &&
157
- expected=$(echo one; echo; echo two; echo; echo three) &&
159
+ actual=$(git cat-file commit HEAD >tmp && sed -e "1,/^\$/d" tmp && rm tmp ) &&
160
+ expected=$(test_write_lines " one" "" " two" "" " three" ) &&
158
161
test "z$actual" = "z$expected"
159
162
160
163
'
@@ -163,7 +166,8 @@ test_expect_success 'verbose' '
163
166
164
167
echo minus >negative &&
165
168
git add negative &&
166
- git status -v | sed -ne "/^diff --git /p" >actual &&
169
+ git status -v >raw &&
170
+ sed -ne "/^diff --git /p" raw >actual &&
167
171
echo "diff --git a/negative b/negative" >expect &&
168
172
test_cmp expect actual
169
173
@@ -189,7 +193,8 @@ test_expect_success 'cleanup commit messages (verbatim option,-t)' '
189
193
190
194
echo >>negative &&
191
195
git commit --cleanup=verbatim --no-status -t expect -a &&
192
- git cat-file -p HEAD |sed -e "1,/^\$/d" >actual &&
196
+ git cat-file -p HEAD >raw &&
197
+ sed -e "1,/^\$/d" raw >actual &&
193
198
test_cmp expect actual
194
199
195
200
'
@@ -198,7 +203,8 @@ test_expect_success 'cleanup commit messages (verbatim option,-F)' '
198
203
199
204
echo >>negative &&
200
205
git commit --cleanup=verbatim -F expect -a &&
201
- git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
206
+ git cat-file -p HEAD >raw &&
207
+ sed -e "1,/^\$/d" raw >actual &&
202
208
test_cmp expect actual
203
209
204
210
'
@@ -207,75 +213,80 @@ test_expect_success 'cleanup commit messages (verbatim option,-m)' '
207
213
208
214
echo >>negative &&
209
215
git commit --cleanup=verbatim -m "$mesg_with_comment_and_newlines" -a &&
210
- git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
216
+ git cat-file -p HEAD >raw &&
217
+ sed -e "1,/^\$/d" raw >actual &&
211
218
test_cmp expect actual
212
219
213
220
'
214
221
215
222
test_expect_success ' cleanup commit messages (whitespace option,-F)' '
216
223
217
224
echo >>negative &&
218
- { echo;echo "# text";echo; } >text &&
225
+ test_write_lines "" "# text" "" >text &&
219
226
echo "# text" >expect &&
220
227
git commit --cleanup=whitespace -F text -a &&
221
- git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
228
+ git cat-file -p HEAD >raw &&
229
+ sed -e "1,/^\$/d" raw >actual &&
222
230
test_cmp expect actual
223
231
224
232
'
225
233
226
234
test_expect_success ' cleanup commit messages (scissors option,-F,-e)' '
227
235
228
236
echo >>negative &&
229
- cat >text <<EOF &&
237
+ cat >text <<-\ EOF &&
230
238
231
- # to be kept
239
+ # to be kept
232
240
233
- # ------------------------ >8 ------------------------
234
- # to be kept, too
235
- # ------------------------ >8 ------------------------
236
- to be removed
237
- # ------------------------ >8 ------------------------
238
- to be removed, too
239
- EOF
241
+ # ------------------------ >8 ------------------------
242
+ # to be kept, too
243
+ # ------------------------ >8 ------------------------
244
+ to be removed
245
+ # ------------------------ >8 ------------------------
246
+ to be removed, too
247
+ EOF
240
248
241
- cat >expect <<EOF &&
242
- # to be kept
249
+ cat >expect <<-\ EOF &&
250
+ # to be kept
243
251
244
- # ------------------------ >8 ------------------------
245
- # to be kept, too
246
- EOF
252
+ # ------------------------ >8 ------------------------
253
+ # to be kept, too
254
+ EOF
247
255
git commit --cleanup=scissors -e -F text -a &&
248
- git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
256
+ git cat-file -p HEAD >raw &&
257
+ sed -e "1,/^\$/d" raw >actual &&
249
258
test_cmp expect actual
250
259
'
251
260
252
261
test_expect_success ' cleanup commit messages (scissors option,-F,-e, scissors on first line)' '
253
262
254
263
echo >>negative &&
255
- cat >text <<EOF &&
256
- # ------------------------ >8 ------------------------
257
- to be removed
258
- EOF
264
+ cat >text <<-\ EOF &&
265
+ # ------------------------ >8 ------------------------
266
+ to be removed
267
+ EOF
259
268
git commit --cleanup=scissors -e -F text -a --allow-empty-message &&
260
- git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
269
+ git cat-file -p HEAD >raw &&
270
+ sed -e "1,/^\$/d" raw >actual &&
261
271
test_must_be_empty actual
262
272
'
263
273
264
274
test_expect_success ' cleanup commit messages (strip option,-F)' '
265
275
266
276
echo >>negative &&
267
- { echo;echo "# text";echo sample;echo; } >text &&
277
+ test_write_lines "" "# text" " sample" "" >text &&
268
278
echo sample >expect &&
269
279
git commit --cleanup=strip -F text -a &&
270
- git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
280
+ git cat-file -p HEAD >raw &&
281
+ sed -e "1,/^\$/d" raw >actual &&
271
282
test_cmp expect actual
272
283
273
284
'
274
285
275
286
test_expect_success ' cleanup commit messages (strip option,-F,-e)' '
276
287
277
288
echo >>negative &&
278
- { echo;echo sample;echo; } >text &&
289
+ test_write_lines "" " sample" "" >text &&
279
290
git commit -e -F text -a &&
280
291
head -n 4 .git/COMMIT_EDITMSG >actual
281
292
'
@@ -387,7 +398,7 @@ test_expect_success AUTOIDENT 'message shows committer when it is automatic' '
387
398
'
388
399
389
400
write_script .git/FAKE_EDITOR << EOF
390
- echo editor started > "$( pwd) /.git/result"
401
+ echo editor started >"$( pwd) /.git/result"
391
402
exit 0
392
403
EOF
393
404
455
466
test_expect_success EXECKEEPSPID ' a SIGTERM should break locks' '
456
467
echo >>negative &&
457
468
! "$SHELL_PATH" -c ' \' '
458
- echo kill -TERM $$ >> .git/FAKE_EDITOR
469
+ echo kill -TERM $$ >>.git/FAKE_EDITOR
459
470
GIT_EDITOR=.git/FAKE_EDITOR
460
471
export GIT_EDITOR
461
472
exec git commit -a' \' ' &&
@@ -471,7 +482,8 @@ test_expect_success 'Hand committing of a redundant merge removes dups' '
471
482
test_must_fail git merge second master &&
472
483
git checkout master g &&
473
484
EDITOR=: git commit -a &&
474
- git cat-file commit HEAD | sed -n -e "s/^parent //p" -e "/^$/q" >actual &&
485
+ git cat-file commit HEAD >raw &&
486
+ sed -n -e "s/^parent //p" -e "/^$/q" raw >actual &&
475
487
test_cmp expect actual
476
488
477
489
'
@@ -480,7 +492,8 @@ test_expect_success 'A single-liner subject with a token plus colon is not a foo
480
492
481
493
git reset --hard &&
482
494
git commit -s -m "hello: kitty" --allow-empty &&
483
- git cat-file commit HEAD | sed -e "1,/^$/d" >actual &&
495
+ git cat-file commit HEAD >raw &&
496
+ sed -e "1,/^$/d" raw >actual &&
484
497
test_line_count = 3 actual
485
498
486
499
'
0 commit comments