]> git.99rst.org Git - git.git/commit
t: use commit_body to extract commit message bodies
authorShlok Kulshreshtha <redacted>
Mon, 27 Jul 2026 09:56:56 +0000 (15:26 +0530)
committerJunio C Hamano <redacted>
Mon, 27 Jul 2026 19:58:38 +0000 (12:58 -0700)
commit9539653b71ed1ab37302574f96544013b8829eb9
treec3b12c8ae9c14b52b08a4ebb851ed9b30b18dd1e
parenta592d6feb3d47a1fcd6be5b4c8136e116c26ffbc
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 <redacted>
Signed-off-by: Junio C Hamano <redacted>
13 files changed:
t/t3404-rebase-interactive.sh
t/t3405-rebase-malformed.sh
t/t3408-rebase-multi-line.sh
t/t3434-rebase-i18n.sh
t/t3900-i18n-commit.sh
t/t4150-am.sh
t/t7500-commit-template-squash-signoff.sh
t/t7501-commit-basic-functionality.sh
t/t7502-commit-porcelain.sh
t/t7509-commit-authorship.sh
t/t7600-merge.sh
t/t7604-merge-custom-message.sh
t/t7614-merge-signoff.sh
git clone https://git.99rst.org/PROJECT