t: use commit_body to extract commit message bodies

Replace the "git cat-file commit | sed" idiom with commit_body across the test suite: 61 sites in 12 files, plus one local helper that wrapped the same idiom. The idiom appears in four equivalent spellings -- piped or written to a file first, "sed -e" or plain "sed", "\$" or "$" in the address -- all producing byte-identical output; they all collapse to the same commit_body call. t7509-commit-authorship.sh defined its own local message_body() helper around the idiom instead of spelling it out at each call site; remove the helper and convert its six call sites to commit_body directly. Two sites needed more than a mechanical substitution: * t7600.sh ("merge --no-ff --edit") greps the raw commit object for a phrase before stripping its header for the final comparison. The phrase is part of the commit body, not the header, so the grep can run against the already-stripped body instead, letting both steps share one commit_body call. * t3900-i18n-commit.sh pipes the stripped body into "iconv" to test re-encoding. Piping commit_body's output into "iconv" would reintroduce an exit-code hole one line after removing it elsewhere, so this site writes the body to a file first and reads that, keeping the &&-chain intact. Some greps for sed -e "1,/^\*$/d" left unconverted, as they are not extracting a commit's message body: * t9001-send-email.sh strips mail headers from a message file, not a commit object. * t1450-fsck.sh strips the header off a hand-built commit object while constructing a malformed one for fsck to reject. * t4014-format-patch.sh runs the same sed address on a ".patch" file, with an additional expression. All converted files pass in full, and a deliberately failing "git cat-file" now fails a converted test that previously passed. Signed-off-by: Shlok Kulshreshtha <diy2903@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Shlok Kulshreshtha committed Jul 27, 2026 at 15:26 UTC 9539653b71ed1ab37302574f96544013b8829eb9
13 files changed +72 -123
t/t3404-rebase-interactive.sh
+1 -1
@@ -484,7 +484,7 @@ test_expect_success 'squash and fixup generate correct log messages' '
484 EXPECT_HEADER_COUNT=4 \
485 git rebase -i $base
486 ) &&
487 - git cat-file commit HEAD | sed -e 1,/^\$/d > actual-squash-fixup &&
487 + commit_body HEAD >actual-squash-fixup &&
488 test_cmp expect-squash-fixup actual-squash-fixup &&
489 git cat-file commit HEAD@{2} >actual &&
490 test_grep "^# This is a combination of 3 commits\." actual &&
t/t3405-rebase-malformed.sh
+4 -4
@@ -37,7 +37,7 @@ test_expect_success setup '
37 test_tick &&
38 git commit -F F &&
39
40 - git cat-file commit HEAD | sed -e "1,/^\$/d" >F0 &&
40 + commit_body HEAD >F0 &&
41
42 git checkout diff-in-message &&
43 echo "commit log message containing a diff" >G &&
@@ -48,7 +48,7 @@ test_expect_success setup '
48 test_tick &&
49 git commit -F G &&
50
51 - git cat-file commit HEAD | sed -e "1,/^\$/d" >G0 &&
51 + commit_body HEAD >G0 &&
52
53 git checkout empty-message-merge &&
54 echo file3 >file3 &&
@@ -66,7 +66,7 @@ test_expect_success setup '
66 test_expect_success 'rebase commit with multi-line subject' '
67
68 git rebase main multi-line-subject &&
69 - git cat-file commit HEAD | sed -e "1,/^\$/d" >F1 &&
69 + commit_body HEAD >F1 &&
70
71 test_cmp F0 F1 &&
72 test_cmp F F0
@@ -74,7 +74,7 @@ test_expect_success 'rebase commit with multi-line subject' '
74
75 test_expect_success 'rebase commit with diff in message' '
76 git rebase main diff-in-message &&
77 - git cat-file commit HEAD | sed -e "1,/^$/d" >G1 &&
77 + commit_body HEAD >G1 &&
78 test_cmp G0 G1 &&
79 test_cmp G G0
80 '
t/t3408-rebase-multi-line.sh
+2 -2
@@ -50,8 +50,8 @@ test_expect_success rebase '
50
51 git checkout side &&
52 git rebase main &&
53 - git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
54 - git cat-file commit side@{1} | sed -e "1,/^\$/d" >expect &&
53 + commit_body HEAD >actual &&
54 + commit_body side@{1} >expect &&
55 test_cmp expect actual
56
57 '
t/t3434-rebase-i18n.sh
+1 -2
@@ -27,8 +27,7 @@ fi
27
28 compare_msg () {
29 iconv -f "$2" -t "$3" "$TEST_DIRECTORY/t3434/$1" >expect &&
30 - git cat-file commit HEAD >raw &&
31 - sed "1,/^$/d" raw >actual &&
30 + commit_body HEAD >actual &&
31 test_cmp expect actual
32 }
33
t/t3900-i18n-commit.sh
+2 -2
@@ -232,8 +232,8 @@ test_commit_autosquash_multi_encoding () {
232 git rev-list HEAD >actual &&
233 test_line_count = 3 actual &&
234 iconv -f $old -t UTF-8 "$TEST_DIRECTORY"/t3900/$msg >expect &&
235 - git cat-file commit HEAD^ >raw &&
236 - (sed "1,/^$/d" raw | iconv -f $new -t utf-8) >actual &&
235 + commit_body HEAD^ >raw &&
236 + iconv -f $new -t utf-8 <raw >actual &&
237 test_cmp expect actual
238 '
239 }
t/t4150-am.sh
+4 -4
@@ -1018,7 +1018,7 @@ test_expect_success 'am -s unexpected trailer block' '
1018 Signed-off-by: J C H <j@c.h>
1019 EOF
1020 git commit -F msg &&
1021 - git cat-file commit HEAD | sed -e "1,/^$/d" >original &&
1021 + commit_body HEAD >original &&
1022 git format-patch --stdout -1 >patch &&
1023
1024 git reset --hard HEAD^ &&
@@ -1027,7 +1027,7 @@ test_expect_success 'am -s unexpected trailer block' '
1027 cat original &&
1028 echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
1029 ) >expect &&
1030 - git cat-file commit HEAD | sed -e "1,/^$/d" >actual &&
1030 + commit_body HEAD >actual &&
1031 test_cmp expect actual &&
1032
1033 cat >msg <<-\EOF &&
@@ -1038,7 +1038,7 @@ test_expect_success 'am -s unexpected trailer block' '
1038 EOF
1039 git reset HEAD^ &&
1040 git commit -F msg file &&
1041 - git cat-file commit HEAD | sed -e "1,/^$/d" >original &&
1041 + commit_body HEAD >original &&
1042 git format-patch --stdout -1 >patch &&
1043
1044 git reset --hard HEAD^ &&
@@ -1049,7 +1049,7 @@ test_expect_success 'am -s unexpected trailer block' '
1049 echo &&
1050 echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
1051 ) >expect &&
1052 - git cat-file commit HEAD | sed -e "1,/^$/d" >actual &&
1052 + commit_body HEAD >actual &&
1053 test_cmp expect actual
1054 '
1055
t/t7500-commit-template-squash-signoff.sh
+2 -2
@@ -59,7 +59,7 @@ test_expect_success 'nonexistent template file in config should return error' '
59 test_expect_success 'nonexistent optional template file in config' '
60 test_config commit.template ":(optional)$(pwd)"/notexist &&
61 GIT_EDITOR="echo hello >" git commit --allow-empty &&
62 - git cat-file commit HEAD | sed -e "1,/^$/d" >actual &&
62 + commit_body HEAD >actual &&
63 echo hello >expect &&
64 test_cmp expect actual
65 '
@@ -204,7 +204,7 @@ EOF
204 test_expect_success '--signoff' '
205 echo "yet another content *narf*" >> foo &&
206 echo "zort" | git commit -s -F - foo &&
207 - git cat-file commit HEAD | sed "1,/^\$/d" > output &&
207 + commit_body HEAD >output &&
208 test_cmp expect output
209 '
210
t/t7501-commit-basic-functionality.sh
+7 -14
@@ -491,8 +491,7 @@ test_expect_success 'sign off (1)' '
491 echo 1 >positive &&
492 git add positive &&
493 git commit -s -m "thank you" &&
494 - git cat-file commit HEAD >commit &&
495 - sed -e "1,/^\$/d" commit >actual &&
494 + commit_body HEAD >actual &&
495 (
496 echo thank you &&
497 echo &&
@@ -511,8 +510,7 @@ test_expect_success 'sign off (2)' '
510 git commit -s -m "thank you
511
512 $existing" &&
514 - git cat-file commit HEAD >commit &&
515 - sed -e "1,/^\$/d" commit >actual &&
513 + commit_body HEAD >actual &&
514 (
515 echo thank you &&
516 echo &&
@@ -532,8 +530,7 @@ test_expect_success 'signoff gap' '
530 git commit -s -m "welcome
531
532 $alt" &&
535 - git cat-file commit HEAD >commit &&
536 - sed -e "1,/^\$/d" commit >actual &&
533 + commit_body HEAD >actual &&
534 (
535 echo welcome &&
536 echo &&
@@ -553,8 +550,7 @@ test_expect_success 'signoff gap 2' '
550
551 We have now
552 $alt" &&
556 - git cat-file commit HEAD >commit &&
557 - sed -e "1,/^\$/d" commit >actual &&
553 + commit_body HEAD >actual &&
554 (
555 echo welcome &&
556 echo &&
@@ -575,8 +571,7 @@ test_expect_success 'signoff respects trailer config' '
571
572 non-trailer line
573 Myfooter: x" &&
578 - git cat-file commit HEAD >commit &&
579 - sed -e "1,/^\$/d" commit >actual &&
574 + commit_body HEAD >actual &&
575 (
576 echo subject &&
577 echo &&
@@ -593,8 +588,7 @@ Myfooter: x" &&
588
589 non-trailer line
590 Myfooter: x" &&
596 - git cat-file commit HEAD >commit &&
597 - sed -e "1,/^\$/d" commit >actual &&
591 + commit_body HEAD >actual &&
592 (
593 echo subject &&
594 echo &&
@@ -626,8 +620,7 @@ test_expect_success 'multiple -m' '
620 >negative &&
621 git add negative &&
622 git commit -m "one" -m "two" -m "three" &&
629 - git cat-file commit HEAD >commit &&
630 - sed -e "1,/^\$/d" commit >actual &&
623 + commit_body HEAD >actual &&
624 (
625 echo one &&
626 echo &&
t/t7502-commit-porcelain.sh
+26 -51
@@ -175,8 +175,7 @@ test_expect_success 'commit --trailer with "="' '
175 Reported-by: C3 E3
176 Mentored-by: C4 E4
177 EOF
178 - git cat-file commit HEAD >commit.msg &&
179 - sed -e "1,/^\$/d" commit.msg >actual &&
178 + commit_body HEAD >actual &&
179 test_cmp expected actual
180 '
181
@@ -195,8 +194,7 @@ test_expect_success 'commit --trailer with -c and "replace" as ifexists' '
194 commit --trailer "Mentored-by: C4 E4" \
195 --trailer "Helped-by: C3 E3" \
196 --amend &&
198 - git cat-file commit HEAD >commit.msg &&
199 - sed -e "1,/^\$/d" commit.msg >actual &&
197 + commit_body HEAD >actual &&
198 test_cmp expected actual
199 '
200
@@ -217,8 +215,7 @@ test_expect_success 'commit --trailer with -c and "add" as ifexists' '
215 commit --trailer "Reported-by: C3 E3" \
216 --trailer "Mentored-by: C4 E4" \
217 --amend &&
220 - git cat-file commit HEAD >commit.msg &&
221 - sed -e "1,/^\$/d" commit.msg >actual &&
218 + commit_body HEAD >actual &&
219 test_cmp expected actual
220 '
221
@@ -238,8 +235,7 @@ test_expect_success 'commit --trailer with -c and "donothing" as ifexists' '
235 commit --trailer "Mentored-by: C5 E5" \
236 --trailer "Reviewed-by: C6 E6" \
237 --amend &&
241 - git cat-file commit HEAD >commit.msg &&
242 - sed -e "1,/^\$/d" commit.msg >actual &&
238 + commit_body HEAD >actual &&
239 test_cmp expected actual
240 '
241
@@ -259,8 +255,7 @@ test_expect_success 'commit --trailer with -c and "addIfDifferent" as ifexists'
255 commit --trailer "Reported-by: C3 E3" \
256 --trailer "Mentored-by: C5 E5" \
257 --amend &&
262 - git cat-file commit HEAD >commit.msg &&
263 - sed -e "1,/^\$/d" commit.msg >actual &&
258 + commit_body HEAD >actual &&
259 test_cmp expected actual
260 '
261
@@ -280,8 +275,7 @@ test_expect_success 'commit --trailer with -c and "addIfDifferentNeighbor" as if
275 commit --trailer "Mentored-by: C4 E4" \
276 --trailer "Reported-by: C3 E3" \
277 --amend &&
283 - git cat-file commit HEAD >commit.msg &&
284 - sed -e "1,/^\$/d" commit.msg >actual &&
278 + commit_body HEAD >actual &&
279 test_cmp expected actual
280 '
281
@@ -302,8 +296,7 @@ test_expect_success 'commit --trailer with -c and "end" as where' '
296 commit --trailer "Reported-by: C3 E3" \
297 --trailer "Mentored-by: C4 E4" \
298 --amend &&
305 - git cat-file commit HEAD >commit.msg &&
306 - sed -e "1,/^\$/d" commit.msg >actual &&
299 + commit_body HEAD >actual &&
300 test_cmp expected actual
301 '
302
@@ -323,8 +316,7 @@ test_expect_success 'commit --trailer with -c and "start" as where' '
316 commit --trailer "Signed-off-by: C O Mitter <committer@example.com>" \
317 --trailer "Signed-off-by: C1 E1" \
318 --amend &&
326 - git cat-file commit HEAD >commit.msg &&
327 - sed -e "1,/^\$/d" commit.msg >actual &&
319 + commit_body HEAD >actual &&
320 test_cmp expected actual
321 '
322
@@ -344,8 +336,7 @@ test_expect_success 'commit --trailer with -c and "after" as where' '
336 commit --trailer "Mentored-by: C4 E4" \
337 --trailer "Mentored-by: C5 E5" \
338 --amend &&
347 - git cat-file commit HEAD >commit.msg &&
348 - sed -e "1,/^\$/d" commit.msg >actual &&
339 + commit_body HEAD >actual &&
340 test_cmp expected actual
341 '
342
@@ -366,8 +357,7 @@ test_expect_success 'commit --trailer with -c and "before" as where' '
357 commit --trailer "Mentored-by: C3 E3" \
358 --trailer "Mentored-by: C2 E2" \
359 --amend &&
369 - git cat-file commit HEAD >commit.msg &&
370 - sed -e "1,/^\$/d" commit.msg >actual &&
360 + commit_body HEAD >actual &&
361 test_cmp expected actual
362 '
363
@@ -387,8 +377,7 @@ test_expect_success 'commit --trailer with -c and "donothing" as ifmissing' '
377 commit --trailer "Helped-by: C5 E5" \
378 --trailer "Based-by: C6 E6" \
379 --amend &&
390 - git cat-file commit HEAD >commit.msg &&
391 - sed -e "1,/^\$/d" commit.msg >actual &&
380 + commit_body HEAD >actual &&
381 test_cmp expected actual
382 '
383
@@ -409,8 +398,7 @@ test_expect_success 'commit --trailer with -c and "add" as ifmissing' '
398 commit --trailer "Helped-by: C5 E5" \
399 --trailer "Based-by: C6 E6" \
400 --amend &&
412 - git cat-file commit HEAD >commit.msg &&
413 - sed -e "1,/^\$/d" commit.msg >actual &&
401 + commit_body HEAD >actual &&
402 test_cmp expected actual
403 '
404
@@ -424,8 +412,7 @@ test_expect_success 'commit --trailer with -c ack.key ' '
412 EOF
413 git -c trailer.ack.key="Acked-by" \
414 commit --trailer "ack = Peff" -m "hello" &&
427 - git cat-file commit HEAD >commit.msg &&
428 - sed -e "1,/^\$/d" commit.msg >actual &&
415 + commit_body HEAD >actual &&
416 test_cmp expected actual
417 '
418
@@ -440,8 +427,7 @@ test_expect_success 'commit --trailer with -c and ":=#" as separators' '
427 git -c trailer.separators=":=#" \
428 -c trailer.bug.key="Bug #" \
429 commit --trailer "bug = 42" -m "I hate bug" &&
443 - git cat-file commit HEAD >commit.msg &&
444 - sed -e "1,/^\$/d" commit.msg >actual &&
430 + commit_body HEAD >actual &&
431 test_cmp expected actual
432 '
433
@@ -461,8 +447,7 @@ test_expect_success 'commit --trailer with -c and command' '
447 -c trailer.report.command="NAME=\"\$ARG\"; test -n \"\$NAME\" && \
448 git log --author=\"\$NAME\" -1 --format=\"format:%aN <%aE>\" || true" \
449 commit --trailer "report = author" --amend &&
464 - git cat-file commit HEAD >commit.msg &&
465 - sed -e "1,/^\$/d" commit.msg >actual &&
450 + commit_body HEAD >actual &&
451 test_cmp expected actual
452 '
453
@@ -480,8 +465,7 @@ test_expect_success 'commit --trailer not confused by --- separator' '
465 echo &&
466 echo "my-trailer: value"
467 } >expected &&
483 - git cat-file commit HEAD >commit.msg &&
484 - sed -e "1,/^\$/d" commit.msg >actual &&
468 + commit_body HEAD >actual &&
469 test_cmp expected actual
470 '
471
@@ -498,8 +482,7 @@ test_expect_success 'commit --trailer with --verbose' '
482 echo &&
483 echo "my-trailer: value"
484 } >expected &&
501 - git cat-file commit HEAD >commit.msg &&
502 - sed -e "1,/^\$/d" commit.msg >actual &&
485 + commit_body HEAD >actual &&
486 test_cmp expected actual
487 '
488
@@ -508,7 +491,7 @@ test_expect_success 'multiple -m' '
491 >negative &&
492 git add negative &&
493 git commit -m "one" -m "two" -m "three" &&
511 - actual=$(git cat-file commit HEAD >tmp && sed -e "1,/^\$/d" tmp && rm tmp) &&
494 + actual=$(commit_body HEAD) &&
495 expected=$(test_write_lines "one" "" "two" "" "three") &&
496 test "z$actual" = "z$expected"
497
@@ -545,8 +528,7 @@ test_expect_success 'cleanup commit messages (verbatim option,-t)' '
528
529 echo >>negative &&
530 git commit --cleanup=verbatim --no-status -t expect -a &&
548 - git cat-file -p HEAD >raw &&
549 - sed -e "1,/^\$/d" raw >actual &&
531 + commit_body HEAD >actual &&
532 test_cmp expect actual
533
534 '
@@ -555,8 +537,7 @@ test_expect_success 'cleanup commit messages (verbatim option,-F)' '
537
538 echo >>negative &&
539 git commit --cleanup=verbatim -F expect -a &&
558 - git cat-file -p HEAD >raw &&
559 - sed -e "1,/^\$/d" raw >actual &&
540 + commit_body HEAD >actual &&
541 test_cmp expect actual
542
543 '
@@ -565,8 +546,7 @@ test_expect_success 'cleanup commit messages (verbatim option,-m)' '
546
547 echo >>negative &&
548 git commit --cleanup=verbatim -m "$mesg_with_comment_and_newlines" -a &&
568 - git cat-file -p HEAD >raw &&
569 - sed -e "1,/^\$/d" raw >actual &&
549 + commit_body HEAD >actual &&
550 test_cmp expect actual
551
552 '
@@ -577,8 +557,7 @@ test_expect_success 'cleanup commit messages (whitespace option,-F)' '
557 test_write_lines "" "# text" "" >text &&
558 echo "# text" >expect &&
559 git commit --cleanup=whitespace -F text -a &&
580 - git cat-file -p HEAD >raw &&
581 - sed -e "1,/^\$/d" raw >actual &&
560 + commit_body HEAD >actual &&
561 test_cmp expect actual
562
563 '
@@ -605,8 +584,7 @@ test_expect_success 'cleanup commit messages (scissors option,-F,-e)' '
584 # to be kept, too
585 EOF
586 git commit --cleanup=scissors -e -F text -a &&
608 - git cat-file -p HEAD >raw &&
609 - sed -e "1,/^\$/d" raw >actual &&
587 + commit_body HEAD >actual &&
588 test_cmp expect actual
589 '
590
@@ -618,8 +596,7 @@ test_expect_success 'cleanup commit messages (scissors option,-F,-e, scissors on
596 to be removed
597 EOF
598 git commit --cleanup=scissors -e -F text -a --allow-empty-message &&
621 - git cat-file -p HEAD >raw &&
622 - sed -e "1,/^\$/d" raw >actual &&
599 + commit_body HEAD >actual &&
600 test_must_be_empty actual
601 '
602
@@ -629,8 +606,7 @@ test_expect_success 'cleanup commit messages (strip option,-F)' '
606 test_write_lines "" "# text" "sample" "" >text &&
607 echo sample >expect &&
608 git commit --cleanup=strip -F text -a &&
632 - git cat-file -p HEAD >raw &&
633 - sed -e "1,/^\$/d" raw >actual &&
609 + commit_body HEAD >actual &&
610 test_cmp expect actual
611
612 '
@@ -849,8 +825,7 @@ test_expect_success 'A single-liner subject with a token plus colon is not a foo
825
826 git reset --hard &&
827 git commit -s -m "hello: kitty" --allow-empty &&
852 - git cat-file commit HEAD >raw &&
853 - sed -e "1,/^$/d" raw >actual &&
828 + commit_body HEAD >actual &&
829 test_line_count = 3 actual
830
831 '
t/t7509-commit-authorship.sh
+9 -14
@@ -12,11 +12,6 @@ author_header () {
12 sed -n -e '/^$/q' -e '/^author /p'
13 }
14
15 -message_body () {
16 - git cat-file commit "$1" |
17 - sed -e '1,/^$/d'
18 -}
19 -
15 test_expect_success '-C option copies authorship and message' '
16 test_commit --author Frigate\ \<flying@over.world\> \
17 "Initial Commit" foo Initial Initial &&
@@ -27,8 +22,8 @@ test_expect_success '-C option copies authorship and message' '
22 author_header HEAD >actual &&
23 test_cmp expect actual &&
24
30 - message_body Initial >expect &&
31 - message_body HEAD >actual &&
25 + commit_body Initial >expect &&
26 + commit_body HEAD >actual &&
27 test_cmp expect actual
28 '
29
@@ -40,8 +35,8 @@ test_expect_success '-C option copies only the message with --reset-author' '
35 author_header HEAD >actual &&
36 test_cmp expect actual &&
37
43 - message_body Initial >expect &&
44 - message_body HEAD >actual &&
38 + commit_body Initial >expect &&
39 + commit_body HEAD >actual &&
40 test_cmp expect actual
41 '
42
@@ -62,8 +57,8 @@ test_expect_success '-c option copies only the message with --reset-author' '
57 author_header HEAD >actual &&
58 test_cmp expect actual &&
59
65 - message_body Initial >expect &&
66 - message_body HEAD >actual &&
60 + commit_body Initial >expect &&
61 + commit_body HEAD >actual &&
62 test_cmp expect actual
63 '
64
@@ -77,7 +72,7 @@ test_expect_success '--amend option copies authorship' '
72 test_cmp expect actual &&
73
74 echo "amend test" >expect &&
80 - message_body HEAD >actual &&
75 + commit_body HEAD >actual &&
76 test_cmp expect actual
77 '
78
@@ -124,7 +119,7 @@ test_expect_success '--reset-author makes the commit ours even with --amend opti
119 test_cmp expect actual &&
120
121 echo "Changed again" >expect &&
127 - message_body HEAD >actual &&
122 + commit_body HEAD >actual &&
123 test_cmp expect actual
124 '
125
@@ -157,7 +152,7 @@ test_expect_success 'commit respects CHERRY_PICK_HEAD and MERGE_MSG' '
152 test_cmp expect actual &&
153
154 echo "This is a MERGE_MSG" >expect &&
160 - message_body HEAD >actual &&
155 + commit_body HEAD >actual &&
156 test_cmp expect actual
157 '
158
t/t7600-merge.sh
+5 -9
@@ -332,8 +332,7 @@ test_expect_success 'merge --squash c3 with c7' '
332 # Conflicts:
333 # file
334 EOF
335 - git cat-file commit HEAD >raw &&
336 - sed -e "1,/^$/d" raw >actual &&
335 + commit_body HEAD >actual &&
336 test_cmp expect actual
337 '
338
@@ -363,8 +362,7 @@ test_expect_success 'merge c3 with c7 with commit.cleanup = scissors' '
362 # Conflicts:
363 # file
364 EOF
366 - git cat-file commit HEAD >raw &&
367 - sed -e "1,/^$/d" raw >actual &&
365 + commit_body HEAD >actual &&
366 test_cmp expect actual
367 '
368
@@ -387,8 +385,7 @@ test_expect_success 'merge c3 with c7 with --squash commit.cleanup = scissors' '
385 # Conflicts:
386 # file
387 EOF
390 - git cat-file commit HEAD >raw &&
391 - sed -e "1,/^$/d" raw >actual &&
388 + commit_body HEAD >actual &&
389 test_cmp expect actual
390 '
391
@@ -989,9 +986,8 @@ test_expect_success 'merge --no-ff --edit' '
986 git reset --hard c0 &&
987 EDITOR=./editor git merge --no-ff --edit c1 &&
988 verify_parents $c0 $c1 &&
992 - git cat-file commit HEAD >raw &&
993 - test_grep "work done on the side branch" raw &&
994 - sed "1,/^$/d" >actual raw &&
989 + commit_body HEAD >actual &&
990 + test_grep "work done on the side branch" actual &&
991 test_cmp expected actual
992 '
993
t/t7604-merge-custom-message.sh
+6 -12
@@ -36,16 +36,14 @@ test_expect_success 'setup' '
36 test_expect_success 'merge c2 with a custom message' '
37 git reset --hard c1 &&
38 git merge -m "$(cat exp.subject)" c2 &&
39 - git cat-file commit HEAD >raw &&
40 - sed -e "1,/^$/d" raw >actual &&
39 + commit_body HEAD >actual &&
40 test_cmp exp.subject actual
41 '
42
43 test_expect_success 'merge --log appends to custom message' '
44 git reset --hard c1 &&
45 git merge --log -m "$(cat exp.subject)" c2 &&
47 - git cat-file commit HEAD >raw &&
48 - sed -e "1,/^$/d" raw >actual &&
46 + commit_body HEAD >actual &&
47 test_cmp exp.log actual
48 '
49
@@ -61,8 +59,7 @@ test_expect_success 'prepare file with comment line and trailing newlines' '
59 test_expect_success 'cleanup commit messages (verbatim option)' '
60 git reset --hard c1 &&
61 git merge --cleanup=verbatim -F expect c2 &&
64 - git cat-file commit HEAD >raw &&
65 - sed -e "1,/^$/d" raw >actual &&
62 + commit_body HEAD >actual &&
63 test_cmp expect actual
64 '
65
@@ -71,8 +68,7 @@ test_expect_success 'cleanup commit messages (whitespace option)' '
68 test_write_lines "" "# text" "" >text &&
69 echo "# text" >expect &&
70 git merge --cleanup=whitespace -F text c2 &&
74 - git cat-file commit HEAD >raw &&
75 - sed -e "1,/^$/d" raw >actual &&
71 + commit_body HEAD >actual &&
72 test_cmp expect actual
73 '
74
@@ -97,8 +93,7 @@ test_expect_success 'cleanup merge messages (scissors option)' '
93 # to be kept, too
94 EOF
95 git merge --cleanup=scissors -e -F text c2 &&
100 - git cat-file commit HEAD >raw &&
101 - sed -e "1,/^$/d" raw >actual &&
96 + commit_body HEAD >actual &&
97 test_cmp expect actual
98 '
99
@@ -107,8 +102,7 @@ test_expect_success 'cleanup commit messages (strip option)' '
102 test_write_lines "" "# text" "sample" "" >text &&
103 echo sample >expect &&
104 git merge --cleanup=strip -F text c2 &&
110 - git cat-file commit HEAD >raw &&
111 - sed -e "1,/^$/d" raw >actual &&
105 + commit_body HEAD >actual &&
106 test_cmp expect actual
107 '
108
t/t7614-merge-signoff.sh
+3 -6
@@ -45,8 +45,7 @@ test_expect_success 'git merge --signoff adds a sign-off line' '
45 test_commit main-branch-2 file2 2 &&
46 git checkout other-branch &&
47 git merge main --signoff --no-edit &&
48 - git cat-file commit HEAD >commit &&
49 - sed -e "1,/^\$/d" commit >actual &&
48 + commit_body HEAD >actual &&
49 test_cmp expected-signed actual
50 '
51
@@ -56,8 +55,7 @@ test_expect_success 'git merge does not add a sign-off line' '
55 test_commit main-branch-3 file3 3 &&
56 git checkout other-branch &&
57 git merge main --no-edit &&
59 - git cat-file commit HEAD >commit &&
60 - sed -e "1,/^\$/d" commit >actual &&
58 + commit_body HEAD >actual &&
59 test_cmp expected-unsigned actual
60 '
61
@@ -67,8 +65,7 @@ test_expect_success 'git merge --no-signoff flag cancels --signoff flag' '
65 test_commit main-branch-4 file4 4 &&
66 git checkout other-branch &&
67 git merge main --no-edit --signoff --no-signoff &&
70 - git cat-file commit HEAD >commit &&
71 - sed -e "1,/^\$/d" commit >actual &&
68 + commit_body HEAD >actual &&
69 test_cmp expected-unsigned actual
70 '
71