Git development
 help / color / mirror / Atom feed
* [PATCH 0/2] t: add and use a commit_body test helper
@ 2026-07-26 22:48 Shlok Kulshreshtha
  2026-07-26 22:48 ` [PATCH 1/2] test-lib-functions: add commit_body helper Shlok Kulshreshtha
  2026-07-26 22:48 ` [PATCH 2/2] t: use commit_body to extract commit message bodies Shlok Kulshreshtha
  0 siblings, 2 replies; 3+ messages in thread
From: Shlok Kulshreshtha @ 2026-07-26 22:48 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Shlok Kulshreshtha

While reviewing "t7614: avoid hiding git's exit code in a pipe"
(now in master as b6b276974e), Junio pointed out that the pattern
fixed there by hand -- "cat-file the commit object, and strip away
the object header with sed" -- recurs throughout the test suite, and
suggested factoring it into a helper (cf. <xmqq1pd4m4ea.fsf@gitster.g>):

    commit_body () {
        git cat-file commit "$1" >.commit &&
        sed -e "1,/^$/d" .commit &&
        rm -f .commit
    }

I said I would take this up as a follow-up once t7614 landed. It has,
so here it is.

Scope:

  1/2 adds the helper to t/test-lib-functions.sh, following Junio's
      sketch, with a t/README entry.

  2/2 converts the existing call sites: 60 sites across 11 files.
      The idiom appears in four equivalent spellings (piped or
      written to a file first, "sed -e" or plain "sed", "\$" or "$"
      in the address) that all produce byte-identical output and
      collapse to the same commit_body call. Two sites needed more
      than a mechanical substitution and are explained individually
      in that commit's message; a few more are left alone because
      they are not extracting a commit's message body at all (email
      headers, a hand-built object for fsck, a .patch file).

Converting the piped sites also closes the same exit-code hole t7614
fixed: the exit status of a pipeline is that of its last command, so
a crashing "git cat-file" was previously masked by "sed" succeeding
on empty input.

Verification: all 11 touched test scripts pass in full (build clean,
no new failures), and a deliberately failing "git cat-file" now fails
a converted test that previously passed, confirming the exit-code fix
is real.

Shlok Kulshreshtha (2):
  test-lib-functions: add commit_body helper
  t: use commit_body to extract commit message bodies

 t/README                                  | 11 ++++
 t/t3405-rebase-malformed.sh               |  8 +--
 t/t3408-rebase-multi-line.sh              |  4 +-
 t/t3434-rebase-i18n.sh                    |  3 +-
 t/t3900-i18n-commit.sh                    |  4 +-
 t/t4150-am.sh                             |  8 +--
 t/t7500-commit-template-squash-signoff.sh |  4 +-
 t/t7501-commit-basic-functionality.sh     | 21 +++----
 t/t7502-commit-porcelain.sh               | 77 ++++++++---------------
 t/t7600-merge.sh                          | 14 ++---
 t/t7604-merge-custom-message.sh           | 18 ++----
 t/t7614-merge-signoff.sh                  |  9 +--
 t/test-lib-functions.sh                   |  8 +++
 13 files changed, 81 insertions(+), 108 deletions(-)

-- 
2.52.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-26 22:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-26 22:48 [PATCH 0/2] t: add and use a commit_body test helper Shlok Kulshreshtha
2026-07-26 22:48 ` [PATCH 1/2] test-lib-functions: add commit_body helper Shlok Kulshreshtha
2026-07-26 22:48 ` [PATCH 2/2] t: use commit_body to extract commit message bodies Shlok Kulshreshtha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox