Skip to contentSkip to conversation

format-patch: learn --infer-cover-subject option

PATCH Superseded Denton Liu 5 participants 91 messages Aug 19, 2019 – Oct 15, 2019 Documentation

lore
Share & tools
lore

Denton Liu

author
#0 lore raw

v2 cover format-patch: learn --infer-cover-subject option

Thanks for the review, Eric. I've incorporated all of your suggestions and, while I was doing that, I found a couple more places for cleanup.

Currently, format-patch only puts "*** SUBJECT HERE ***" when a cover letter is generated. However, it is already smart enough to be able to populate the cover letter with the branch description so there's no reason why it cannot populate the subject as well.

Teach format-patch the --infer-cover-subject and corresponding format.inferCoverSubject configuration option which will read the subject from the branch description using the same rules as for a commit message (that is, it will expect a subject line followed by a blank line).

Also includes some other cleanup along the way.

This was based on patches 1-3 of an earlier patchset I sent[1].

Changes since v1:

* Incorporate Eric's suggestions for cleanup in all patches

* Add patch 3/4 to make it clear what is the default value for format.coverLetter (since format.inferCoverSubject was borrowed from this config but it also did not state what the default value was)

* In 1/4, rename all instances of "expected" to "expect"

[1]: https://public-inbox.org/git/[email protected]/

Denton Liu (4):
t4014: clean up style
Doc: add more detail for git-format-patch config/format.txt: make clear the default value of format.coverLetter
format-patch: learn --infer-cover-letter option

 Documentation/config/format.txt    |   7 +-
 Documentation/git-format-patch.txt |  27 +-
 builtin/log.c                      |  56 ++-
 t/t4014-format-patch.sh            | 766 ++++++++++++++++-------------
 4 files changed, 481 insertions(+), 375 deletions(-)

Range-diff against v1:
1: 058f877c34 ! 1: 76a0a274fd t4014: clean up style

    @@ Commit message
         Change here-docs from `<<\EOF` to `<<-\EOF` so that they can be indented
         along with the rest of the test case.
     
    -    Finally, refactor to remove Git commands upstream of pipe. This way, if
    -    an invocation of a Git command fails, the return code won't be lost.
    -    Keep upstream non-Git commands since we have to assume a base level of
    -    sanity.
    +    Convert all instances of `cnt=$(... | wc -l) && test $cnt = N` into
    +    uses of `test_line_count()`.
    +
    +    For style, move the ending sq of test cases onto its own line whenever
    +    they do not conform.
    +
    +    Rename output files from "expected" to "expect" to conform with the
    +    usual convention.
    +
    +    Finally, refactor to remove Git commands upstream of pipe as well as Git
    +    commands that are in a non-variable-assignment subshell (e.g. `echo
    +    "base-commit: $(git rev-parse HEAD)"`. This way, if an invocation of a
    +    Git command fails, the return code won't be lost. Keep upstream non-Git
    +    commands since we have to assume a base level of sanity.
     
         Signed-off-by: Denton Liu <[email protected]>
     
    @@ t/t4014-format-patch.sh: test_expect_success setup '
      	test_tick &&
      	git commit -m "Master accepts moral equivalent of #2" &&
      
    +@@ t/t4014-format-patch.sh: test_expect_success setup '
    + test_expect_success "format-patch --ignore-if-in-upstream" '
    + 
    + 	git format-patch --stdout master..side >patch0 &&
    +-	cnt=$(grep "^From " patch0 | wc -l) &&
    +-	test $cnt = 3
    +-
    ++	grep "^From " patch0 >from0 &&
    ++	test_line_count = 3 from0
    + '
    + 
    + test_expect_success "format-patch --ignore-if-in-upstream" '
    + 
    + 	git format-patch --stdout \
    + 		--ignore-if-in-upstream master..side >patch1 &&
    +-	cnt=$(grep "^From " patch1 | wc -l) &&
    +-	test $cnt = 2
    +-
    ++	grep "^From " patch1 >from1 &&
    ++	test_line_count = 2 from1
    + '
    + 
    + test_expect_success "format-patch --ignore-if-in-upstream handles tags" '
    + 	git tag -a v1 -m tag side &&
    + 	git tag -a v2 -m tag master &&
    + 	git format-patch --stdout --ignore-if-in-upstream v2..v1 >patch1 &&
    +-	cnt=$(grep "^From " patch1 | wc -l) &&
    +-	test $cnt = 2
    ++	grep "^From " patch1 >from1 &&
    ++	test_line_count = 2 from1
    + '
    + 
    + test_expect_success "format-patch doesn't consider merge commits" '
     @@ t/t4014-format-patch.sh: test_expect_success "format-patch doesn't consider merge commits" '
      	git checkout -b merger master &&
      	test_tick &&
      	git merge --no-ff slave &&
     -	cnt=$(git format-patch -3 --stdout | grep "^From " | wc -l) &&
    -+	cnt=$(git format-patch -3 --stdout >patch && grep "^From " patch | wc -l) &&
    - 	test $cnt = 3
    +-	test $cnt = 3
    ++	git format-patch -3 --stdout >patch &&
    ++	grep "^From " patch >from &&
    ++	test_line_count = 3 from
      '
      
    -@@ t/t4014-format-patch.sh: test_expect_success "format-patch result applies" '
    + test_expect_success "format-patch result applies" '
      
      	git checkout -b rebuild-0 master &&
      	git am -3 patch0 &&
    @@ t/t4014-format-patch.sh: test_expect_success 'reroll count (-v)' '
      	expect="$1" &&
      	shift &&
     -	(git format-patch --stdout "$@"; echo $? > status.out) |
    -+	(git format-patch --stdout "$@"; echo $? >status.out) |
    ++	git format-patch --stdout "$@" >patch &&
      	# Prints everything between the Message-ID and In-Reply-To,
      	# and replaces all Message-ID-lookalikes by a sequence number
      	perl -ne '
    @@ t/t4014-format-patch.sh: check_threading () {
      		}
      		print "---\n" if /^From /i;
     -	' > actual &&
    -+	' >actual &&
    - 	test 0 = "$(cat status.out)" &&
    +-	test 0 = "$(cat status.out)" &&
    ++	' <patch >actual &&
      	test_cmp "$expect" actual
      }
      
    @@ t/t4014-format-patch.sh: test_expect_success 'format-patch with multiple notes r
     +	test_must_fail git format-patch --name-status 2>output &&
      	test_i18ncmp expect.name-status output &&
     -	test_must_fail git format-patch --check 2> output &&
    +-	test_i18ncmp expect.check output'
     +	test_must_fail git format-patch --check 2>output &&
    - 	test_i18ncmp expect.check output'
    ++	test_i18ncmp expect.check output
    ++'
      
      test_expect_success 'format-patch --numstat should produce a patch' '
     -	git format-patch --numstat --stdout master..side > output &&
    +-	test 5 = $(grep "^diff --git a/" output | wc -l)'
     +	git format-patch --numstat --stdout master..side >output &&
    - 	test 5 = $(grep "^diff --git a/" output | wc -l)'
    ++	grep "^diff --git a/" output >diff &&
    ++	test_line_count = 5 diff
    ++'
      
      test_expect_success 'format-patch -- <path>' '
    + 	git format-patch master..side -- file 2>error &&
     @@ t/t4014-format-patch.sh: test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
      	git format-patch --ignore-if-in-upstream HEAD
      '
      
     -git_version="$(git --version | sed "s/.* //")"
    -+git_version="$(git --version >version && sed "s/.* //" version)"
    - 
    +-
      signature() {
    ++	git_version="$(git --version >version && sed "s/.* //" version)" &&
      	printf "%s\n%s\n\n" "-- " "${1:-$git_version}"
      }
      
    @@ t/t4014-format-patch.sh: test_expect_success 'format-patch --ignore-if-in-upstre
      	signature "my sig" >expect &&
      	test_cmp expect output
      '
    +@@ t/t4014-format-patch.sh: test_expect_success 'format-patch --signature --cover-letter' '
    + 	git config --unset-all format.signature &&
    + 	git format-patch --stdout --signature="my sig" --cover-letter \
    + 		-1 >output &&
    +-	grep "my sig" output &&
    +-	test 2 = $(grep "my sig" output | wc -l)
    ++	grep "my sig" output >sig &&
    ++	test_line_count = 2 sig
    + '
    + 
    + test_expect_success 'format.signature="" suppresses signatures' '
     @@ t/t4014-format-patch.sh: append_signoff()
      
      test_expect_success 'signoff: commit with no body' '
    @@ t/t4014-format-patch.sh: append_signoff()
     -8:
     -9:Signed-off-by: C O Mitter <[email protected]>
     -EOF
    -+	cat <<-\EOF | sed "s/EOL$//" >expected &&
    +-	test_cmp expected actual
    ++	cat <<-\EOF | sed "s/EOL$//" >expect &&
     +	4:Subject: [PATCH] EOL
     +	8:
     +	9:Signed-off-by: C O Mitter <[email protected]>
     +	EOF
    - 	test_cmp expected actual
    ++	test_cmp expect actual
      '
      
      test_expect_success 'signoff: commit with only subject' '
    @@ t/t4014-format-patch.sh: append_signoff()
     -8:
     -9:Signed-off-by: C O Mitter <[email protected]>
     -EOF
    -+	cat >expected <<-\EOF &&
    +-	test_cmp expected actual
    ++	cat >expect <<-\EOF &&
     +	4:Subject: [PATCH] subject
     +	8:
     +	9:Signed-off-by: C O Mitter <[email protected]>
     +	EOF
    - 	test_cmp expected actual
    ++	test_cmp expect actual
      '
      
      test_expect_success 'signoff: commit with only subject that does not end with NL' '
    @@ t/t4014-format-patch.sh: append_signoff()
     -8:
     -9:Signed-off-by: C O Mitter <[email protected]>
     -EOF
    -+	cat >expected <<-\EOF &&
    +-	test_cmp expected actual
    ++	cat >expect <<-\EOF &&
     +	4:Subject: [PATCH] subject
     +	8:
     +	9:Signed-off-by: C O Mitter <[email protected]>
     +	EOF
    - 	test_cmp expected actual
    ++	test_cmp expect actual
      '
      
      test_expect_success 'signoff: no existing signoffs' '
    @@ t/t4014-format-patch.sh: append_signoff()
     -10:
     -11:Signed-off-by: C O Mitter <[email protected]>
     -EOF
    +-	test_cmp expected actual
     +	body
     +	EOF
    -+	cat >expected <<-\EOF &&
    ++	cat >expect <<-\EOF &&
     +	4:Subject: [PATCH] subject
     +	8:
     +	10:
     +	11:Signed-off-by: C O Mitter <[email protected]>
     +	EOF
    - 	test_cmp expected actual
    ++	test_cmp expect actual
      '
      
      test_expect_success 'signoff: no existing signoffs and no trailing NL' '
    @@ t/t4014-format-patch.sh: append_signoff()
     -10:
     -11:Signed-off-by: C O Mitter <[email protected]>
     -EOF
    -+	cat >expected <<-\EOF &&
    +-	test_cmp expected actual
    ++	cat >expect <<-\EOF &&
     +	4:Subject: [PATCH] subject
     +	8:
     +	10:
     +	11:Signed-off-by: C O Mitter <[email protected]>
     +	EOF
    - 	test_cmp expected actual
    ++	test_cmp expect actual
      '
      
      test_expect_success 'signoff: some random signoff' '
    @@ t/t4014-format-patch.sh: append_signoff()
     -11:Signed-off-by: my@house
     -12:Signed-off-by: C O Mitter <[email protected]>
     -EOF
    +-	test_cmp expected actual
     +	Signed-off-by: my@house
     +	EOF
    -+	cat >expected <<-\EOF &&
    ++	cat >expect <<-\EOF &&
     +	4:Subject: [PATCH] subject
     +	8:
     +	10:
     +	11:Signed-off-by: my@house
     +	12:Signed-off-by: C O Mitter <[email protected]>
     +	EOF
    - 	test_cmp expected actual
    ++	test_cmp expect actual
      '
      
      test_expect_success 'signoff: misc conforming footer elements' '
    @@ t/t4014-format-patch.sh: append_signoff()
     -11:Signed-off-by: my@house
     -15:Signed-off-by: C O Mitter <[email protected]>
     -EOF
    +-	test_cmp expected actual
     +	Signed-off-by: my@house
     +	(cherry picked from commit da39a3ee5e6b4b0d3255bfef95601890afd80709)
     +	Tested-by: Some One <[email protected]>
     +	Bug: 1234
     +	EOF
    -+	cat >expected <<-\EOF &&
    ++	cat >expect <<-\EOF &&
     +	4:Subject: [PATCH] subject
     +	8:
     +	10:
     +	11:Signed-off-by: my@house
     +	15:Signed-off-by: C O Mitter <[email protected]>
     +	EOF
    - 	test_cmp expected actual
    ++	test_cmp expect actual
      '
      
      test_expect_success 'signoff: some random signoff-alike' '
    @@ t/t4014-format-patch.sh: append_signoff()
     -11:
     -12:Signed-off-by: C O Mitter <[email protected]>
     -EOF
    +-	test_cmp expected actual
     +	body
     +	Fooled-by-me: my@house
     +	EOF
    -+	cat >expected <<-\EOF &&
    ++	cat >expect <<-\EOF &&
     +	4:Subject: [PATCH] subject
     +	8:
     +	11:
     +	12:Signed-off-by: C O Mitter <[email protected]>
     +	EOF
    - 	test_cmp expected actual
    ++	test_cmp expect actual
      '
      
      test_expect_success 'signoff: not really a signoff' '
    @@ t/t4014-format-patch.sh: append_signoff()
     -10:
     -11:Signed-off-by: C O Mitter <[email protected]>
     -EOF
    +-	test_cmp expected actual
     +	I want to mention about Signed-off-by: here.
     +	EOF
    -+	cat >expected <<-\EOF &&
    ++	cat >expect <<-\EOF &&
     +	4:Subject: [PATCH] subject
     +	8:
     +	9:I want to mention about Signed-off-by: here.
     +	10:
     +	11:Signed-off-by: C O Mitter <[email protected]>
     +	EOF
    - 	test_cmp expected actual
    ++	test_cmp expect actual
      '
      
      test_expect_success 'signoff: not really a signoff (2)' '
    @@ t/t4014-format-patch.sh: append_signoff()
     -10:Signed-off-by: example happens to be wrapped here.
     -11:Signed-off-by: C O Mitter <[email protected]>
     -EOF
    +-	test_cmp expected actual
     +	My unfortunate
     +	Signed-off-by: example happens to be wrapped here.
     +	EOF
    -+	cat >expected <<-\EOF &&
    ++	cat >expect <<-\EOF &&
     +	4:Subject: [PATCH] subject
     +	8:
     +	10:Signed-off-by: example happens to be wrapped here.
     +	11:Signed-off-by: C O Mitter <[email protected]>
     +	EOF
    - 	test_cmp expected actual
    ++	test_cmp expect actual
      '
      
      test_expect_success 'signoff: valid S-o-b paragraph in the middle' '
    @@ t/t4014-format-patch.sh: append_signoff()
     -13:
     -14:Signed-off-by: C O Mitter <[email protected]>
     -EOF
    +-	test_cmp expected actual
     +	A lot of houses.
     +	EOF
    -+	cat >expected <<-\EOF &&
    ++	cat >expect <<-\EOF &&
     +	4:Subject: [PATCH] subject
     +	8:
     +	9:Signed-off-by: my@house
    @@ t/t4014-format-patch.sh: append_signoff()
     +	13:
     +	14:Signed-off-by: C O Mitter <[email protected]>
     +	EOF
    - 	test_cmp expected actual
    ++	test_cmp expect actual
      '
      
      test_expect_success 'signoff: the same signoff at the end' '
    @@ t/t4014-format-patch.sh: append_signoff()
     -10:
     -11:Signed-off-by: C O Mitter <[email protected]>
     -EOF
    +-	test_cmp expected actual
     +	Signed-off-by: C O Mitter <[email protected]>
     +	EOF
    -+	cat >expected <<-\EOF &&
    ++	cat >expect <<-\EOF &&
     +	4:Subject: [PATCH] subject
     +	8:
     +	10:
     +	11:Signed-off-by: C O Mitter <[email protected]>
     +	EOF
    - 	test_cmp expected actual
    ++	test_cmp expect actual
      '
      
      test_expect_success 'signoff: the same signoff at the end, no trailing NL' '
    @@ t/t4014-format-patch.sh: append_signoff()
     -8:
     -9:Signed-off-by: C O Mitter <[email protected]>
     -EOF
    -+	cat >expected <<-\EOF &&
    +-	test_cmp expected actual
    ++	cat >expect <<-\EOF &&
     +	4:Subject: [PATCH] subject
     +	8:
     +	9:Signed-off-by: C O Mitter <[email protected]>
     +	EOF
    - 	test_cmp expected actual
    ++	test_cmp expect actual
      '
      
      test_expect_success 'signoff: the same signoff NOT at the end' '
    @@ t/t4014-format-patch.sh: append_signoff()
     -11:Signed-off-by: C O Mitter <[email protected]>
     -12:Signed-off-by: my@house
     -EOF
    +-	test_cmp expected actual
     +	Signed-off-by: C O Mitter <[email protected]>
     +	Signed-off-by: my@house
     +	EOF
    -+	cat >expected <<-\EOF &&
    ++	cat >expect <<-\EOF &&
     +	4:Subject: [PATCH] subject
     +	8:
     +	10:
     +	11:Signed-off-by: C O Mitter <[email protected]>
     +	12:Signed-off-by: my@house
     +	EOF
    - 	test_cmp expected actual
    ++	test_cmp expect actual
      '
      
      test_expect_success 'signoff: tolerate garbage in conforming footer' '
    @@ t/t4014-format-patch.sh: append_signoff()
     -10:
     -13:Signed-off-by: C O Mitter <[email protected]>
     -EOF
    +-	test_cmp expected actual
     +	Tested-by: my@house
     +	Some Trash
     +	Signed-off-by: C O Mitter <[email protected]>
     +	EOF
    -+	cat >expected <<-\EOF &&
    ++	cat >expect <<-\EOF &&
     +	4:Subject: [PATCH] subject
     +	8:
     +	10:
     +	13:Signed-off-by: C O Mitter <[email protected]>
     +	EOF
    - 	test_cmp expected actual
    ++	test_cmp expect actual
      '
      
      test_expect_success 'signoff: respect trailer config' '
    @@ t/t4014-format-patch.sh: append_signoff()
     -11:
     -12:Signed-off-by: C O Mitter <[email protected]>
     -EOF
    +-	test_cmp expected actual &&
     +	Myfooter: x
     +	Some Trash
     +	EOF
    -+	cat >expected <<-\EOF &&
    ++	cat >expect <<-\EOF &&
     +	4:Subject: [PATCH] subject
     +	8:
     +	11:
     +	12:Signed-off-by: C O Mitter <[email protected]>
     +	EOF
    - 	test_cmp expected actual &&
    ++	test_cmp expect actual &&
      
      	test_config trailer.Myfooter.ifexists add &&
     -	append_signoff <<\EOF >actual &&
    @@ t/t4014-format-patch.sh: append_signoff()
     -8:
     -11:Signed-off-by: C O Mitter <[email protected]>
     -EOF
    +-	test_cmp expected actual
     +	Myfooter: x
     +	Some Trash
     +	EOF
    -+	cat >expected <<-\EOF &&
    ++	cat >expect <<-\EOF &&
     +	4:Subject: [PATCH] subject
     +	8:
     +	11:Signed-off-by: C O Mitter <[email protected]>
     +	EOF
    - 	test_cmp expected actual
    ++	test_cmp expect actual
      '
      
      test_expect_success 'signoff: footer begins with non-signoff without @ sign' '
    @@ t/t4014-format-patch.sh: append_signoff()
     -10:
     -14:Signed-off-by: C O Mitter <[email protected]>
     -EOF
    +-	test_cmp expected actual
     +	Reviewed-id: Noone
     +	Tested-by: my@house
     +	Change-id: Ideadbeef
     +	Signed-off-by: C O Mitter <[email protected]>
     +	Bug: 1234
     +	EOF
    -+	cat >expected <<-\EOF &&
    ++	cat >expect <<-\EOF &&
     +	4:Subject: [PATCH] subject
     +	8:
     +	10:
     +	14:Signed-off-by: C O Mitter <[email protected]>
     +	EOF
    - 	test_cmp expected actual
    ++	test_cmp expect actual
      '
      
    + test_expect_success 'format patch ignores color.ui' '
     @@ t/t4014-format-patch.sh: test_expect_success 'cover letter using branch description (1)' '
      	git checkout rebuild-1 &&
      	test_config branch.rebuild-1.description hello &&
    @@ t/t4014-format-patch.sh: test_expect_success 'format-patch -o overrides format.o
      	git checkout patchid &&
     -	git format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual1 &&
     -	git format-patch --stdout --base=HEAD~3 HEAD~.. | tail -n 7 >actual2 &&
    +-	echo >expected &&
    +-	echo "base-commit: $(git rev-parse HEAD~3)" >>expected &&
    +-	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expected &&
    +-	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expected &&
    +-	signature >> expected &&
    +-	test_cmp expected actual1 &&
    +-	test_cmp expected actual2 &&
    ++
     +	git format-patch --stdout --base=HEAD~3 -1 >patch &&
     +	tail -n 7 patch >actual1 &&
    ++
     +	git format-patch --stdout --base=HEAD~3 HEAD~.. >patch &&
     +	tail -n 7 patch >actual2 &&
    - 	echo >expected &&
    - 	echo "base-commit: $(git rev-parse HEAD~3)" >>expected &&
    --	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expected &&
    --	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expected &&
    --	signature >> expected &&
    ++
    ++	echo >expect &&
    ++	git rev-parse HEAD~3 >commit-id-base &&
    ++	echo "base-commit: $(cat commit-id-base)" >>expect &&
    ++
     +	git show --patch HEAD~2 >patch &&
     +	git patch-id --stable <patch >patch.id.raw &&
    -+	awk "{print \$1}" <patch.id.raw >patch.id &&
    -+	echo "prerequisite-patch-id: $(cat patch.id)" >>expected &&
    ++	awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >>expect &&
    ++
     +	git show --patch HEAD~1 >patch &&
     +	git patch-id --stable <patch >patch.id.raw &&
    -+	awk "{print \$1}" <patch.id.raw >patch.id &&
    -+	echo "prerequisite-patch-id: $(cat patch.id)" >>expected &&
    -+	signature >>expected &&
    - 	test_cmp expected actual1 &&
    - 	test_cmp expected actual2 &&
    ++	awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >>expect &&
    ++
    ++	signature >>expect &&
    ++	test_cmp expect actual1 &&
    ++	test_cmp expect actual2 &&
    ++
      	echo >fail &&
    - 	echo "base-commit: $(git rev-parse HEAD~3)" >>fail &&
    +-	echo "base-commit: $(git rev-parse HEAD~3)" >>fail &&
     -	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --unstable | awk "{print \$1}")" >>fail &&
     -	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --unstable | awk "{print \$1}")" >>fail &&
    -+	echo "prerequisite-patch-id: $(
    -+		git show --patch HEAD~2 >patch &&
    -+		git patch-id --unstable <patch >patch.id.raw &&
    -+		awk "{print \$1}" <patch.id.raw)" >>fail &&
    -+	echo "prerequisite-patch-id: $(git show --patch HEAD~1 >patch &&
    -+		git patch-id --unstable <patch >patch.id.raw &&
    -+		awk "{print \$1}" <pattch.id.raw)" >>fail &&
    - 	signature >> fail &&
    +-	signature >> fail &&
    ++	echo "base-commit: $(cat commit-id-base)" >>fail &&
    ++
    ++	git show --patch HEAD~2 >patch &&
    ++	git patch-id --unstable <patch >patch.id.raw &&
    ++	awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >>fail &&
    ++
    ++	git show --patch HEAD~1 >patch &&
    ++	git patch-id --unstable <patch >patch.id.raw &&
    ++	awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >>fail &&
    ++
    ++	signature >>fail &&
      	! test_cmp fail actual1 &&
      	! test_cmp fail actual2
    + '
    +@@ t/t4014-format-patch.sh: test_expect_success 'format-patch --base errors out when base commit is in revis
    + 	test_must_fail git format-patch --base=HEAD~1 -2 &&
    + 	git format-patch --stdout --base=HEAD~2 -2 >patch &&
    + 	grep "^base-commit:" patch >actual &&
    +-	echo "base-commit: $(git rev-parse HEAD~2)" >expected &&
    +-	test_cmp expected actual
    ++	git rev-parse HEAD~2 >commit-id-base &&
    ++	echo "base-commit: $(cat commit-id-base)" >expect &&
    ++	test_cmp expect actual
    + '
    + 
    + test_expect_success 'format-patch --base errors out when base commit is not ancestor of revision list' '
    +@@ t/t4014-format-patch.sh: test_expect_success 'format-patch --base errors out when base commit is not ance
    + 	test_must_fail git format-patch --base=$(cat commit-id-Z) -3 &&
    + 	git format-patch --stdout --base=$(cat commit-id-base) -3 >patch &&
    + 	grep "^base-commit:" patch >actual &&
    +-	echo "base-commit: $(cat commit-id-base)" >expected &&
    +-	test_cmp expected actual
    ++	echo "base-commit: $(cat commit-id-base)" >expect &&
    ++	test_cmp expect actual
    + '
    + 
    + test_expect_success 'format-patch --base=auto' '
    +@@ t/t4014-format-patch.sh: test_expect_success 'format-patch --base=auto' '
    + 	test_commit N2 &&
    + 	git format-patch --stdout --base=auto -2 >patch &&
    + 	grep "^base-commit:" patch >actual &&
    +-	echo "base-commit: $(git rev-parse upstream)" >expected &&
    +-	test_cmp expected actual
    ++	git rev-parse upstream >commit-id-base &&
    ++	echo "base-commit: $(cat commit-id-base)" >expect &&
    ++	test_cmp expect actual
    + '
    + 
    + test_expect_success 'format-patch errors out when history involves criss-cross' '
    +@@ t/t4014-format-patch.sh: test_expect_success 'format-patch format.useAutoBaseoption' '
    + 	git config format.useAutoBase true &&
    + 	git format-patch --stdout -1 >patch &&
    + 	grep "^base-commit:" patch >actual &&
    +-	echo "base-commit: $(git rev-parse upstream)" >expected &&
    +-	test_cmp expected actual
    ++	git rev-parse upstream >commit-id-base &&
    ++	echo "base-commit: $(cat commit-id-base)" >expect &&
    ++	test_cmp expect actual
    + '
    + 
    + test_expect_success 'format-patch --base overrides format.useAutoBase' '
    +@@ t/t4014-format-patch.sh: test_expect_success 'format-patch --base overrides format.useAutoBase' '
    + 	git config format.useAutoBase true &&
    + 	git format-patch --stdout --base=HEAD~1 -1 >patch &&
    + 	grep "^base-commit:" patch >actual &&
    +-	echo "base-commit: $(git rev-parse HEAD~1)" >expected &&
    +-	test_cmp expected actual
    ++	git rev-parse HEAD~1 >commit-id-base &&
    ++	echo "base-commit: $(cat commit-id-base)" >expect &&
    ++	test_cmp expect actual
    + '
    + 
    + test_expect_success 'format-patch --base with --attach' '

2: 7619da962d ! 2: fd908bcc01 Doc: add more detail for git-format-patch
@@ Commit message
Next, while we're at it, surround option arguments with <>.

Finally, document the format.outputDirectory config and change
- format.coverletter to use camelcase.
+ format.coverletter to use camel case.

@@ Documentation/git-format-patch.txt: Beware that the default for 'git send-email'
Make the first mail (or all the mails with --no-thread) appear as a
reply to the given Message-Id, which avoids breaking threads to
provide a new patch series.
-@@ Documentation/git-format-patch.txt: will want to ensure that threading is disabled for git send-email. -
- --to=<email>::
- Add a To: header to the email headers. This is in addition
-- to any configured headers, and may be used multiple times.
-+ to any configured headers, and may be used multiple times. The
-+ emails given will be used along with any emails given by
-+ format.to configurations.
- The negated form --no-to discards all To: headers added so
- far (from config or command line).
-
- --cc=<email>::
- Add a Cc: header to the email headers. This is in addition
-- to any configured headers, and may be used multiple times.
-+ to any configured headers, and may be used multiple times. The
-+ emails given will be used along with any emails given by
-+ format.cc configurations.
- The negated form --no-cc discards all Cc: headers added so
- far (from config or command line).
-
@@ Documentation/git-format-patch.txt: you can use --suffix=-patch to get 0001-description-of-my-change-patch.
--base=<commit>::
Record the base tree information to identify the state the
patch series applies to. See the BASE TREE INFORMATION section
- below for details.
-+ below for details. If <commit> is equal to "auto", a base commit
-+ is automatically chosen.
++ below for details. If <commit> is "auto", a base commit is
++ automatically chosen.

--root::
Treat the revision argument as a <revision range>, even if it

-:  ---------- > 3:  94a778c9aa config/format.txt: make clear the default value of format.coverLetter
3:  5cc5e354b6 ! 4:  e682bd347a format-patch: infer cover letter from branch description

@@ Metadata
Author: Denton Liu <[email protected]>

## Commit message ##
- format-patch: infer cover letter from branch description
+ format-patch: learn --infer-cover-letter option

We used to populate the subject of the cover letter generated by git-format-patch with "*** SUBJECT HERE ***". However, if a user submits
@@ Documentation/config/format.txt: format.subjectPrefix::
subject prefix. Use this variable to change that prefix.

+format.inferCoverSubject::
-+ A boolean that controls whether or not to infer the subject for
-+ the cover letter based on the branch's description. See the
-+ --infer-cover-subject option in linkgit:git-format-patch[1].
++ A boolean value which lets you enable the
++ --infer-cover-subject option of format-patch by default.
+
format.signature::
The default for format-patch is to output a signature containing

Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#1 lore raw

PATCH v2 1/4 t4014: clean up style

In Git's tests, there is typically no space between the redirection operator and the filename. Remove these spaces.

Since output is silenced when running without -v and debugging output is useful with -v, remove redirections to /dev/null.

Change here-docs from <<\EOF to <<-\EOF so that they can be indented along with the rest of the test case.

Convert all instances of cnt=$(... | wc -l) && test $cnt = N into uses of test_line_count().

For style, move the ending sq of test cases onto its own line whenever they do not conform.

Rename output files from "expected" to "expect" to conform with the usual convention.

Finally, refactor to remove Git commands upstream of pipe as well as Git commands that are in a non-variable-assignment subshell (e.g. echo "base-commit: $(git rev-parse HEAD)". This way, if an invocation of a Git command fails, the return code won't be lost. Keep upstream non-Git commands since we have to assume a base level of sanity.

---

This patch is getting a little unwieldy. Perhaps we could split it into several smaller patches? Unfortunately, I'm not really sure where a logical place to split it would be.

 t/t4014-format-patch.sh | 733 +++++++++++++++++++++-------------------
 1 file changed, 387 insertions(+), 346 deletions(-)
t/t4014-format-patch.sh +387 -346
index ca7debf1d4..0114608b1f 100755
@@ -34,7 +34,8 @@ test_expect_success setup '
 	git commit -m "Side changes #3 with \\n backslash-n in it." &&
 
 	git checkout master &&
-	git diff-tree -p C2 | git apply --index &&
+	git diff-tree -p C2 >patch &&
+	git apply --index <patch &&
 	test_tick &&
 	git commit -m "Master accepts moral equivalent of #2" &&
 
@@ -62,26 +63,24 @@ test_expect_success setup '
 test_expect_success "format-patch --ignore-if-in-upstream" '
 
 	git format-patch --stdout master..side >patch0 &&
-	cnt=$(grep "^From " patch0 | wc -l) &&
-	test $cnt = 3
-
+	grep "^From " patch0 >from0 &&
+	test_line_count = 3 from0
 '
 
 test_expect_success "format-patch --ignore-if-in-upstream" '
 
 	git format-patch --stdout \
 		--ignore-if-in-upstream master..side >patch1 &&
-	cnt=$(grep "^From " patch1 | wc -l) &&
-	test $cnt = 2
-
+	grep "^From " patch1 >from1 &&
+	test_line_count = 2 from1
 '
 
 test_expect_success "format-patch --ignore-if-in-upstream handles tags" '
 	git tag -a v1 -m tag side &&
 	git tag -a v2 -m tag master &&
 	git format-patch --stdout --ignore-if-in-upstream v2..v1 >patch1 &&
-	cnt=$(grep "^From " patch1 | wc -l) &&
-	test $cnt = 2
+	grep "^From " patch1 >from1 &&
+	test_line_count = 2 from1
 '
 
 test_expect_success "format-patch doesn't consider merge commits" '
@@ -96,29 +95,31 @@ test_expect_success "format-patch doesn't consider merge commits" '
 	git checkout -b merger master &&
 	test_tick &&
 	git merge --no-ff slave &&
-	cnt=$(git format-patch -3 --stdout | grep "^From " | wc -l) &&
-	test $cnt = 3
+	git format-patch -3 --stdout >patch &&
+	grep "^From " patch >from &&
+	test_line_count = 3 from
 '
 
 test_expect_success "format-patch result applies" '
 
 	git checkout -b rebuild-0 master &&
 	git am -3 patch0 &&
-	cnt=$(git rev-list master.. | wc -l) &&
-	test $cnt = 2
+	git rev-list master.. >list &&
+	test_line_count = 2 list
 '
 
 test_expect_success "format-patch --ignore-if-in-upstream result applies" '
 
 	git checkout -b rebuild-1 master &&
 	git am -3 patch1 &&
-	cnt=$(git rev-list master.. | wc -l) &&
-	test $cnt = 2
+	git rev-list master.. >list &&
+	test_line_count = 2 list
 '
 
 test_expect_success 'commit did not screw up the log message' '
 
-	git cat-file commit side | grep "^Side .* with .* backslash-n"
+	git cat-file commit side >actual &&
+	grep "^Side .* with .* backslash-n" actual
 
 '
 
@@ -131,7 +132,8 @@ test_expect_success 'format-patch did not screw up the log message' '
 
 test_expect_success 'replay did not screw up the log message' '
 
-	git cat-file commit rebuild-1 | grep "^Side .* with .* backslash-n"
+	git cat-file commit rebuild-1 >actual &&
+	grep "^Side .* with .* backslash-n" actual
 
 '
 
@@ -141,8 +143,8 @@ test_expect_success 'extra headers' '
 " &&
 	git config --add format.headers "Cc: S E Cipient <[email protected]>
 " &&
-	git format-patch --stdout master..side > patch2 &&
-	sed -e "/^\$/q" patch2 > hdrs2 &&
+	git format-patch --stdout master..side >patch2 &&
+	sed -e "/^\$/q" patch2 >hdrs2 &&
 	grep "^To: R E Cipient <[email protected]>\$" hdrs2 &&
 	grep "^Cc: S E Cipient <[email protected]>\$" hdrs2
 
@@ -153,7 +155,7 @@ test_expect_success 'extra headers without newlines' '
 	git config --replace-all format.headers "To: R E Cipient <[email protected]>" &&
 	git config --add format.headers "Cc: S E Cipient <[email protected]>" &&
 	git format-patch --stdout master..side >patch3 &&
-	sed -e "/^\$/q" patch3 > hdrs3 &&
+	sed -e "/^\$/q" patch3 >hdrs3 &&
 	grep "^To: R E Cipient <[email protected]>\$" hdrs3 &&
 	grep "^Cc: S E Cipient <[email protected]>\$" hdrs3
 
@@ -163,8 +165,8 @@ test_expect_success 'extra headers with multiple To:s' '
 
 	git config --replace-all format.headers "To: R E Cipient <[email protected]>" &&
 	git config --add format.headers "To: S E Cipient <[email protected]>" &&
-	git format-patch --stdout master..side > patch4 &&
-	sed -e "/^\$/q" patch4 > hdrs4 &&
+	git format-patch --stdout master..side >patch4 &&
+	sed -e "/^\$/q" patch4 >hdrs4 &&
 	grep "^To: R E Cipient <[email protected]>,\$" hdrs4 &&
 	grep "^ *S E Cipient <[email protected]>\$" hdrs4
 '
@@ -172,72 +174,82 @@ test_expect_success 'extra headers with multiple To:s' '
 test_expect_success 'additional command line cc (ascii)' '
 
 	git config --replace-all format.headers "Cc: R E Cipient <[email protected]>" &&
-	git format-patch --cc="S E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch5 &&
-	grep "^Cc: R E Cipient <[email protected]>,\$" patch5 &&
-	grep "^ *S E Cipient <[email protected]>\$" patch5
+	git format-patch --cc="S E Cipient <[email protected]>" --stdout master..side >patch5 &&
+	sed -e "/^\$/q" patch5 >hdrs5 &&
+	grep "^Cc: R E Cipient <[email protected]>,\$" hdrs5 &&
+	grep "^ *S E Cipient <[email protected]>\$" hdrs5
 '
 
 test_expect_failure 'additional command line cc (rfc822)' '
 
 	git config --replace-all format.headers "Cc: R E Cipient <[email protected]>" &&
-	git format-patch --cc="S. E. Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch5 &&
-	grep "^Cc: R E Cipient <[email protected]>,\$" patch5 &&
-	grep "^ *\"S. E. Cipient\" <[email protected]>\$" patch5
+	git format-patch --cc="S. E. Cipient <[email protected]>" --stdout master..side >patch5 &&
+	sed -e "/^\$/q" patch5 >hdrs5 &&
+	grep "^Cc: R E Cipient <[email protected]>,\$" hdrs5 &&
+	grep "^ *\"S. E. Cipient\" <[email protected]>\$" hdrs5
 '
 
 test_expect_success 'command line headers' '
 
 	git config --unset-all format.headers &&
-	git format-patch --add-header="Cc: R E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch6 &&
-	grep "^Cc: R E Cipient <[email protected]>\$" patch6
+	git format-patch --add-header="Cc: R E Cipient <[email protected]>" --stdout master..side >patch6 &&
+	sed -e "/^\$/q" patch6 >hdrs6 &&
+	grep "^Cc: R E Cipient <[email protected]>\$" hdrs6
 '
 
 test_expect_success 'configuration headers and command line headers' '
 
 	git config --replace-all format.headers "Cc: R E Cipient <[email protected]>" &&
-	git format-patch --add-header="Cc: S E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch7 &&
-	grep "^Cc: R E Cipient <[email protected]>,\$" patch7 &&
-	grep "^ *S E Cipient <[email protected]>\$" patch7
+	git format-patch --add-header="Cc: S E Cipient <[email protected]>" --stdout master..side >patch7 &&
+	sed -e "/^\$/q" patch7 >hdrs7 &&
+	grep "^Cc: R E Cipient <[email protected]>,\$" hdrs7 &&
+	grep "^ *S E Cipient <[email protected]>\$" hdrs7
 '
 
 test_expect_success 'command line To: header (ascii)' '
 
 	git config --unset-all format.headers &&
-	git format-patch --to="R E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
-	grep "^To: R E Cipient <[email protected]>\$" patch8
+	git format-patch --to="R E Cipient <[email protected]>" --stdout master..side >patch8 &&
+	sed -e "/^\$/q" patch8 >hdrs8 &&
+	grep "^To: R E Cipient <[email protected]>\$" hdrs8
 '
 
 test_expect_failure 'command line To: header (rfc822)' '
 
-	git format-patch --to="R. E. Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
-	grep "^To: \"R. E. Cipient\" <[email protected]>\$" patch8
+	git format-patch --to="R. E. Cipient <[email protected]>" --stdout master..side >patch8 &&
+	sed -e "/^\$/q" patch8 >hdrs8 &&
+	grep "^To: \"R. E. Cipient\" <[email protected]>\$" hdrs8
 '
 
 test_expect_failure 'command line To: header (rfc2047)' '
 
-	git format-patch --to="R Ä Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
-	grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected]>\$" patch8
+	git format-patch --to="R Ä Cipient <[email protected]>" --stdout master..side >patch8 &&
+	sed -e "/^\$/q" patch8 >hdrs8 &&
+	grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected]>\$" hdrs8
 '
 
 test_expect_success 'configuration To: header (ascii)' '
 
 	git config format.to "R E Cipient <[email protected]>" &&
-	git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
-	grep "^To: R E Cipient <[email protected]>\$" patch9
+	git format-patch --stdout master..side >patch9 &&
+	sed -e "/^\$/q" patch9 >hdrs9 &&
+	grep "^To: R E Cipient <[email protected]>\$" hdrs9
 '
 
 test_expect_failure 'configuration To: header (rfc822)' '
 
 	git config format.to "R. E. Cipient <[email protected]>" &&
-	git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
-	grep "^To: \"R. E. Cipient\" <[email protected]>\$" patch9
+	git format-patch --stdout master..side >patch9 &&
+	sed -e "/^\$/q" patch9 >hdrs9 &&
+	grep "^To: \"R. E. Cipient\" <[email protected]>\$" hdrs9
 '
 
 test_expect_failure 'configuration To: header (rfc2047)' '
 
 	git config format.to "R Ä Cipient <[email protected]>" &&
-	git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
-	grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected]>\$" patch9
+	git format-patch --stdout master..side >patch9 &&
+	sed -e "/^\$/q" patch9 >hdrs9 &&
+	grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected]>\$" hdrs9
 '
 
 # check_patch <patch>: Verify that <patch> looks like a half-sane
@@ -250,52 +262,52 @@ check_patch () {
 
 test_expect_success 'format.from=false' '
 
-	git -c format.from=false format-patch --stdout master..side |
-	sed -e "/^\$/q" >patch &&
+	git -c format.from=false format-patch --stdout master..side >patch &&
+	sed -e "/^\$/q" patch >hdrs &&
 	check_patch patch &&
-	! grep "^From: C O Mitter <[email protected]>\$" patch
+	! grep "^From: C O Mitter <[email protected]>\$" hdrs
 '
 
 test_expect_success 'format.from=true' '
 
-	git -c format.from=true format-patch --stdout master..side |
-	sed -e "/^\$/q" >patch &&
-	check_patch patch &&
-	grep "^From: C O Mitter <[email protected]>\$" patch
+	git -c format.from=true format-patch --stdout master..side >patch &&
+	sed -e "/^\$/q" patch >hdrs &&
+	check_patch hdrs &&
+	grep "^From: C O Mitter <[email protected]>\$" hdrs
 '
 
 test_expect_success 'format.from with address' '
 
-	git -c format.from="F R Om <[email protected]>" format-patch --stdout master..side |
-	sed -e "/^\$/q" >patch &&
-	check_patch patch &&
-	grep "^From: F R Om <[email protected]>\$" patch
+	git -c format.from="F R Om <[email protected]>" format-patch --stdout master..side >patch &&
+	sed -e "/^\$/q" patch >hdrs &&
+	check_patch hdrs &&
+	grep "^From: F R Om <[email protected]>\$" hdrs
 '
 
 test_expect_success '--no-from overrides format.from' '
 
-	git -c format.from="F R Om <[email protected]>" format-patch --no-from --stdout master..side |
-	sed -e "/^\$/q" >patch &&
-	check_patch patch &&
-	! grep "^From: F R Om <[email protected]>\$" patch
+	git -c format.from="F R Om <[email protected]>" format-patch --no-from --stdout master..side >patch &&
+	sed -e "/^\$/q" patch >hdrs &&
+	check_patch hdrs &&
+	! grep "^From: F R Om <[email protected]>\$" hdrs
 '
 
 test_expect_success '--from overrides format.from' '
 
-	git -c format.from="F R Om <[email protected]>" format-patch --from --stdout master..side |
-	sed -e "/^\$/q" >patch &&
-	check_patch patch &&
-	! grep "^From: F R Om <[email protected]>\$" patch
+	git -c format.from="F R Om <[email protected]>" format-patch --from --stdout master..side >patch &&
+	sed -e "/^\$/q" patch >hdrs &&
+	check_patch hdrs &&
+	! grep "^From: F R Om <[email protected]>\$" hdrs
 '
 
 test_expect_success '--no-to overrides config.to' '
 
 	git config --replace-all format.to \
 		"R E Cipient <[email protected]>" &&
-	git format-patch --no-to --stdout master..side |
-	sed -e "/^\$/q" >patch10 &&
-	check_patch patch10 &&
-	! grep "^To: R E Cipient <[email protected]>\$" patch10
+	git format-patch --no-to --stdout master..side >patch10 &&
+	sed -e "/^\$/q" patch10 >hdrs10 &&
+	check_patch hdrs10 &&
+	! grep "^To: R E Cipient <[email protected]>\$" hdrs10
 '
 
 test_expect_success '--no-to and --to replaces config.to' '
@@ -303,31 +315,31 @@ test_expect_success '--no-to and --to replaces config.to' '
 	git config --replace-all format.to \
 		"Someone <[email protected]>" &&
 	git format-patch --no-to --to="Someone Else <[email protected]>" \
-		--stdout master..side |
-	sed -e "/^\$/q" >patch11 &&
-	check_patch patch11 &&
-	! grep "^To: Someone <[email protected]>\$" patch11 &&
-	grep "^To: Someone Else <[email protected]>\$" patch11
+		--stdout master..side >patch11 &&
+	sed -e "/^\$/q" patch11 >hdrs11 &&
+	check_patch hdrs11 &&
+	! grep "^To: Someone <[email protected]>\$" hdrs11 &&
+	grep "^To: Someone Else <[email protected]>\$" hdrs11
 '
 
 test_expect_success '--no-cc overrides config.cc' '
 
 	git config --replace-all format.cc \
 		"C E Cipient <[email protected]>" &&
-	git format-patch --no-cc --stdout master..side |
-	sed -e "/^\$/q" >patch12 &&
-	check_patch patch12 &&
-	! grep "^Cc: C E Cipient <[email protected]>\$" patch12
+	git format-patch --no-cc --stdout master..side >patch12 &&
+	sed -e "/^\$/q" patch12 >hdrs12 &&
+	check_patch hdrs12 &&
+	! grep "^Cc: C E Cipient <[email protected]>\$" hdrs12
 '
 
 test_expect_success '--no-add-header overrides config.headers' '
 
 	git config --replace-all format.headers \
 		"Header1: B E Cipient <[email protected]>" &&
-	git format-patch --no-add-header --stdout master..side |
-	sed -e "/^\$/q" >patch13 &&
-	check_patch patch13 &&
-	! grep "^Header1: B E Cipient <[email protected]>\$" patch13
+	git format-patch --no-add-header --stdout master..side >patch13 &&
+	sed -e "/^\$/q" patch13 >hdrs13 &&
+	check_patch hdrs13 &&
+	! grep "^Header1: B E Cipient <[email protected]>\$" hdrs13
 '
 
 test_expect_success 'multiple files' '
@@ -357,7 +369,7 @@ test_expect_success 'reroll count (-v)' '
 check_threading () {
 	expect="$1" &&
 	shift &&
-	(git format-patch --stdout "$@"; echo $? > status.out) |
+	git format-patch --stdout "$@" >patch &&
 	# Prints everything between the Message-ID and In-Reply-To,
 	# and replaces all Message-ID-lookalikes by a sequence number
 	perl -ne '
@@ -372,12 +384,11 @@ check_threading () {
 			print;
 		}
 		print "---\n" if /^From /i;
-	' > actual &&
-	test 0 = "$(cat status.out)" &&
+	' <patch >actual &&
 	test_cmp "$expect" actual
 }
 
-cat >> expect.no-threading <<EOF
+cat >>expect.no-threading <<EOF
 ---
 ---
 ---
@@ -388,7 +399,7 @@ test_expect_success 'no threading' '
 	check_threading expect.no-threading master
 '
 
-cat > expect.thread <<EOF
+cat >expect.thread <<EOF
 ---
 Message-Id: <0>
 ---
@@ -405,7 +416,7 @@ test_expect_success 'thread' '
 	check_threading expect.thread --thread master
 '
 
-cat > expect.in-reply-to <<EOF
+cat >expect.in-reply-to <<EOF
 ---
 Message-Id: <0>
 In-Reply-To: <1>
@@ -425,7 +436,7 @@ test_expect_success 'thread in-reply-to' '
 		--thread master
 '
 
-cat > expect.cover-letter <<EOF
+cat >expect.cover-letter <<EOF
 ---
 Message-Id: <0>
 ---
@@ -446,7 +457,7 @@ test_expect_success 'thread cover-letter' '
 	check_threading expect.cover-letter --cover-letter --thread master
 '
 
-cat > expect.cl-irt <<EOF
+cat >expect.cl-irt <<EOF
 ---
 Message-Id: <0>
 In-Reply-To: <1>
@@ -478,7 +489,7 @@ test_expect_success 'thread explicit shallow' '
 		--in-reply-to="<test.message>" --thread=shallow master
 '
 
-cat > expect.deep <<EOF
+cat >expect.deep <<EOF
 ---
 Message-Id: <0>
 ---
@@ -496,7 +507,7 @@ test_expect_success 'thread deep' '
 	check_threading expect.deep --thread=deep master
 '
 
-cat > expect.deep-irt <<EOF
+cat >expect.deep-irt <<EOF
 ---
 Message-Id: <0>
 In-Reply-To: <1>
@@ -519,7 +530,7 @@ test_expect_success 'thread deep in-reply-to' '
 		--in-reply-to="<test.message>" master
 '
 
-cat > expect.deep-cl <<EOF
+cat >expect.deep-cl <<EOF
 ---
 Message-Id: <0>
 ---
@@ -543,7 +554,7 @@ test_expect_success 'thread deep cover-letter' '
 	check_threading expect.deep-cl --cover-letter --thread=deep master
 '
 
-cat > expect.deep-cl-irt <<EOF
+cat >expect.deep-cl-irt <<EOF
 ---
 Message-Id: <0>
 In-Reply-To: <1>
@@ -625,7 +636,7 @@ test_expect_success 'cover-letter inherits diff options' '
 
 '
 
-cat > expect << EOF
+cat >expect <<EOF
   This is an excessively long subject line for a message due to the
     habit some projects have of not having a short, one-line subject at
     the start of the commit message, but rather sticking a whole
@@ -638,12 +649,12 @@ EOF
 test_expect_success 'shortlog of cover-letter wraps overly-long onelines' '
 
 	git format-patch --cover-letter -2 &&
-	sed -e "1,/A U Thor/d" -e "/^\$/q" < 0000-cover-letter.patch > output &&
+	sed -e "1,/A U Thor/d" -e "/^\$/q" <0000-cover-letter.patch >output &&
 	test_cmp expect output
 
 '
 
-cat > expect << EOF
+cat >expect <<EOF
 index $before..$after 100644
 --- a/file
 +++ b/file
@@ -665,7 +676,7 @@ test_expect_success 'format-patch respects -U' '
 
 '
 
-cat > expect << EOF
+cat >expect <<EOF
 
 diff --git a/file b/file
 index $before..$after 100644
@@ -681,7 +692,7 @@ EOF
 test_expect_success 'format-patch -p suppresses stat' '
 
 	git format-patch -p -2 &&
-	sed -e "1,/^\$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output &&
+	sed -e "1,/^\$/d" -e "/^+5/q" <0001-This-is-an-excessively-long-subject-line-for-a-messa.patch >output &&
 	test_cmp expect output
 
 '
@@ -736,7 +747,7 @@ test_expect_success 'format-patch from a subdirectory (3)' '
 '
 
 test_expect_success 'format-patch --in-reply-to' '
-	git format-patch -1 --stdout --in-reply-to "[email protected]" > patch8 &&
+	git format-patch -1 --stdout --in-reply-to "[email protected]" >patch8 &&
 	grep "^In-Reply-To: <[email protected]>" patch8 &&
 	grep "^References: <[email protected]>" patch8
 '
@@ -827,21 +838,24 @@ test_expect_success 'format-patch with multiple notes refs' '
 	! grep "this is note 2" out
 '
 
-echo "fatal: --name-only does not make sense" > expect.name-only
-echo "fatal: --name-status does not make sense" > expect.name-status
-echo "fatal: --check does not make sense" > expect.check
+echo "fatal: --name-only does not make sense" >expect.name-only
+echo "fatal: --name-status does not make sense" >expect.name-status
+echo "fatal: --check does not make sense" >expect.check
 
 test_expect_success 'options no longer allowed for format-patch' '
-	test_must_fail git format-patch --name-only 2> output &&
+	test_must_fail git format-patch --name-only 2>output &&
 	test_i18ncmp expect.name-only output &&
-	test_must_fail git format-patch --name-status 2> output &&
+	test_must_fail git format-patch --name-status 2>output &&
 	test_i18ncmp expect.name-status output &&
-	test_must_fail git format-patch --check 2> output &&
-	test_i18ncmp expect.check output'
+	test_must_fail git format-patch --check 2>output &&
+	test_i18ncmp expect.check output
+'
 
 test_expect_success 'format-patch --numstat should produce a patch' '
-	git format-patch --numstat --stdout master..side > output &&
-	test 5 = $(grep "^diff --git a/" output | wc -l)'
+	git format-patch --numstat --stdout master..side >output &&
+	grep "^diff --git a/" output >diff &&
+	test_line_count = 5 diff
+'
 
 test_expect_success 'format-patch -- <path>' '
 	git format-patch master..side -- file 2>error &&
@@ -852,20 +866,21 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
 	git format-patch --ignore-if-in-upstream HEAD
 '
 
-git_version="$(git --version | sed "s/.* //")"
-
 signature() {
+	git_version="$(git --version >version && sed "s/.* //" version)" &&
 	printf "%s\n%s\n\n" "-- " "${1:-$git_version}"
 }
 
 test_expect_success 'format-patch default signature' '
-	git format-patch --stdout -1 | tail -n 3 >output &&
+	git format-patch --stdout -1 >patch &&
+	tail -n 3 patch >output &&
 	signature >expect &&
 	test_cmp expect output
 '
 
 test_expect_success 'format-patch --signature' '
-	git format-patch --stdout --signature="my sig" -1 | tail -n 3 >output &&
+	git format-patch --stdout --signature="my sig" -1 >patch &&
+	tail -n 3 patch >output &&
 	signature "my sig" >expect &&
 	test_cmp expect output
 '
@@ -897,8 +912,8 @@ test_expect_success 'format-patch --signature --cover-letter' '
 	git config --unset-all format.signature &&
 	git format-patch --stdout --signature="my sig" --cover-letter \
 		-1 >output &&
-	grep "my sig" output &&
-	test 2 = $(grep "my sig" output | wc -l)
+	grep "my sig" output >sig &&
+	test_line_count = 2 sig
 '
 
 test_expect_success 'format.signature="" suppresses signatures' '
@@ -1256,283 +1271,283 @@ append_signoff()
 
 test_expect_success 'signoff: commit with no body' '
 	append_signoff </dev/null >actual &&
-	cat <<\EOF | sed "s/EOL$//" >expected &&
-4:Subject: [PATCH] EOL
-8:
-9:Signed-off-by: C O Mitter <[email protected]>
-EOF
-	test_cmp expected actual
+	cat <<-\EOF | sed "s/EOL$//" >expect &&
+	4:Subject: [PATCH] EOL
+	8:
+	9:Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: commit with only subject' '
 	echo subject | append_signoff >actual &&
-	cat >expected <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-9:Signed-off-by: C O Mitter <[email protected]>
-EOF
-	test_cmp expected actual
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	9:Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: commit with only subject that does not end with NL' '
 	printf subject | append_signoff >actual &&
-	cat >expected <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-9:Signed-off-by: C O Mitter <[email protected]>
-EOF
-	test_cmp expected actual
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	9:Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: no existing signoffs' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
-EOF
-	cat >expected <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-11:Signed-off-by: C O Mitter <[email protected]>
-EOF
-	test_cmp expected actual
+	body
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	11:Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: no existing signoffs and no trailing NL' '
 	printf "subject\n\nbody" | append_signoff >actual &&
-	cat >expected <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-11:Signed-off-by: C O Mitter <[email protected]>
-EOF
-	test_cmp expected actual
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	11:Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: some random signoff' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
+	body
 
-Signed-off-by: my@house
-EOF
-	cat >expected <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-11:Signed-off-by: my@house
-12:Signed-off-by: C O Mitter <[email protected]>
-EOF
-	test_cmp expected actual
+	Signed-off-by: my@house
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	11:Signed-off-by: my@house
+	12:Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: misc conforming footer elements' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
+	body
 
-Signed-off-by: my@house
-(cherry picked from commit da39a3ee5e6b4b0d3255bfef95601890afd80709)
-Tested-by: Some One <[email protected]>
-Bug: 1234
-EOF
-	cat >expected <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-11:Signed-off-by: my@house
-15:Signed-off-by: C O Mitter <[email protected]>
-EOF
-	test_cmp expected actual
+	Signed-off-by: my@house
+	(cherry picked from commit da39a3ee5e6b4b0d3255bfef95601890afd80709)
+	Tested-by: Some One <[email protected]>
+	Bug: 1234
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	11:Signed-off-by: my@house
+	15:Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: some random signoff-alike' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
-Fooled-by-me: my@house
-EOF
-	cat >expected <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-11:
-12:Signed-off-by: C O Mitter <[email protected]>
-EOF
-	test_cmp expected actual
+	body
+	Fooled-by-me: my@house
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	11:
+	12:Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: not really a signoff' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-I want to mention about Signed-off-by: here.
-EOF
-	cat >expected <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-9:I want to mention about Signed-off-by: here.
-10:
-11:Signed-off-by: C O Mitter <[email protected]>
-EOF
-	test_cmp expected actual
+	I want to mention about Signed-off-by: here.
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	9:I want to mention about Signed-off-by: here.
+	10:
+	11:Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: not really a signoff (2)' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-My unfortunate
-Signed-off-by: example happens to be wrapped here.
-EOF
-	cat >expected <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:Signed-off-by: example happens to be wrapped here.
-11:Signed-off-by: C O Mitter <[email protected]>
-EOF
-	test_cmp expected actual
+	My unfortunate
+	Signed-off-by: example happens to be wrapped here.
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:Signed-off-by: example happens to be wrapped here.
+	11:Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: valid S-o-b paragraph in the middle' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-Signed-off-by: my@house
-Signed-off-by: your@house
+	Signed-off-by: my@house
+	Signed-off-by: your@house
 
-A lot of houses.
-EOF
-	cat >expected <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-9:Signed-off-by: my@house
-10:Signed-off-by: your@house
-11:
-13:
-14:Signed-off-by: C O Mitter <[email protected]>
-EOF
-	test_cmp expected actual
+	A lot of houses.
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	9:Signed-off-by: my@house
+	10:Signed-off-by: your@house
+	11:
+	13:
+	14:Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: the same signoff at the end' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
+	body
 
-Signed-off-by: C O Mitter <[email protected]>
-EOF
-	cat >expected <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-11:Signed-off-by: C O Mitter <[email protected]>
-EOF
-	test_cmp expected actual
+	Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	11:Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: the same signoff at the end, no trailing NL' '
 	printf "subject\n\nSigned-off-by: C O Mitter <[email protected]>" |
 		append_signoff >actual &&
-	cat >expected <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-9:Signed-off-by: C O Mitter <[email protected]>
-EOF
-	test_cmp expected actual
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	9:Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: the same signoff NOT at the end' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
+	body
 
-Signed-off-by: C O Mitter <[email protected]>
-Signed-off-by: my@house
-EOF
-	cat >expected <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-11:Signed-off-by: C O Mitter <[email protected]>
-12:Signed-off-by: my@house
-EOF
-	test_cmp expected actual
+	Signed-off-by: C O Mitter <[email protected]>
+	Signed-off-by: my@house
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	11:Signed-off-by: C O Mitter <[email protected]>
+	12:Signed-off-by: my@house
+	EOF
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: tolerate garbage in conforming footer' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
+	body
 
-Tested-by: my@house
-Some Trash
-Signed-off-by: C O Mitter <[email protected]>
-EOF
-	cat >expected <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-13:Signed-off-by: C O Mitter <[email protected]>
-EOF
-	test_cmp expected actual
+	Tested-by: my@house
+	Some Trash
+	Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	13:Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: respect trailer config' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-Myfooter: x
-Some Trash
-EOF
-	cat >expected <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-11:
-12:Signed-off-by: C O Mitter <[email protected]>
-EOF
-	test_cmp expected actual &&
+	Myfooter: x
+	Some Trash
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	11:
+	12:Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	test_cmp expect actual &&
 
 	test_config trailer.Myfooter.ifexists add &&
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-Myfooter: x
-Some Trash
-EOF
-	cat >expected <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-11:Signed-off-by: C O Mitter <[email protected]>
-EOF
-	test_cmp expected actual
+	Myfooter: x
+	Some Trash
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	11:Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: footer begins with non-signoff without @ sign' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
+	body
 
-Reviewed-id: Noone
-Tested-by: my@house
-Change-id: Ideadbeef
-Signed-off-by: C O Mitter <[email protected]>
-Bug: 1234
-EOF
-	cat >expected <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-14:Signed-off-by: C O Mitter <[email protected]>
-EOF
-	test_cmp expected actual
+	Reviewed-id: Noone
+	Tested-by: my@house
+	Change-id: Ideadbeef
+	Signed-off-by: C O Mitter <[email protected]>
+	Bug: 1234
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	14:Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	test_cmp expect actual
 '
 
 test_expect_success 'format patch ignores color.ui' '
@@ -1547,42 +1562,42 @@ test_expect_success 'cover letter using branch description (1)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
 	git format-patch --stdout --cover-letter master >actual &&
-	grep hello actual >/dev/null
+	grep hello actual
 '
 
 test_expect_success 'cover letter using branch description (2)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
 	git format-patch --stdout --cover-letter rebuild-1~2..rebuild-1 >actual &&
-	grep hello actual >/dev/null
+	grep hello actual
 '
 
 test_expect_success 'cover letter using branch description (3)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
 	git format-patch --stdout --cover-letter ^master rebuild-1 >actual &&
-	grep hello actual >/dev/null
+	grep hello actual
 '
 
 test_expect_success 'cover letter using branch description (4)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
 	git format-patch --stdout --cover-letter master.. >actual &&
-	grep hello actual >/dev/null
+	grep hello actual
 '
 
 test_expect_success 'cover letter using branch description (5)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
 	git format-patch --stdout --cover-letter -2 HEAD >actual &&
-	grep hello actual >/dev/null
+	grep hello actual
 '
 
 test_expect_success 'cover letter using branch description (6)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
 	git format-patch --stdout --cover-letter -2 >actual &&
-	grep hello actual >/dev/null
+	grep hello actual
 '
 
 test_expect_success 'cover letter with nothing' '
@@ -1636,7 +1651,8 @@ test_expect_success 'format-patch format.outputDirectory option' '
 	test_config format.outputDirectory patches &&
 	rm -fr patches &&
 	git format-patch master..side &&
-	test $(git rev-list master..side | wc -l) -eq $(ls patches | wc -l)
+	git rev-list master..side >list &&
+	test_line_count = $(ls patches | wc -l) list
 '
 
 test_expect_success 'format-patch -o overrides format.outputDirectory' '
@@ -1649,20 +1665,41 @@ test_expect_success 'format-patch -o overrides format.outputDirectory' '
 
 test_expect_success 'format-patch --base' '
 	git checkout patchid &&
-	git format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual1 &&
-	git format-patch --stdout --base=HEAD~3 HEAD~.. | tail -n 7 >actual2 &&
-	echo >expected &&
-	echo "base-commit: $(git rev-parse HEAD~3)" >>expected &&
-	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expected &&
-	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expected &&
-	signature >> expected &&
-	test_cmp expected actual1 &&
-	test_cmp expected actual2 &&
+
+	git format-patch --stdout --base=HEAD~3 -1 >patch &&
+	tail -n 7 patch >actual1 &&
+
+	git format-patch --stdout --base=HEAD~3 HEAD~.. >patch &&
+	tail -n 7 patch >actual2 &&
+
+	echo >expect &&
+	git rev-parse HEAD~3 >commit-id-base &&
+	echo "base-commit: $(cat commit-id-base)" >>expect &&
+
+	git show --patch HEAD~2 >patch &&
+	git patch-id --stable <patch >patch.id.raw &&
+	awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >>expect &&
+
+	git show --patch HEAD~1 >patch &&
+	git patch-id --stable <patch >patch.id.raw &&
+	awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >>expect &&
+
+	signature >>expect &&
+	test_cmp expect actual1 &&
+	test_cmp expect actual2 &&
+
 	echo >fail &&
-	echo "base-commit: $(git rev-parse HEAD~3)" >>fail &&
-	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --unstable | awk "{print \$1}")" >>fail &&
-	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --unstable | awk "{print \$1}")" >>fail &&
-	signature >> fail &&
+	echo "base-commit: $(cat commit-id-base)" >>fail &&
+
+	git show --patch HEAD~2 >patch &&
+	git patch-id --unstable <patch >patch.id.raw &&
+	awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >>fail &&
+
+	git show --patch HEAD~1 >patch &&
+	git patch-id --unstable <patch >patch.id.raw &&
+	awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >>fail &&
+
+	signature >>fail &&
 	! test_cmp fail actual1 &&
 	! test_cmp fail actual2
 '
@@ -1672,8 +1709,9 @@ test_expect_success 'format-patch --base errors out when base commit is in revis
 	test_must_fail git format-patch --base=HEAD~1 -2 &&
 	git format-patch --stdout --base=HEAD~2 -2 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse HEAD~2)" >expected &&
-	test_cmp expected actual
+	git rev-parse HEAD~2 >commit-id-base &&
+	echo "base-commit: $(cat commit-id-base)" >expect &&
+	test_cmp expect actual
 '
 
 test_expect_success 'format-patch --base errors out when base commit is not ancestor of revision list' '
@@ -1699,8 +1737,8 @@ test_expect_success 'format-patch --base errors out when base commit is not ance
 	test_must_fail git format-patch --base=$(cat commit-id-Z) -3 &&
 	git format-patch --stdout --base=$(cat commit-id-base) -3 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(cat commit-id-base)" >expected &&
-	test_cmp expected actual
+	echo "base-commit: $(cat commit-id-base)" >expect &&
+	test_cmp expect actual
 '
 
 test_expect_success 'format-patch --base=auto' '
@@ -1711,8 +1749,9 @@ test_expect_success 'format-patch --base=auto' '
 	test_commit N2 &&
 	git format-patch --stdout --base=auto -2 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse upstream)" >expected &&
-	test_cmp expected actual
+	git rev-parse upstream >commit-id-base &&
+	echo "base-commit: $(cat commit-id-base)" >expect &&
+	test_cmp expect actual
 '
 
 test_expect_success 'format-patch errors out when history involves criss-cross' '
@@ -1748,8 +1787,9 @@ test_expect_success 'format-patch format.useAutoBaseoption' '
 	git config format.useAutoBase true &&
 	git format-patch --stdout -1 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse upstream)" >expected &&
-	test_cmp expected actual
+	git rev-parse upstream >commit-id-base &&
+	echo "base-commit: $(cat commit-id-base)" >expect &&
+	test_cmp expect actual
 '
 
 test_expect_success 'format-patch --base overrides format.useAutoBase' '
@@ -1757,8 +1797,9 @@ test_expect_success 'format-patch --base overrides format.useAutoBase' '
 	git config format.useAutoBase true &&
 	git format-patch --stdout --base=HEAD~1 -1 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse HEAD~1)" >expected &&
-	test_cmp expected actual
+	git rev-parse HEAD~1 >commit-id-base &&
+	echo "base-commit: $(cat commit-id-base)" >expect &&
+	test_cmp expect actual
 '
 
 test_expect_success 'format-patch --base with --attach' '
Signature · 1 line
2.23.0.248.g3a9dd8fb08
#2 lore raw

Re: [PATCH v2 1/4] t4014: clean up style

Quoted 24 lines · Denton Liu

In Git's tests, there is typically no space between the redirection operator and the filename. Remove these spaces.

Since output is silenced when running without -v and debugging output is useful with -v, remove redirections to /dev/null.

Change here-docs from <<\EOF to <<-\EOF so that they can be indented along with the rest of the test case.

Convert all instances of cnt=$(... | wc -l) && test $cnt = N into uses of test_line_count().

For style, move the ending sq of test cases onto its own line whenever they do not conform.

Rename output files from "expected" to "expect" to conform with the usual convention.

Finally, refactor to remove Git commands upstream of pipe as well as Git commands that are in a non-variable-assignment subshell (e.g. echo "base-commit: $(git rev-parse HEAD)". This way, if an invocation of a Git command fails, the return code won't be lost. Keep upstream non-Git commands since we have to assume a base level of sanity.

Quoted 5 lines

---
This patch is getting a little unwieldy. Perhaps we could split it into several smaller patches? Unfortunately, I'm not really sure where a logical place to split it would be.

The bullet points in the commit message, each of which is a distinct change, give a strong hint as to how the commit could be split into smaller pieces. It would make repeated review easier (though I'm not sure it's worth re-rolling just for that).

t/t4014-format-patch.sh test_expect_success setup ' · line 69

Quoted 12 lines
t/t4014-format-patch.sh +2 -3
@@ -62,26 +63,24 @@ test_expect_success setup '
 test_expect_success "format-patch --ignore-if-in-upstream" '
 
        git format-patch --stdout \
                --ignore-if-in-upstream master..side >patch1 &&
-       cnt=$(grep "^From " patch1 | wc -l) &&
-       test $cnt = 2
-
+       grep "^From " patch1 >from1 &&
+       test_line_count = 2 from1
 '

Here you've removed the blank line following the body before the closing quote, which brings the formatting more in line with current style, however, you could do the same with the blank line before the body. Ditto for other tests.

Another style fix would be to change the double quotes in the test title to single quotes (here and in other tests).

Quoted 10 lines
t/t4014-format-patch.sh +1 -1
@@ -357,7 +369,7 @@ test_expect_success 'reroll count (-v)' '
 check_threading () {
        expect="$1" &&
        shift &&
-       (git format-patch --stdout "$@"; echo $? > status.out) |
+       git format-patch --stdout "$@" >patch &&
        # Prints everything between the Message-ID and In-Reply-To,
        # and replaces all Message-ID-lookalikes by a sequence number
        perl -ne '

t/t4014-format-patch.sh check_threading () { · line 389

Quoted 8 lines
t/t4014-format-patch.sh +1 -2
@@ -372,12 +384,11 @@ check_threading () {
                        print;
                }
                print "---\n" if /^From /i;
-       ' > actual &&
-       test 0 = "$(cat status.out)" &&
+       ' <patch >actual &&
        test_cmp "$expect" actual
 }

If you do break this patch into smaller pieces, this might deserve its own patch (or not) because it requires a bit of extra reasoning by the reviewer.

t/t4014-format-patch.sh test_expect_success 'format-patch --ignore-if-in-upstream HEAD' ' · line 869

Quoted 7 lines
t/t4014-format-patch.sh +1 -2
@@ -852,20 +866,21 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
-git_version="$(git --version | sed "s/.* //")"
-
 signature() {
+       git_version="$(git --version >version && sed "s/.* //" version)" &&
        printf "%s\n%s\n\n" "-- " "${1:-$git_version}"
 }

Windows folks are not going to like you for this change since process creation is so expensive on that platform, and the point of setting that variable globally was to avoid repeated invocation (especially since the output of "git --version" won't change). This function appears to be invoked only three times presently, but that number could increase in the future as new tests are added. Consequently, it might be best to drop this change.

author
#3 lore raw

PATCH v2 2/4 Doc: add more detail for git-format-patch

In reply to Denton Liu

In git-format-patch.txt, we were missing some key user information. First of all, using the --to and --cc options don't override format.to and format.cc variables, respectively. They add on to each other. Document this.

In addition, document the special value of --base=auto.

Next, while we're at it, surround option arguments with <>.

Finally, document the format.outputDirectory config and change format.coverletter to use camel case.

---
 Documentation/git-format-patch.txt | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
Documentation/git-format-patch.txt +10 -7
index b9b97e63ae..95bc4d53ca 100644
@@ -17,9 +17,9 @@ SYNOPSIS
 		   [--signature-file=<file>]
 		   [-n | --numbered | -N | --no-numbered]
 		   [--start-number <n>] [--numbered-files]
-		   [--in-reply-to=Message-Id] [--suffix=.<sfx>]
+		   [--in-reply-to=<Message-Id>] [--suffix=.<sfx>]
 		   [--ignore-if-in-upstream]
-		   [--rfc] [--subject-prefix=Subject-Prefix]
+		   [--rfc] [--subject-prefix=<Subject-Prefix>]
 		   [(--reroll-count|-v) <n>]
 		   [--to=<email>] [--cc=<email>]
 		   [--[no-]cover-letter] [--quiet]
@@ -159,7 +159,7 @@ Beware that the default for 'git send-email' is to thread emails
 itself.  If you want `git format-patch` to take care of threading, you
 will want to ensure that threading is disabled for `git send-email`.
 
---in-reply-to=Message-Id::
+--in-reply-to=<Message-Id>::
 	Make the first mail (or all the mails with `--no-thread`) appear as a
 	reply to the given Message-Id, which avoids breaking threads to
 	provide a new patch series.
@@ -314,7 +314,8 @@ you can use `--suffix=-patch` to get `0001-description-of-my-change-patch`.
 --base=<commit>::
 	Record the base tree information to identify the state the
 	patch series applies to.  See the BASE TREE INFORMATION section
-	below for details.
+	below for details. If <commit> is "auto", a base commit is
+	automatically chosen.
 
 --root::
 	Treat the revision argument as a <revision range>, even if it
@@ -330,8 +331,9 @@ CONFIGURATION
 -------------
 You can specify extra mail header lines to be added to each message,
 defaults for the subject prefix and file suffix, number patches when
-outputting more than one patch, add "To" or "Cc:" headers, configure
-attachments, and sign off patches with configuration variables.
+outputting more than one patch, add "To:" or "Cc:" headers, configure
+attachments, change the patch output directory, and sign off patches
+with configuration variables.
 
 ------------
 [format]
@@ -343,7 +345,8 @@ attachments, and sign off patches with configuration variables.
 	cc = <email>
 	attach [ = mime-boundary-string ]
 	signOff = true
-	coverletter = auto
+	outputDirectory = <directory>
+	coverLetter = auto
 ------------
 
 
Signature · 1 line
2.23.0.248.g3a9dd8fb08
#4 lore raw

Re: [PATCH v2 2/4] Doc: add more detail for git-format-patch

Quoted 4 lines · Denton Liu

In git-format-patch.txt, we were missing some key user information. First of all, using the --to and --cc options don't override format.to and format.cc variables, respectively. They add on to each other. Document this.

This entire paragraph can go away since v2 dropped this change.

Quoted 11 lines

In addition, document the special value of --base=auto.

Next, while we're at it, surround option arguments with <>.

Finally, document the format.outputDirectory config and change format.coverletter to use camel case.

---

Documentation/git-format-patch.txt you can use `--suffix=-patch` to get `0001-description-of-my-change-patch`. · line 318

Quoted 6 lines
Documentation/git-format-patch.txt +2 -1
@@ -314,7 +314,8 @@ you can use `--suffix=-patch` to get `0001-description-of-my-change-patch`.
 --base=<commit>::
        Record the base tree information to identify the state the
        patch series applies to.  See the BASE TREE INFORMATION section
-       below for details.
+       below for details. If <commit> is "auto", a base commit is
+       automatically chosen.

Should <commit> be encased in backquotes in the paragraph body?

author
#5 lore raw

Re: [PATCH v2 2/4] Doc: add more detail for git-format-patch

Quoted 15 lines · Eric Sunshine
Quoted 4 lines · Denton Liu

In git-format-patch.txt, we were missing some key user information. First of all, using the --to and --cc options don't override format.to and format.cc variables, respectively. They add on to each other. Document this.

This entire paragraph can go away since v2 dropped this change.

Quoted 7 lines

In addition, document the special value of --base=auto.

Next, while we're at it, surround option arguments with <>.

Finally, document the format.outputDirectory config and change format.coverletter to use camel case.

Quoted 12 lines

Documentation/git-format-patch.txt you can use `--suffix=-patch` to get `0001-description-of-my-change-patch`. · line 318

Quoted 10 lines

---

Documentation/git-format-patch.txt +2 -1
@@ -314,7 +314,8 @@ you can use `--suffix=-patch` to get `0001-description-of-my-change-patch`.
 --base=<commit>::
        Record the base tree information to identify the state the
        patch series applies to.  See the BASE TREE INFORMATION section
-       below for details.
+       below for details. If <commit> is "auto", a base commit is
+       automatically chosen.

Should <commit> be encased in backquotes in the paragraph body?

In this page, it seems like the other instances of <commit> (or most other <text> for that matter) aren't wrapped in backquotes. From checking out the rest of Git's documentation, it seems like it's a mixed bag whether to do this or not.

I'm going to leave it as is and hopefully someone who cares enough will make the docs more stylistically uniform.

author
#6 lore raw

PATCH v2 3/4 config/format.txt: make clear the default value of format.coverLetter

In reply to Denton Liu
---
 Documentation/config/format.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/config/format.txt +2 -1
index 414a5a8a9d..60e4e92885 100644
@@ -74,7 +74,8 @@ format.signOff::
 	Please see the 'SubmittingPatches' document for further discussion.
 
 format.coverLetter::
-	A boolean that controls whether to generate a cover-letter when
+	A boolean which lets you enable the `--cover-letter` option by
+	default when
 	format-patch is invoked, but in addition can be set to "auto", to
 	generate a cover-letter only when there's more than one patch.
 
Signature · 1 line
2.23.0.248.g3a9dd8fb08
#7 lore raw

Re: [PATCH v2 3/4] config/format.txt: make clear the default value of format.coverLetter

Documentation/config/format.txt format.signOff:: · line 78

Quoted 8 lines · Denton Liu
Documentation/config/format.txt +2 -1
@@ -74,7 +74,8 @@ format.signOff::
 format.coverLetter::
-       A boolean that controls whether to generate a cover-letter when
+       A boolean which lets you enable the `--cover-letter` option by
+       default when
        format-patch is invoked, but in addition can be set to "auto", to
        generate a cover-letter only when there's more than one patch.

Rather than rewriting like this, I think it's more common in Git documentation to mention the default as the last sentence in the paragraph. For instance:

... when there's more than one patch. Default is true.

author
#8 lore raw

PATCH v2 4/4 format-patch: learn --infer-cover-letter option

In reply to Denton Liu

We used to populate the subject of the cover letter generated by git-format-patch with "*** SUBJECT HERE ***". However, if a user submits multiple patchsets, they may want to keep a consistent subject between rerolls.

If git-format-patch is run with --infer-cover-letter or format.inferCoverSubject, infer the subject for the cover letter from the top line(s) of a branch description, similar to how a subject is read from a commit message.

---
 Documentation/config/format.txt    |  4 +++
 Documentation/git-format-patch.txt | 10 ++++++
 builtin/log.c                      | 56 +++++++++++++++++++-----------
 t/t4014-format-patch.sh            | 33 ++++++++++++++++++
 4 files changed, 82 insertions(+), 21 deletions(-)
Documentation/config/format.txt +4 -0
index 60e4e92885..9cd6a64e3e 100644
@@ -36,6 +36,10 @@ format.subjectPrefix::
 	The default for format-patch is to output files with the '[PATCH]'
 	subject prefix. Use this variable to change that prefix.
 
+format.inferCoverSubject::
+	A boolean value which lets you enable the
+	`--infer-cover-subject` option of format-patch by default.
+
 format.signature::
 	The default for format-patch is to output a signature containing
 	the Git version number. Use this variable to change that default.
Documentation/git-format-patch.txt +10 -0
index 95bc4d53ca..00ccfb51e7 100644
@@ -19,6 +19,7 @@ SYNOPSIS
 		   [--start-number <n>] [--numbered-files]
 		   [--in-reply-to=<Message-Id>] [--suffix=.<sfx>]
 		   [--ignore-if-in-upstream]
+		   [--[no-]infer-cover-subject]
 		   [--rfc] [--subject-prefix=<Subject-Prefix>]
 		   [(--reroll-count|-v) <n>]
 		   [--to=<email>] [--cc=<email>]
@@ -171,6 +172,14 @@ will want to ensure that threading is disabled for `git send-email`.
 	patches being generated, and any patch that matches is
 	ignored.
 
+--[no-]infer-cover-subject::
+	Instead of using the default "*** SUBJECT HERE ***" subject for
+	the cover letter, infer the subject from the branch's
+	description.
++
+Similar to a commit message, the subject is inferred as the beginning of
+the description up to and excluding the first blank line.
+
 --subject-prefix=<Subject-Prefix>::
 	Instead of the standard '[PATCH]' prefix in the subject
 	line, instead use '[<Subject-Prefix>]'. This
@@ -347,6 +356,7 @@ with configuration variables.
 	signOff = true
 	outputDirectory = <directory>
 	coverLetter = auto
+	inferCoverSubject = true
 ------------
 
 
builtin/log.c +35 -21

110 lines not on this page · raw message

t/t4014-format-patch.sh +33 -0
index 0114608b1f..ad920bb063 100755
@@ -1558,6 +1558,39 @@ test_expect_success 'format patch ignores color.ui' '
 	test_cmp expect actual
 '
 
+test_expect_success 'cover letter with config subject' '
+	test_config branch.rebuild-1.description "config subject
+
+body" &&
+	test_config format.inferCoverSubject true &&
+	git checkout rebuild-1 &&
+	git format-patch --stdout --cover-letter master >actual &&
+	grep "^Subject: \[PATCH 0/2\] config subject$" actual &&
+	grep "^body" actual
+'
+
+test_expect_success 'cover letter with command-line subject' '
+	test_config branch.rebuild-1.description "command-line subject
+
+body" &&
+	git checkout rebuild-1 &&
+	git format-patch --stdout --cover-letter --infer-cover-subject master >actual &&
+	grep "^Subject: \[PATCH 0/2\] command-line subject$" actual &&
+	grep "^body" actual
+'
+
+test_expect_success 'cover letter with command-line --no-infer-cover-subject overrides config' '
+	test_config branch.rebuild-1.description "config subject
+
+body" &&
+	test_config format.inferCoverSubject true &&
+	git checkout rebuild-1 &&
+	git format-patch --stdout --cover-letter --no-infer-cover-subject master >actual &&
+	grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual &&
+	grep "^config subject" actual &&
+	grep "^body" actual
+'
+
 test_expect_success 'cover letter using branch description (1)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
Signature · 1 line
2.23.0.248.g3a9dd8fb08
#9 lore raw

Re: [PATCH v2 4/4] format-patch: learn --infer-cover-letter option

Quoted 6 lines · Denton Liu

We used to populate the subject of the cover letter generated by git-format-patch with "*** SUBJECT HERE ***". However, if a user submits multiple patchsets, they may want to keep a consistent subject between rerolls.

If git-format-patch is run with --infer-cover-letter or

s/letter/subject/

Quoted 3 lines

format.inferCoverSubject, infer the subject for the cover letter from the top line(s) of a branch description, similar to how a subject is read from a commit message.

A possible rewrite of the entire commit message in imperative mood:

Teach 'format-patch' to use the first line of the branch description as the Subject: of the generated cover letter, rather than "*** SUBJECT HERE ***", if --infer-cover-subject is specified (or the corresponding format.inferCoverSubject option is enabled). This complements existing inclusion of the branch description in the cover letter body.

A casual reader of this patch might wonder why this new useful behavior isn't default, so it might make sense for the commit message to further explain that making it default would potentially break existing tooling.

Documentation/config/format.txt format.subjectPrefix:: · line 38

Quoted 7 lines

---

Documentation/config/format.txt +3 -0
@@ -36,6 +36,10 @@ format.subjectPrefix::
+format.inferCoverSubject::
+       A boolean value which lets you enable the
+       `--infer-cover-subject` option of format-patch by default.

As mentioned in my review of 3/4, it is common to mention the default value at the end of the paragraph. So, perhaps:

A boolean that controls whether or not to take the first line of the branch description as the subject for the cover letter. See the --infer-cover-subject option in linkgit:git-format-patch[1]. Default is false.

Documentation/git-format-patch.txt will want to ensure that threading is disabled for `git send-email`. · line 178

Quoted 9 lines
Documentation/git-format-patch.txt +7 -0
@@ -171,6 +172,14 @@ will want to ensure that threading is disabled for `git send-email`.
+--[no-]infer-cover-subject::
+       Instead of using the default "*** SUBJECT HERE ***" subject for
+       the cover letter, infer the subject from the branch's
+       description.
++
+Similar to a commit message, the subject is inferred as the beginning of
+the description up to and excluding the first blank line.

I think this can all be collapsed to the simpler:

Use the beginning of the branch description (up to the first blank line) as the cover letter subject instead of the default "*** SUBJECT HERE ***".

or something.

builtin/log.c int cmd_format_patch(int argc, const char **argv, const char *prefix) · line 1590

Quoted 4 lines
builtin/log.c +2 -0
@@ -1577,6 +1589,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
+               OPT_BOOL(0, "infer-cover-subject", &infer_cover_subject,
+                           N_("infer a cover letter subject from the branch description")),

Shorter: "infer cover letter subject from branch description"

author
#10 lore raw

v3 cover format-patch: learn --infer-cover-subject option (also t4014 cleanup)

In reply to Denton Liu

Thanks for another round of reviews, Eric. I've incorporated most of your suggestions, including breaking the t4014 cleanup patch into multiple patches. Hopefully it isn't such a doozy to review now.

Currently, format-patch only puts "*** SUBJECT HERE ***" when a cover letter is generated. However, it is already smart enough to be able to populate the cover letter with the branch description so there's no reason why it cannot populate the subject as well.

Teach format-patch the --infer-cover-subject option and corresponding format.inferCoverSubject configuration option which will read the subject from the branch description using the same rules as for a commit message (that is, it will expect a subject line followed by a blank line).

While we're at it, perform some major cleanup of t4014 including some stylistic cleanup and also, unmasking of Git return codes.

This was based on patches 1-3 of an earlier patchset I sent[1].

Changes since v2:

* Break 1/4 into many different patches (one per paragraph of the original patch)

* Incorporate Eric's documentation/commit message suggestions

Changes since v1:

* Incorporate Eric's suggestions for cleanup in all patches

* Add patch 3/4 to make it clear what is the default value for format.coverLetter (since format.inferCoverSubject was borrowed from this config but it also did not state what the default value was)

* In 1/4, rename all instances of "expected" to "expect"

[1]: https://public-inbox.org/git/[email protected]/

Denton Liu (13):
t4014: drop unnecessary blank lines from test cases
t4014: s/expected/expect/
t4014: move closing sq onto its own line
t4014: use sq for test case names
t4014: remove spaces after redirect operators
t4014: use indentable here-docs
t4014: drop redirections to /dev/null
t4014: use test_line_count() where possible
t4014: remove confusing pipe in check_threading()
t4014: stop losing return codes of git commands
Doc: add more detail for git-format-patch config/format.txt: specify default value of format.coverLetter
format-patch: learn --infer-cover-subject option

 Documentation/config/format.txt    |   7 +
 Documentation/git-format-patch.txt |  24 +-
 builtin/log.c                      |  56 +-
 t/t4014-format-patch.sh            | 822 +++++++++++++++--------------
 4 files changed, 486 insertions(+), 423 deletions(-)

Range-diff against v2:

 1:  76a0a274fd <  -:  ---------- t4014: clean up style
 -:  ---------- >  1:  fb000bfca2 t4014: drop unnecessary blank lines from test cases
 -:  ---------- >  2:  568b3a03a0 t4014: s/expected/expect/
 -:  ---------- >  3:  a205a920bd t4014: move closing sq onto its own line
 -:  ---------- >  4:  66bf2e3dd4 t4014: use sq for test case names
 -:  ---------- >  5:  6f1371275e t4014: remove spaces after redirect operators
 -:  ---------- >  6:  b4295846f5 t4014: use indentable here-docs
 -:  ---------- >  7:  34315412c8 t4014: drop redirections to /dev/null
 -:  ---------- >  8:  de08dd886d t4014: use test_line_count() where possible
 -:  ---------- >  9:  dec5a62e82 t4014: remove confusing pipe in check_threading()
 -:  ---------- > 10:  64069c0c54 t4014: stop losing return codes of git commands
 2:  fd908bcc01 ! 11:  c12534ab5d Doc: add more detail for git-format-patch

@@ Commit message
Doc: add more detail for git-format-patch

In git-format-patch.txt, we were missing some key user information.
- First of all, using the --to and --cc options don't override
- format.to and format.cc variables, respectively. They add on to each
- other. Document this.
-
- In addition, document the special value of --base=auto.
+ First of all, document the special value of --base=auto.

Next, while we're at it, surround option arguments with <>.

 3:  94a778c9aa <  -:  ---------- config/format.txt: make clear the default value of format.coverLetter
 -:  ---------- > 12:  a08273ebcc config/format.txt: specify default value of format.coverLetter
 4:  e682bd347a ! 13:  de599f7ca9 format-patch: learn --infer-cover-letter option

@@ Metadata
Author: Denton Liu <[email protected]>

## Commit message ##
- format-patch: learn --infer-cover-letter option
+ format-patch: learn --infer-cover-subject option

- We used to populate the subject of the cover letter generated by
- git-format-patch with "*** SUBJECT HERE ***". However, if a user submits
- multiple patchsets, they may want to keep a consistent subject between
- rerolls.
+ Teach format-patch to use the first line of the branch description as
+ the Subject: of the generated cover letter, rather than "*** SUBJECT
+ HERE ***" if --infer-cover-subject is specified or the corresponding
+ format.inferCoverSubject option is enabled. This complements the
+ existing inclusion of the branch description in the cover letter body.

- If git-format-patch is run with --infer-cover-letter or
- format.inferCoverSubject, infer the subject for the cover letter from
- the top line(s) of a branch description, similar to how a subject is
- read from a commit message.
+ The reason why this behaviour is not made default is because this change
+ is not backwards compatible and may break existing tooling that may rely
+ on the default template subject.

@@ Documentation/config/format.txt: format.subjectPrefix::
subject prefix. Use this variable to change that prefix.

+format.inferCoverSubject::
-+ A boolean value which lets you enable the
-+ --infer-cover-subject option of format-patch by default.
++ A boolean that controls whether or not to take the first line of
++ the branch description as the subject for the cover letter. See the
++ --infer-cover-subject option in linkgit:git-format-patch[1].
++ Default is false.
+
format.signature::
The default for format-patch is to output a signature containing
@@ Documentation/git-format-patch.txt: will want to ensure that threading is disabl
ignored.

+--[no-]infer-cover-subject::
-+ Instead of using the default "*** SUBJECT HERE ***" subject for
-+ the cover letter, infer the subject from the branch's
-+ description.
-++
-+Similar to a commit message, the subject is inferred as the beginning of -+the description up to and excluding the first blank line.
++ Use the beginning of the branch description (up to the first
++ blank line) as the cover letter subject instead of the default
++ "*** SUBJECT HERE ***".
+
--subject-prefix=<Subject-Prefix>::
Instead of the standard '[PATCH]' prefix in the subject
@@ builtin/log.c: int cmd_format_patch(int argc, const char **argv, const char *pre
N_("Use [RFC PATCH] instead of [PATCH]"), PARSE_OPT_NOARG | PARSE_OPT_NONEG, rfc_callback },
+ OPT_BOOL(0, "infer-cover-subject", &infer_cover_subject,
-+ N_("infer a cover letter subject from the branch description")),
++ N_("infer a cover letter subject from branch description")),
{ OPTION_CALLBACK, 0, "subject-prefix", &rev, N_("prefix"),
N_("Use [<prefix>] instead of [PATCH]"), PARSE_OPT_NONEG, subject_prefix_callback },
@@ builtin/log.c: int cmd_format_patch(int argc, const char **argv, const char *pre
total++;

## t/t4014-format-patch.sh ##
+@@ t/t4014-format-patch.sh: test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
+ '
+
+ test_expect_success 'get git version' '
+- git_version="$(git --version | sed "s/.* //")"
++ git_version="$(git --version >version && sed "s/.* //" <version)"
+ '
+
+ signature() {
@@ t/t4014-format-patch.sh: test_expect_success 'format patch ignores color.ui' '
test_cmp expect actual
'

Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#11 lore raw

PATCH v3 1/13 t4014: drop unnecessary blank lines from test cases

---
 t/t4014-format-patch.sh | 47 -----------------------------------------
 1 file changed, 47 deletions(-)
t/t4014-format-patch.sh +0 -47
index ca7debf1d4..3ed3feabfe 100755
@@ -9,7 +9,6 @@ test_description='various format-patch tests'
 . "$TEST_DIRECTORY"/lib-terminal.sh
 
 test_expect_success setup '
-
 	for i in 1 2 3 4 5 6 7 8 9 10; do echo "$i"; done >file &&
 	cat file >elif &&
 	git add file elif &&
@@ -60,20 +59,16 @@ test_expect_success setup '
 '
 
 test_expect_success "format-patch --ignore-if-in-upstream" '
-
 	git format-patch --stdout master..side >patch0 &&
 	cnt=$(grep "^From " patch0 | wc -l) &&
 	test $cnt = 3
-
 '
 
 test_expect_success "format-patch --ignore-if-in-upstream" '
-
 	git format-patch --stdout \
 		--ignore-if-in-upstream master..side >patch1 &&
 	cnt=$(grep "^From " patch1 | wc -l) &&
 	test $cnt = 2
-
 '
 
 test_expect_success "format-patch --ignore-if-in-upstream handles tags" '
@@ -85,7 +80,6 @@ test_expect_success "format-patch --ignore-if-in-upstream handles tags" '
 '
 
 test_expect_success "format-patch doesn't consider merge commits" '
-
 	git checkout -b slave master &&
 	echo "Another line" >>file &&
 	test_tick &&
@@ -101,7 +95,6 @@ test_expect_success "format-patch doesn't consider merge commits" '
 '
 
 test_expect_success "format-patch result applies" '
-
 	git checkout -b rebuild-0 master &&
 	git am -3 patch0 &&
 	cnt=$(git rev-list master.. | wc -l) &&
@@ -109,7 +102,6 @@ test_expect_success "format-patch result applies" '
 '
 
 test_expect_success "format-patch --ignore-if-in-upstream result applies" '
-
 	git checkout -b rebuild-1 master &&
 	git am -3 patch1 &&
 	cnt=$(git rev-list master.. | wc -l) &&
@@ -117,26 +109,19 @@ test_expect_success "format-patch --ignore-if-in-upstream result applies" '
 '
 
 test_expect_success 'commit did not screw up the log message' '
-
 	git cat-file commit side | grep "^Side .* with .* backslash-n"
-
 '
 
 test_expect_success 'format-patch did not screw up the log message' '
-
 	grep "^Subject: .*Side changes #3 with .* backslash-n" patch0 &&
 	grep "^Subject: .*Side changes #3 with .* backslash-n" patch1
-
 '
 
 test_expect_success 'replay did not screw up the log message' '
-
 	git cat-file commit rebuild-1 | grep "^Side .* with .* backslash-n"
-
 '
 
 test_expect_success 'extra headers' '
-
 	git config format.headers "To: R E Cipient <[email protected]>
 " &&
 	git config --add format.headers "Cc: S E Cipient <[email protected]>
@@ -145,22 +130,18 @@ test_expect_success 'extra headers' '
 	sed -e "/^\$/q" patch2 > hdrs2 &&
 	grep "^To: R E Cipient <[email protected]>\$" hdrs2 &&
 	grep "^Cc: S E Cipient <[email protected]>\$" hdrs2
-
 '
 
 test_expect_success 'extra headers without newlines' '
-
 	git config --replace-all format.headers "To: R E Cipient <[email protected]>" &&
 	git config --add format.headers "Cc: S E Cipient <[email protected]>" &&
 	git format-patch --stdout master..side >patch3 &&
 	sed -e "/^\$/q" patch3 > hdrs3 &&
 	grep "^To: R E Cipient <[email protected]>\$" hdrs3 &&
 	grep "^Cc: S E Cipient <[email protected]>\$" hdrs3
-
 '
 
 test_expect_success 'extra headers with multiple To:s' '
-
 	git config --replace-all format.headers "To: R E Cipient <[email protected]>" &&
 	git config --add format.headers "To: S E Cipient <[email protected]>" &&
 	git format-patch --stdout master..side > patch4 &&
@@ -170,7 +151,6 @@ test_expect_success 'extra headers with multiple To:s' '
 '
 
 test_expect_success 'additional command line cc (ascii)' '
-
 	git config --replace-all format.headers "Cc: R E Cipient <[email protected]>" &&
 	git format-patch --cc="S E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch5 &&
 	grep "^Cc: R E Cipient <[email protected]>,\$" patch5 &&
@@ -178,7 +158,6 @@ test_expect_success 'additional command line cc (ascii)' '
 '
 
 test_expect_failure 'additional command line cc (rfc822)' '
-
 	git config --replace-all format.headers "Cc: R E Cipient <[email protected]>" &&
 	git format-patch --cc="S. E. Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch5 &&
 	grep "^Cc: R E Cipient <[email protected]>,\$" patch5 &&
@@ -186,14 +165,12 @@ test_expect_failure 'additional command line cc (rfc822)' '
 '
 
 test_expect_success 'command line headers' '
-
 	git config --unset-all format.headers &&
 	git format-patch --add-header="Cc: R E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch6 &&
 	grep "^Cc: R E Cipient <[email protected]>\$" patch6
 '
 
 test_expect_success 'configuration headers and command line headers' '
-
 	git config --replace-all format.headers "Cc: R E Cipient <[email protected]>" &&
 	git format-patch --add-header="Cc: S E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch7 &&
 	grep "^Cc: R E Cipient <[email protected]>,\$" patch7 &&
@@ -201,40 +178,34 @@ test_expect_success 'configuration headers and command line headers' '
 '
 
 test_expect_success 'command line To: header (ascii)' '
-
 	git config --unset-all format.headers &&
 	git format-patch --to="R E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
 	grep "^To: R E Cipient <[email protected]>\$" patch8
 '
 
 test_expect_failure 'command line To: header (rfc822)' '
-
 	git format-patch --to="R. E. Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
 	grep "^To: \"R. E. Cipient\" <[email protected]>\$" patch8
 '
 
 test_expect_failure 'command line To: header (rfc2047)' '
-
 	git format-patch --to="R Ä Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
 	grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected]>\$" patch8
 '
 
 test_expect_success 'configuration To: header (ascii)' '
-
 	git config format.to "R E Cipient <[email protected]>" &&
 	git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
 	grep "^To: R E Cipient <[email protected]>\$" patch9
 '
 
 test_expect_failure 'configuration To: header (rfc822)' '
-
 	git config format.to "R. E. Cipient <[email protected]>" &&
 	git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
 	grep "^To: \"R. E. Cipient\" <[email protected]>\$" patch9
 '
 
 test_expect_failure 'configuration To: header (rfc2047)' '
-
 	git config format.to "R Ä Cipient <[email protected]>" &&
 	git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
 	grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected]>\$" patch9
@@ -249,7 +220,6 @@ check_patch () {
 }
 
 test_expect_success 'format.from=false' '
-
 	git -c format.from=false format-patch --stdout master..side |
 	sed -e "/^\$/q" >patch &&
 	check_patch patch &&
@@ -257,7 +227,6 @@ test_expect_success 'format.from=false' '
 '
 
 test_expect_success 'format.from=true' '
-
 	git -c format.from=true format-patch --stdout master..side |
 	sed -e "/^\$/q" >patch &&
 	check_patch patch &&
@@ -265,7 +234,6 @@ test_expect_success 'format.from=true' '
 '
 
 test_expect_success 'format.from with address' '
-
 	git -c format.from="F R Om <[email protected]>" format-patch --stdout master..side |
 	sed -e "/^\$/q" >patch &&
 	check_patch patch &&
@@ -273,7 +241,6 @@ test_expect_success 'format.from with address' '
 '
 
 test_expect_success '--no-from overrides format.from' '
-
 	git -c format.from="F R Om <[email protected]>" format-patch --no-from --stdout master..side |
 	sed -e "/^\$/q" >patch &&
 	check_patch patch &&
@@ -281,7 +248,6 @@ test_expect_success '--no-from overrides format.from' '
 '
 
 test_expect_success '--from overrides format.from' '
-
 	git -c format.from="F R Om <[email protected]>" format-patch --from --stdout master..side |
 	sed -e "/^\$/q" >patch &&
 	check_patch patch &&
@@ -289,7 +255,6 @@ test_expect_success '--from overrides format.from' '
 '
 
 test_expect_success '--no-to overrides config.to' '
-
 	git config --replace-all format.to \
 		"R E Cipient <[email protected]>" &&
 	git format-patch --no-to --stdout master..side |
@@ -299,7 +264,6 @@ test_expect_success '--no-to overrides config.to' '
 '
 
 test_expect_success '--no-to and --to replaces config.to' '
-
 	git config --replace-all format.to \
 		"Someone <[email protected]>" &&
 	git format-patch --no-to --to="Someone Else <[email protected]>" \
@@ -311,7 +275,6 @@ test_expect_success '--no-to and --to replaces config.to' '
 '
 
 test_expect_success '--no-cc overrides config.cc' '
-
 	git config --replace-all format.cc \
 		"C E Cipient <[email protected]>" &&
 	git format-patch --no-cc --stdout master..side |
@@ -321,7 +284,6 @@ test_expect_success '--no-cc overrides config.cc' '
 '
 
 test_expect_success '--no-add-header overrides config.headers' '
-
 	git config --replace-all format.headers \
 		"Header1: B E Cipient <[email protected]>" &&
 	git format-patch --no-add-header --stdout master..side |
@@ -331,7 +293,6 @@ test_expect_success '--no-add-header overrides config.headers' '
 '
 
 test_expect_success 'multiple files' '
-
 	rm -rf patches/ &&
 	git checkout side &&
 	git format-patch -o patches/ master &&
@@ -594,7 +555,6 @@ test_expect_success 'thread config + --no-thread' '
 '
 
 test_expect_success 'excessive subject' '
-
 	rm -rf patches/ &&
 	git checkout side &&
 	before=$(git hash-object file) &&
@@ -622,7 +582,6 @@ test_expect_success 'cover-letter inherits diff options' '
 	! grep "file => foo .* 0 *\$" 0000-cover-letter.patch &&
 	git format-patch --cover-letter -1 -M &&
 	grep "file => foo .* 0 *\$" 0000-cover-letter.patch
-
 '
 
 cat > expect << EOF
@@ -636,11 +595,9 @@ cat > expect << EOF
 EOF
 
 test_expect_success 'shortlog of cover-letter wraps overly-long onelines' '
-
 	git format-patch --cover-letter -2 &&
 	sed -e "1,/A U Thor/d" -e "/^\$/q" < 0000-cover-letter.patch > output &&
 	test_cmp expect output
-
 '
 
 cat > expect << EOF
@@ -656,13 +613,11 @@ index $before..$after 100644
 EOF
 
 test_expect_success 'format-patch respects -U' '
-
 	git format-patch -U4 -2 &&
 	sed -e "1,/^diff/d" -e "/^+5/q" \
 		<0001-This-is-an-excessively-long-subject-line-for-a-messa.patch \
 		>output &&
 	test_cmp expect output
-
 '
 
 cat > expect << EOF
@@ -679,11 +634,9 @@ index $before..$after 100644
 EOF
 
 test_expect_success 'format-patch -p suppresses stat' '
-
 	git format-patch -p -2 &&
 	sed -e "1,/^\$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output &&
 	test_cmp expect output
-
 '
 
 test_expect_success 'format-patch from a subdirectory (1)' '
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#12 lore raw

PATCH v3 2/13 t4014: s/expected/expect/

In reply to Denton Liu

For test cases, the usual convention is to name expected output files "expect", not "expected". Replace all instances with "expected" with "expect" except for one case where the "expected" is used as the name of a test case.

---
 t/t4014-format-patch.sh | 106 ++++++++++++++++++++--------------------
 1 file changed, 53 insertions(+), 53 deletions(-)
t/t4014-format-patch.sh +53 -53
index 3ed3feabfe..62f5680f05 100755
@@ -1209,32 +1209,32 @@ append_signoff()
 
 test_expect_success 'signoff: commit with no body' '
 	append_signoff </dev/null >actual &&
-	cat <<\EOF | sed "s/EOL$//" >expected &&
+	cat <<\EOF | sed "s/EOL$//" >expect &&
 4:Subject: [PATCH] EOL
 8:
 9:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: commit with only subject' '
 	echo subject | append_signoff >actual &&
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 9:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: commit with only subject that does not end with NL' '
 	printf subject | append_signoff >actual &&
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 9:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: no existing signoffs' '
@@ -1243,24 +1243,24 @@ subject
 
 body
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
 11:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: no existing signoffs and no trailing NL' '
 	printf "subject\n\nbody" | append_signoff >actual &&
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
 11:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: some random signoff' '
@@ -1271,14 +1271,14 @@ body
 
 Signed-off-by: my@house
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
 11:Signed-off-by: my@house
 12:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: misc conforming footer elements' '
@@ -1292,14 +1292,14 @@ Signed-off-by: my@house
 Tested-by: Some One <[email protected]>
 Bug: 1234
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
 11:Signed-off-by: my@house
 15:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: some random signoff-alike' '
@@ -1309,13 +1309,13 @@ subject
 body
 Fooled-by-me: my@house
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 11:
 12:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: not really a signoff' '
@@ -1324,14 +1324,14 @@ subject
 
 I want to mention about Signed-off-by: here.
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 9:I want to mention about Signed-off-by: here.
 10:
 11:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: not really a signoff (2)' '
@@ -1341,13 +1341,13 @@ subject
 My unfortunate
 Signed-off-by: example happens to be wrapped here.
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:Signed-off-by: example happens to be wrapped here.
 11:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: valid S-o-b paragraph in the middle' '
@@ -1359,7 +1359,7 @@ Signed-off-by: your@house
 
 A lot of houses.
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 9:Signed-off-by: my@house
@@ -1368,7 +1368,7 @@ EOF
 13:
 14:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: the same signoff at the end' '
@@ -1379,24 +1379,24 @@ body
 
 Signed-off-by: C O Mitter <[email protected]>
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
 11:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: the same signoff at the end, no trailing NL' '
 	printf "subject\n\nSigned-off-by: C O Mitter <[email protected]>" |
 		append_signoff >actual &&
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 9:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: the same signoff NOT at the end' '
@@ -1408,14 +1408,14 @@ body
 Signed-off-by: C O Mitter <[email protected]>
 Signed-off-by: my@house
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
 11:Signed-off-by: C O Mitter <[email protected]>
 12:Signed-off-by: my@house
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: tolerate garbage in conforming footer' '
@@ -1428,13 +1428,13 @@ Tested-by: my@house
 Some Trash
 Signed-off-by: C O Mitter <[email protected]>
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
 13:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: respect trailer config' '
@@ -1444,13 +1444,13 @@ subject
 Myfooter: x
 Some Trash
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 11:
 12:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual &&
+	test_cmp expect actual &&
 
 	test_config trailer.Myfooter.ifexists add &&
 	append_signoff <<\EOF >actual &&
@@ -1459,12 +1459,12 @@ subject
 Myfooter: x
 Some Trash
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 11:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: footer begins with non-signoff without @ sign' '
@@ -1479,13 +1479,13 @@ Change-id: Ideadbeef
 Signed-off-by: C O Mitter <[email protected]>
 Bug: 1234
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
 14:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'format patch ignores color.ui' '
@@ -1604,13 +1604,13 @@ test_expect_success 'format-patch --base' '
 	git checkout patchid &&
 	git format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual1 &&
 	git format-patch --stdout --base=HEAD~3 HEAD~.. | tail -n 7 >actual2 &&
-	echo >expected &&
-	echo "base-commit: $(git rev-parse HEAD~3)" >>expected &&
-	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expected &&
-	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expected &&
-	signature >> expected &&
-	test_cmp expected actual1 &&
-	test_cmp expected actual2 &&
+	echo >expect &&
+	echo "base-commit: $(git rev-parse HEAD~3)" >>expect &&
+	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expect &&
+	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expect &&
+	signature >> expect &&
+	test_cmp expect actual1 &&
+	test_cmp expect actual2 &&
 	echo >fail &&
 	echo "base-commit: $(git rev-parse HEAD~3)" >>fail &&
 	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --unstable | awk "{print \$1}")" >>fail &&
@@ -1625,8 +1625,8 @@ test_expect_success 'format-patch --base errors out when base commit is in revis
 	test_must_fail git format-patch --base=HEAD~1 -2 &&
 	git format-patch --stdout --base=HEAD~2 -2 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse HEAD~2)" >expected &&
-	test_cmp expected actual
+	echo "base-commit: $(git rev-parse HEAD~2)" >expect &&
+	test_cmp expect actual
 '
 
 test_expect_success 'format-patch --base errors out when base commit is not ancestor of revision list' '
@@ -1652,8 +1652,8 @@ test_expect_success 'format-patch --base errors out when base commit is not ance
 	test_must_fail git format-patch --base=$(cat commit-id-Z) -3 &&
 	git format-patch --stdout --base=$(cat commit-id-base) -3 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(cat commit-id-base)" >expected &&
-	test_cmp expected actual
+	echo "base-commit: $(cat commit-id-base)" >expect &&
+	test_cmp expect actual
 '
 
 test_expect_success 'format-patch --base=auto' '
@@ -1664,8 +1664,8 @@ test_expect_success 'format-patch --base=auto' '
 	test_commit N2 &&
 	git format-patch --stdout --base=auto -2 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse upstream)" >expected &&
-	test_cmp expected actual
+	echo "base-commit: $(git rev-parse upstream)" >expect &&
+	test_cmp expect actual
 '
 
 test_expect_success 'format-patch errors out when history involves criss-cross' '
@@ -1701,8 +1701,8 @@ test_expect_success 'format-patch format.useAutoBaseoption' '
 	git config format.useAutoBase true &&
 	git format-patch --stdout -1 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse upstream)" >expected &&
-	test_cmp expected actual
+	echo "base-commit: $(git rev-parse upstream)" >expect &&
+	test_cmp expect actual
 '
 
 test_expect_success 'format-patch --base overrides format.useAutoBase' '
@@ -1710,8 +1710,8 @@ test_expect_success 'format-patch --base overrides format.useAutoBase' '
 	git config format.useAutoBase true &&
 	git format-patch --stdout --base=HEAD~1 -1 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse HEAD~1)" >expected &&
-	test_cmp expected actual
+	echo "base-commit: $(git rev-parse HEAD~1)" >expect &&
+	test_cmp expect actual
 '
 
 test_expect_success 'format-patch --base with --attach' '
Signature · 1 line
2.23.0.248.g3a9dd8fb08
#13 lore raw

Re: [PATCH v3 02/13] t4014: s/expected/expect/

Quoted 2 lines · Denton Liu

For test cases, the usual convention is to name expected output files "expect", not "expected". Replace all instances with "expected" with

s/with "expected"/of "expected"/

Quoted 4 lines

"expect" except for one case where the "expected" is used as the name of a test case.

author
#14 lore raw

PATCH v3 3/13 t4014: move closing sq onto its own line

In reply to Denton Liu

The usual convention for test cases is for the closing sq to be on its own line. Move the sq onto its own line for cases that do not conform to this style.

---
 t/t4014-format-patch.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
t/t4014-format-patch.sh +4 -2
index 62f5680f05..5e8eb6fb27 100755
@@ -790,11 +790,13 @@ test_expect_success 'options no longer allowed for format-patch' '
 	test_must_fail git format-patch --name-status 2> output &&
 	test_i18ncmp expect.name-status output &&
 	test_must_fail git format-patch --check 2> output &&
-	test_i18ncmp expect.check output'
+	test_i18ncmp expect.check output
+'
 
 test_expect_success 'format-patch --numstat should produce a patch' '
 	git format-patch --numstat --stdout master..side > output &&
-	test 5 = $(grep "^diff --git a/" output | wc -l)'
+	test 5 = $(grep "^diff --git a/" output | wc -l)
+'
 
 test_expect_success 'format-patch -- <path>' '
 	git format-patch master..side -- file 2>error &&
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#15 lore raw

PATCH v3 4/13 t4014: use sq for test case names

In reply to Denton Liu

The usual convention is for test case names to be written between single-quotes. Change all double-quoted test case names to single-quotes except for one test case name that uses a sq for a contraction.

---
 t/t4014-format-patch.sh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
t/t4014-format-patch.sh +5 -5
index 5e8eb6fb27..a7b440b003 100755
@@ -58,20 +58,20 @@ test_expect_success setup '
 	git checkout master
 '
 
-test_expect_success "format-patch --ignore-if-in-upstream" '
+test_expect_success 'format-patch --ignore-if-in-upstream' '
 	git format-patch --stdout master..side >patch0 &&
 	cnt=$(grep "^From " patch0 | wc -l) &&
 	test $cnt = 3
 '
 
-test_expect_success "format-patch --ignore-if-in-upstream" '
+test_expect_success 'format-patch --ignore-if-in-upstream' '
 	git format-patch --stdout \
 		--ignore-if-in-upstream master..side >patch1 &&
 	cnt=$(grep "^From " patch1 | wc -l) &&
 	test $cnt = 2
 '
 
-test_expect_success "format-patch --ignore-if-in-upstream handles tags" '
+test_expect_success 'format-patch --ignore-if-in-upstream handles tags' '
 	git tag -a v1 -m tag side &&
 	git tag -a v2 -m tag master &&
 	git format-patch --stdout --ignore-if-in-upstream v2..v1 >patch1 &&
@@ -94,14 +94,14 @@ test_expect_success "format-patch doesn't consider merge commits" '
 	test $cnt = 3
 '
 
-test_expect_success "format-patch result applies" '
+test_expect_success 'format-patch result applies' '
 	git checkout -b rebuild-0 master &&
 	git am -3 patch0 &&
 	cnt=$(git rev-list master.. | wc -l) &&
 	test $cnt = 2
 '
 
-test_expect_success "format-patch --ignore-if-in-upstream result applies" '
+test_expect_success 'format-patch --ignore-if-in-upstream result applies' '
 	git checkout -b rebuild-1 master &&
 	git am -3 patch1 &&
 	cnt=$(git rev-list master.. | wc -l) &&
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#16 lore raw

PATCH v3 5/13 t4014: remove spaces after redirect operators

In reply to Denton Liu

For shell scripts, the usual convention is for there to be no space after redirection operators, (e.g. >file, not > file). Remove these spaces wherever they appear.

---
 t/t4014-format-patch.sh | 62 ++++++++++++++++++++---------------------
 1 file changed, 31 insertions(+), 31 deletions(-)
t/t4014-format-patch.sh +31 -31
index a7b440b003..075affb1e5 100755
@@ -126,8 +126,8 @@ test_expect_success 'extra headers' '
 " &&
 	git config --add format.headers "Cc: S E Cipient <[email protected]>
 " &&
-	git format-patch --stdout master..side > patch2 &&
-	sed -e "/^\$/q" patch2 > hdrs2 &&
+	git format-patch --stdout master..side >patch2 &&
+	sed -e "/^\$/q" patch2 >hdrs2 &&
 	grep "^To: R E Cipient <[email protected]>\$" hdrs2 &&
 	grep "^Cc: S E Cipient <[email protected]>\$" hdrs2
 '
@@ -136,7 +136,7 @@ test_expect_success 'extra headers without newlines' '
 	git config --replace-all format.headers "To: R E Cipient <[email protected]>" &&
 	git config --add format.headers "Cc: S E Cipient <[email protected]>" &&
 	git format-patch --stdout master..side >patch3 &&
-	sed -e "/^\$/q" patch3 > hdrs3 &&
+	sed -e "/^\$/q" patch3 >hdrs3 &&
 	grep "^To: R E Cipient <[email protected]>\$" hdrs3 &&
 	grep "^Cc: S E Cipient <[email protected]>\$" hdrs3
 '
@@ -144,8 +144,8 @@ test_expect_success 'extra headers without newlines' '
 test_expect_success 'extra headers with multiple To:s' '
 	git config --replace-all format.headers "To: R E Cipient <[email protected]>" &&
 	git config --add format.headers "To: S E Cipient <[email protected]>" &&
-	git format-patch --stdout master..side > patch4 &&
-	sed -e "/^\$/q" patch4 > hdrs4 &&
+	git format-patch --stdout master..side >patch4 &&
+	sed -e "/^\$/q" patch4 >hdrs4 &&
 	grep "^To: R E Cipient <[email protected]>,\$" hdrs4 &&
 	grep "^ *S E Cipient <[email protected]>\$" hdrs4
 '
@@ -318,7 +318,7 @@ test_expect_success 'reroll count (-v)' '
 check_threading () {
 	expect="$1" &&
 	shift &&
-	(git format-patch --stdout "$@"; echo $? > status.out) |
+	(git format-patch --stdout "$@"; echo $? >status.out) |
 	# Prints everything between the Message-ID and In-Reply-To,
 	# and replaces all Message-ID-lookalikes by a sequence number
 	perl -ne '
@@ -333,12 +333,12 @@ check_threading () {
 			print;
 		}
 		print "---\n" if /^From /i;
-	' > actual &&
+	' >actual &&
 	test 0 = "$(cat status.out)" &&
 	test_cmp "$expect" actual
 }
 
-cat >> expect.no-threading <<EOF
+cat >>expect.no-threading <<EOF
 ---
 ---
 ---
@@ -349,7 +349,7 @@ test_expect_success 'no threading' '
 	check_threading expect.no-threading master
 '
 
-cat > expect.thread <<EOF
+cat >expect.thread <<EOF
 ---
 Message-Id: <0>
 ---
@@ -366,7 +366,7 @@ test_expect_success 'thread' '
 	check_threading expect.thread --thread master
 '
 
-cat > expect.in-reply-to <<EOF
+cat >expect.in-reply-to <<EOF
 ---
 Message-Id: <0>
 In-Reply-To: <1>
@@ -386,7 +386,7 @@ test_expect_success 'thread in-reply-to' '
 		--thread master
 '
 
-cat > expect.cover-letter <<EOF
+cat >expect.cover-letter <<EOF
 ---
 Message-Id: <0>
 ---
@@ -407,7 +407,7 @@ test_expect_success 'thread cover-letter' '
 	check_threading expect.cover-letter --cover-letter --thread master
 '
 
-cat > expect.cl-irt <<EOF
+cat >expect.cl-irt <<EOF
 ---
 Message-Id: <0>
 In-Reply-To: <1>
@@ -439,7 +439,7 @@ test_expect_success 'thread explicit shallow' '
 		--in-reply-to="<test.message>" --thread=shallow master
 '
 
-cat > expect.deep <<EOF
+cat >expect.deep <<EOF
 ---
 Message-Id: <0>
 ---
@@ -457,7 +457,7 @@ test_expect_success 'thread deep' '
 	check_threading expect.deep --thread=deep master
 '
 
-cat > expect.deep-irt <<EOF
+cat >expect.deep-irt <<EOF
 ---
 Message-Id: <0>
 In-Reply-To: <1>
@@ -480,7 +480,7 @@ test_expect_success 'thread deep in-reply-to' '
 		--in-reply-to="<test.message>" master
 '
 
-cat > expect.deep-cl <<EOF
+cat >expect.deep-cl <<EOF
 ---
 Message-Id: <0>
 ---
@@ -504,7 +504,7 @@ test_expect_success 'thread deep cover-letter' '
 	check_threading expect.deep-cl --cover-letter --thread=deep master
 '
 
-cat > expect.deep-cl-irt <<EOF
+cat >expect.deep-cl-irt <<EOF
 ---
 Message-Id: <0>
 In-Reply-To: <1>
@@ -584,7 +584,7 @@ test_expect_success 'cover-letter inherits diff options' '
 	grep "file => foo .* 0 *\$" 0000-cover-letter.patch
 '
 
-cat > expect << EOF
+cat >expect <<EOF
   This is an excessively long subject line for a message due to the
     habit some projects have of not having a short, one-line subject at
     the start of the commit message, but rather sticking a whole
@@ -596,11 +596,11 @@ EOF
 
 test_expect_success 'shortlog of cover-letter wraps overly-long onelines' '
 	git format-patch --cover-letter -2 &&
-	sed -e "1,/A U Thor/d" -e "/^\$/q" < 0000-cover-letter.patch > output &&
+	sed -e "1,/A U Thor/d" -e "/^\$/q" <0000-cover-letter.patch >output &&
 	test_cmp expect output
 '
 
-cat > expect << EOF
+cat >expect <<EOF
 index $before..$after 100644
 --- a/file
 +++ b/file
@@ -620,7 +620,7 @@ test_expect_success 'format-patch respects -U' '
 	test_cmp expect output
 '
 
-cat > expect << EOF
+cat >expect <<EOF
 
 diff --git a/file b/file
 index $before..$after 100644
@@ -635,7 +635,7 @@ EOF
 
 test_expect_success 'format-patch -p suppresses stat' '
 	git format-patch -p -2 &&
-	sed -e "1,/^\$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output &&
+	sed -e "1,/^\$/d" -e "/^+5/q" <0001-This-is-an-excessively-long-subject-line-for-a-messa.patch >output &&
 	test_cmp expect output
 '
 
@@ -689,7 +689,7 @@ test_expect_success 'format-patch from a subdirectory (3)' '
 '
 
 test_expect_success 'format-patch --in-reply-to' '
-	git format-patch -1 --stdout --in-reply-to "[email protected]" > patch8 &&
+	git format-patch -1 --stdout --in-reply-to "[email protected]" >patch8 &&
 	grep "^In-Reply-To: <[email protected]>" patch8 &&
 	grep "^References: <[email protected]>" patch8
 '
@@ -780,21 +780,21 @@ test_expect_success 'format-patch with multiple notes refs' '
 	! grep "this is note 2" out
 '
 
-echo "fatal: --name-only does not make sense" > expect.name-only
-echo "fatal: --name-status does not make sense" > expect.name-status
-echo "fatal: --check does not make sense" > expect.check
+echo "fatal: --name-only does not make sense" >expect.name-only
+echo "fatal: --name-status does not make sense" >expect.name-status
+echo "fatal: --check does not make sense" >expect.check
 
 test_expect_success 'options no longer allowed for format-patch' '
-	test_must_fail git format-patch --name-only 2> output &&
+	test_must_fail git format-patch --name-only 2>output &&
 	test_i18ncmp expect.name-only output &&
-	test_must_fail git format-patch --name-status 2> output &&
+	test_must_fail git format-patch --name-status 2>output &&
 	test_i18ncmp expect.name-status output &&
-	test_must_fail git format-patch --check 2> output &&
+	test_must_fail git format-patch --check 2>output &&
 	test_i18ncmp expect.check output
 '
 
 test_expect_success 'format-patch --numstat should produce a patch' '
-	git format-patch --numstat --stdout master..side > output &&
+	git format-patch --numstat --stdout master..side >output &&
 	test 5 = $(grep "^diff --git a/" output | wc -l)
 '
 
@@ -1610,14 +1610,14 @@ test_expect_success 'format-patch --base' '
 	echo "base-commit: $(git rev-parse HEAD~3)" >>expect &&
 	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expect &&
 	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expect &&
-	signature >> expect &&
+	signature >>expect &&
 	test_cmp expect actual1 &&
 	test_cmp expect actual2 &&
 	echo >fail &&
 	echo "base-commit: $(git rev-parse HEAD~3)" >>fail &&
 	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --unstable | awk "{print \$1}")" >>fail &&
 	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --unstable | awk "{print \$1}")" >>fail &&
-	signature >> fail &&
+	signature >>fail &&
 	! test_cmp fail actual1 &&
 	! test_cmp fail actual2
 '
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#17 lore raw

PATCH v3 6/13 t4014: use indentable here-docs

In reply to Denton Liu

The convention is to use indentable here-docs within test cases so that the here-docs line up with the rest of the code within the test case. Change here-docs from <<\EOF to <<-\EOF so that they can be indented along with the rest of the test case.

---
 t/t4014-format-patch.sh | 368 ++++++++++++++++++++--------------------
 1 file changed, 184 insertions(+), 184 deletions(-)
t/t4014-format-patch.sh +184 -184
index 075affb1e5..c07d868491 100755
@@ -1211,282 +1211,282 @@ append_signoff()
 
 test_expect_success 'signoff: commit with no body' '
 	append_signoff </dev/null >actual &&
-	cat <<\EOF | sed "s/EOL$//" >expect &&
-4:Subject: [PATCH] EOL
-8:
-9:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	cat <<-\EOF | sed "s/EOL$//" >expect &&
+	4:Subject: [PATCH] EOL
+	8:
+	9:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: commit with only subject' '
 	echo subject | append_signoff >actual &&
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-9:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	9:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: commit with only subject that does not end with NL' '
 	printf subject | append_signoff >actual &&
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-9:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	9:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: no existing signoffs' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-11:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	body
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	11:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: no existing signoffs and no trailing NL' '
 	printf "subject\n\nbody" | append_signoff >actual &&
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-11:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	11:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: some random signoff' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
+	body
 
-Signed-off-by: my@house
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-11:Signed-off-by: my@house
-12:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	Signed-off-by: my@house
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	11:Signed-off-by: my@house
+	12:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: misc conforming footer elements' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
+	body
 
-Signed-off-by: my@house
-(cherry picked from commit da39a3ee5e6b4b0d3255bfef95601890afd80709)
-Tested-by: Some One <[email protected]>
-Bug: 1234
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-11:Signed-off-by: my@house
-15:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	Signed-off-by: my@house
+	(cherry picked from commit da39a3ee5e6b4b0d3255bfef95601890afd80709)
+	Tested-by: Some One <[email protected]>
+	Bug: 1234
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	11:Signed-off-by: my@house
+	15:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: some random signoff-alike' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
-Fooled-by-me: my@house
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-11:
-12:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	body
+	Fooled-by-me: my@house
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	11:
+	12:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: not really a signoff' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-I want to mention about Signed-off-by: here.
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-9:I want to mention about Signed-off-by: here.
-10:
-11:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	I want to mention about Signed-off-by: here.
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	9:I want to mention about Signed-off-by: here.
+	10:
+	11:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: not really a signoff (2)' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-My unfortunate
-Signed-off-by: example happens to be wrapped here.
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:Signed-off-by: example happens to be wrapped here.
-11:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	My unfortunate
+	Signed-off-by: example happens to be wrapped here.
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:Signed-off-by: example happens to be wrapped here.
+	11:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: valid S-o-b paragraph in the middle' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-Signed-off-by: my@house
-Signed-off-by: your@house
+	Signed-off-by: my@house
+	Signed-off-by: your@house
 
-A lot of houses.
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-9:Signed-off-by: my@house
-10:Signed-off-by: your@house
-11:
-13:
-14:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	A lot of houses.
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	9:Signed-off-by: my@house
+	10:Signed-off-by: your@house
+	11:
+	13:
+	14:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: the same signoff at the end' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
+	body
 
-Signed-off-by: C O Mitter <[email protected]>
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-11:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	11:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: the same signoff at the end, no trailing NL' '
 	printf "subject\n\nSigned-off-by: C O Mitter <[email protected]>" |
 		append_signoff >actual &&
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-9:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	9:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: the same signoff NOT at the end' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
+	body
 
-Signed-off-by: C O Mitter <[email protected]>
-Signed-off-by: my@house
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-11:Signed-off-by: C O Mitter <[email protected]>
-12:Signed-off-by: my@house
-EOF
+	Signed-off-by: C O Mitter <[email protected]>
+	Signed-off-by: my@house
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	11:Signed-off-by: C O Mitter <[email protected]>
+	12:Signed-off-by: my@house
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: tolerate garbage in conforming footer' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
+	body
 
-Tested-by: my@house
-Some Trash
-Signed-off-by: C O Mitter <[email protected]>
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-13:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	Tested-by: my@house
+	Some Trash
+	Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	13:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: respect trailer config' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-Myfooter: x
-Some Trash
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-11:
-12:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	Myfooter: x
+	Some Trash
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	11:
+	12:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual &&
 
 	test_config trailer.Myfooter.ifexists add &&
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-Myfooter: x
-Some Trash
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-11:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	Myfooter: x
+	Some Trash
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	11:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: footer begins with non-signoff without @ sign' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
+	body
 
-Reviewed-id: Noone
-Tested-by: my@house
-Change-id: Ideadbeef
-Signed-off-by: C O Mitter <[email protected]>
-Bug: 1234
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-14:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	Reviewed-id: Noone
+	Tested-by: my@house
+	Change-id: Ideadbeef
+	Signed-off-by: C O Mitter <[email protected]>
+	Bug: 1234
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	14:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#18 lore raw

PATCH v3 7/13 t4014: drop redirections to /dev/null

In reply to Denton Liu

Since output is silenced when running without -v and debugging output is useful with -v, remove redirections to /dev/null as it is not useful.

---
 t/t4014-format-patch.sh | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
t/t4014-format-patch.sh +6 -6
index c07d868491..2048fb2008 100755
@@ -1502,42 +1502,42 @@ test_expect_success 'cover letter using branch description (1)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
 	git format-patch --stdout --cover-letter master >actual &&
-	grep hello actual >/dev/null
+	grep hello actual
 '
 
 test_expect_success 'cover letter using branch description (2)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
 	git format-patch --stdout --cover-letter rebuild-1~2..rebuild-1 >actual &&
-	grep hello actual >/dev/null
+	grep hello actual
 '
 
 test_expect_success 'cover letter using branch description (3)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
 	git format-patch --stdout --cover-letter ^master rebuild-1 >actual &&
-	grep hello actual >/dev/null
+	grep hello actual
 '
 
 test_expect_success 'cover letter using branch description (4)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
 	git format-patch --stdout --cover-letter master.. >actual &&
-	grep hello actual >/dev/null
+	grep hello actual
 '
 
 test_expect_success 'cover letter using branch description (5)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
 	git format-patch --stdout --cover-letter -2 HEAD >actual &&
-	grep hello actual >/dev/null
+	grep hello actual
 '
 
 test_expect_success 'cover letter using branch description (6)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
 	git format-patch --stdout --cover-letter -2 >actual &&
-	grep hello actual >/dev/null
+	grep hello actual
 '
 
 test_expect_success 'cover letter with nothing' '
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#19 lore raw

PATCH v3 8/13 t4014: use test_line_count() where possible

In reply to Denton Liu

Convert all instances of cnt=$(... | wc -l) && test $cnt = N into uses of test_line_count().

While we're at it, convert one instance of a Git command upstream of a pipe into two commands. This prevents a failure of a Git command from being masked since only the return code of the last member of the pipe is shown.

---
 t/t4014-format-patch.sh | 35 +++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)
t/t4014-format-patch.sh +19 -16
index 2048fb2008..176af4b902 100755
@@ -60,23 +60,23 @@ test_expect_success setup '
 
 test_expect_success 'format-patch --ignore-if-in-upstream' '
 	git format-patch --stdout master..side >patch0 &&
-	cnt=$(grep "^From " patch0 | wc -l) &&
-	test $cnt = 3
+	grep "^From " patch0 >from0 &&
+	test_line_count = 3 from0
 '
 
 test_expect_success 'format-patch --ignore-if-in-upstream' '
 	git format-patch --stdout \
 		--ignore-if-in-upstream master..side >patch1 &&
-	cnt=$(grep "^From " patch1 | wc -l) &&
-	test $cnt = 2
+	grep "^From " patch1 >from1 &&
+	test_line_count = 2 from1
 '
 
 test_expect_success 'format-patch --ignore-if-in-upstream handles tags' '
 	git tag -a v1 -m tag side &&
 	git tag -a v2 -m tag master &&
 	git format-patch --stdout --ignore-if-in-upstream v2..v1 >patch1 &&
-	cnt=$(grep "^From " patch1 | wc -l) &&
-	test $cnt = 2
+	grep "^From " patch1 >from1 &&
+	test_line_count = 2 from1
 '
 
 test_expect_success "format-patch doesn't consider merge commits" '
@@ -90,22 +90,23 @@ test_expect_success "format-patch doesn't consider merge commits" '
 	git checkout -b merger master &&
 	test_tick &&
 	git merge --no-ff slave &&
-	cnt=$(git format-patch -3 --stdout | grep "^From " | wc -l) &&
-	test $cnt = 3
+	git format-patch -3 --stdout >patch &&
+	grep "^From " patch >from &&
+	test_line_count = 3 from
 '
 
 test_expect_success 'format-patch result applies' '
 	git checkout -b rebuild-0 master &&
 	git am -3 patch0 &&
-	cnt=$(git rev-list master.. | wc -l) &&
-	test $cnt = 2
+	git rev-list master.. >list &&
+	test_line_count = 2 list
 '
 
 test_expect_success 'format-patch --ignore-if-in-upstream result applies' '
 	git checkout -b rebuild-1 master &&
 	git am -3 patch1 &&
-	cnt=$(git rev-list master.. | wc -l) &&
-	test $cnt = 2
+	git rev-list master.. >list &&
+	test_line_count = 2 list
 '
 
 test_expect_success 'commit did not screw up the log message' '
@@ -795,7 +796,8 @@ test_expect_success 'options no longer allowed for format-patch' '
 
 test_expect_success 'format-patch --numstat should produce a patch' '
 	git format-patch --numstat --stdout master..side >output &&
-	test 5 = $(grep "^diff --git a/" output | wc -l)
+	grep "^diff --git a/" output >diff &&
+	test_line_count = 5 diff
 '
 
 test_expect_success 'format-patch -- <path>' '
@@ -852,8 +854,8 @@ test_expect_success 'format-patch --signature --cover-letter' '
 	git config --unset-all format.signature &&
 	git format-patch --stdout --signature="my sig" --cover-letter \
 		-1 >output &&
-	grep "my sig" output &&
-	test 2 = $(grep "my sig" output | wc -l)
+	grep "my sig" output >sig &&
+	test_line_count = 2 sig
 '
 
 test_expect_success 'format.signature="" suppresses signatures' '
@@ -1591,7 +1593,8 @@ test_expect_success 'format-patch format.outputDirectory option' '
 	test_config format.outputDirectory patches &&
 	rm -fr patches &&
 	git format-patch master..side &&
-	test $(git rev-list master..side | wc -l) -eq $(ls patches | wc -l)
+	git rev-list master..side >list &&
+	test_line_count = $(ls patches | wc -l) list
 '
 
 test_expect_success 'format-patch -o overrides format.outputDirectory' '
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#20 lore raw

PATCH v3 9/13 t4014: remove confusing pipe in check_threading()

In reply to Denton Liu

In check_threading(), there was a Git command in the upstream of a pipe. In order to not lose its status code, it was saved into a file. However, this may be confusing so rewrite to redirect IO to file. This allows us to directly use the conventional &&-chain.

---
 t/t4014-format-patch.sh | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
t/t4014-format-patch.sh +2 -3
index 176af4b902..7f74948e2c 100755
@@ -319,7 +319,7 @@ test_expect_success 'reroll count (-v)' '
 check_threading () {
 	expect="$1" &&
 	shift &&
-	(git format-patch --stdout "$@"; echo $? >status.out) |
+	git format-patch --stdout "$@" >patch &&
 	# Prints everything between the Message-ID and In-Reply-To,
 	# and replaces all Message-ID-lookalikes by a sequence number
 	perl -ne '
@@ -334,8 +334,7 @@ check_threading () {
 			print;
 		}
 		print "---\n" if /^From /i;
-	' >actual &&
-	test 0 = "$(cat status.out)" &&
+	' <patch >actual &&
 	test_cmp "$expect" actual
 }
 
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#21 lore raw

PATCH v3 10/13 t4014: stop losing return codes of git commands

In reply to Denton Liu

Currently, there are two ways where the return codes of Git commands are lost. The first way is when a command is in the upstream of a pipe. In a pipe, only the return code of the last command is used. Thus, all other commands will have their return codes masked. Rewrite pipes so that there are no Git commands upstream.

The other way is when a command is in a non-assignment subshell. The return code will be lost in favour of the surrounding command's. Rewrite instances of this such that Git commands output to a file and surrounding commands only call subshells with non-Git commands.

---
 t/t4014-format-patch.sh | 196 ++++++++++++++++++++++++----------------
 1 file changed, 119 insertions(+), 77 deletions(-)
t/t4014-format-patch.sh +119 -77
index 7f74948e2c..7b8c8fe136 100755
@@ -33,7 +33,8 @@ test_expect_success setup '
 	git commit -m "Side changes #3 with \\n backslash-n in it." &&
 
 	git checkout master &&
-	git diff-tree -p C2 | git apply --index &&
+	git diff-tree -p C2 >patch &&
+	git apply --index <patch &&
 	test_tick &&
 	git commit -m "Master accepts moral equivalent of #2" &&
 
@@ -110,7 +111,8 @@ test_expect_success 'format-patch --ignore-if-in-upstream result applies' '
 '
 
 test_expect_success 'commit did not screw up the log message' '
-	git cat-file commit side | grep "^Side .* with .* backslash-n"
+	git cat-file commit side >actual &&
+	grep "^Side .* with .* backslash-n" actual
 '
 
 test_expect_success 'format-patch did not screw up the log message' '
@@ -119,7 +121,8 @@ test_expect_success 'format-patch did not screw up the log message' '
 '
 
 test_expect_success 'replay did not screw up the log message' '
-	git cat-file commit rebuild-1 | grep "^Side .* with .* backslash-n"
+	git cat-file commit rebuild-1 >actual &&
+	grep "^Side .* with .* backslash-n" actual
 '
 
 test_expect_success 'extra headers' '
@@ -153,63 +156,73 @@ test_expect_success 'extra headers with multiple To:s' '
 
 test_expect_success 'additional command line cc (ascii)' '
 	git config --replace-all format.headers "Cc: R E Cipient <[email protected]>" &&
-	git format-patch --cc="S E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch5 &&
-	grep "^Cc: R E Cipient <[email protected]>,\$" patch5 &&
-	grep "^ *S E Cipient <[email protected]>\$" patch5
+	git format-patch --cc="S E Cipient <[email protected]>" --stdout master..side >patch5 &&
+	sed -e "/^\$/q" patch5 >hdrs5 &&
+	grep "^Cc: R E Cipient <[email protected]>,\$" hdrs5 &&
+	grep "^ *S E Cipient <[email protected]>\$" hdrs5
 '
 
 test_expect_failure 'additional command line cc (rfc822)' '
 	git config --replace-all format.headers "Cc: R E Cipient <[email protected]>" &&
-	git format-patch --cc="S. E. Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch5 &&
-	grep "^Cc: R E Cipient <[email protected]>,\$" patch5 &&
-	grep "^ *\"S. E. Cipient\" <[email protected]>\$" patch5
+	git format-patch --cc="S. E. Cipient <[email protected]>" --stdout master..side >patch5 &&
+	sed -e "/^\$/q" patch5 >hdrs5 &&
+	grep "^Cc: R E Cipient <[email protected]>,\$" hdrs5 &&
+	grep "^ *\"S. E. Cipient\" <[email protected]>\$" hdrs5
 '
 
 test_expect_success 'command line headers' '
 	git config --unset-all format.headers &&
-	git format-patch --add-header="Cc: R E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch6 &&
-	grep "^Cc: R E Cipient <[email protected]>\$" patch6
+	git format-patch --add-header="Cc: R E Cipient <[email protected]>" --stdout master..side >patch6 &&
+	sed -e "/^\$/q" patch6 >hdrs6 &&
+	grep "^Cc: R E Cipient <[email protected]>\$" hdrs6
 '
 
 test_expect_success 'configuration headers and command line headers' '
 	git config --replace-all format.headers "Cc: R E Cipient <[email protected]>" &&
-	git format-patch --add-header="Cc: S E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch7 &&
-	grep "^Cc: R E Cipient <[email protected]>,\$" patch7 &&
-	grep "^ *S E Cipient <[email protected]>\$" patch7
+	git format-patch --add-header="Cc: S E Cipient <[email protected]>" --stdout master..side >patch7 &&
+	sed -e "/^\$/q" patch7 >hdrs7 &&
+	grep "^Cc: R E Cipient <[email protected]>,\$" hdrs7 &&
+	grep "^ *S E Cipient <[email protected]>\$" hdrs7
 '
 
 test_expect_success 'command line To: header (ascii)' '
 	git config --unset-all format.headers &&
-	git format-patch --to="R E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
-	grep "^To: R E Cipient <[email protected]>\$" patch8
+	git format-patch --to="R E Cipient <[email protected]>" --stdout master..side >patch8 &&
+	sed -e "/^\$/q" patch8 >hdrs8 &&
+	grep "^To: R E Cipient <[email protected]>\$" hdrs8
 '
 
 test_expect_failure 'command line To: header (rfc822)' '
-	git format-patch --to="R. E. Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
-	grep "^To: \"R. E. Cipient\" <[email protected]>\$" patch8
+	git format-patch --to="R. E. Cipient <[email protected]>" --stdout master..side >patch8 &&
+	sed -e "/^\$/q" patch8 >hdrs8 &&
+	grep "^To: \"R. E. Cipient\" <[email protected]>\$" hdrs8
 '
 
 test_expect_failure 'command line To: header (rfc2047)' '
-	git format-patch --to="R Ä Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
-	grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected]>\$" patch8
+	git format-patch --to="R Ä Cipient <[email protected]>" --stdout master..side >patch8 &&
+	sed -e "/^\$/q" patch8 >hdrs8 &&
+	grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected]>\$" hdrs8
 '
 
 test_expect_success 'configuration To: header (ascii)' '
 	git config format.to "R E Cipient <[email protected]>" &&
-	git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
-	grep "^To: R E Cipient <[email protected]>\$" patch9
+	git format-patch --stdout master..side >patch9 &&
+	sed -e "/^\$/q" patch9 >hdrs9 &&
+	grep "^To: R E Cipient <[email protected]>\$" hdrs9
 '
 
 test_expect_failure 'configuration To: header (rfc822)' '
 	git config format.to "R. E. Cipient <[email protected]>" &&
-	git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
-	grep "^To: \"R. E. Cipient\" <[email protected]>\$" patch9
+	git format-patch --stdout master..side >patch9 &&
+	sed -e "/^\$/q" patch9 >hdrs9 &&
+	grep "^To: \"R. E. Cipient\" <[email protected]>\$" hdrs9
 '
 
 test_expect_failure 'configuration To: header (rfc2047)' '
 	git config format.to "R Ä Cipient <[email protected]>" &&
-	git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
-	grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected]>\$" patch9
+	git format-patch --stdout master..side >patch9 &&
+	sed -e "/^\$/q" patch9 >hdrs9 &&
+	grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected]>\$" hdrs9
 '
 
 # check_patch <patch>: Verify that <patch> looks like a half-sane
@@ -221,76 +234,76 @@ check_patch () {
 }
 
 test_expect_success 'format.from=false' '
-	git -c format.from=false format-patch --stdout master..side |
-	sed -e "/^\$/q" >patch &&
+	git -c format.from=false format-patch --stdout master..side >patch &&
+	sed -e "/^\$/q" patch >hdrs &&
 	check_patch patch &&
-	! grep "^From: C O Mitter <[email protected]>\$" patch
+	! grep "^From: C O Mitter <[email protected]>\$" hdrs
 '
 
 test_expect_success 'format.from=true' '
-	git -c format.from=true format-patch --stdout master..side |
-	sed -e "/^\$/q" >patch &&
-	check_patch patch &&
-	grep "^From: C O Mitter <[email protected]>\$" patch
+	git -c format.from=true format-patch --stdout master..side >patch &&
+	sed -e "/^\$/q" patch >hdrs &&
+	check_patch hdrs &&
+	grep "^From: C O Mitter <[email protected]>\$" hdrs
 '
 
 test_expect_success 'format.from with address' '
-	git -c format.from="F R Om <[email protected]>" format-patch --stdout master..side |
-	sed -e "/^\$/q" >patch &&
-	check_patch patch &&
-	grep "^From: F R Om <[email protected]>\$" patch
+	git -c format.from="F R Om <[email protected]>" format-patch --stdout master..side >patch &&
+	sed -e "/^\$/q" patch >hdrs &&
+	check_patch hdrs &&
+	grep "^From: F R Om <[email protected]>\$" hdrs
 '
 
 test_expect_success '--no-from overrides format.from' '
-	git -c format.from="F R Om <[email protected]>" format-patch --no-from --stdout master..side |
-	sed -e "/^\$/q" >patch &&
-	check_patch patch &&
-	! grep "^From: F R Om <[email protected]>\$" patch
+	git -c format.from="F R Om <[email protected]>" format-patch --no-from --stdout master..side >patch &&
+	sed -e "/^\$/q" patch >hdrs &&
+	check_patch hdrs &&
+	! grep "^From: F R Om <[email protected]>\$" hdrs
 '
 
 test_expect_success '--from overrides format.from' '
-	git -c format.from="F R Om <[email protected]>" format-patch --from --stdout master..side |
-	sed -e "/^\$/q" >patch &&
-	check_patch patch &&
-	! grep "^From: F R Om <[email protected]>\$" patch
+	git -c format.from="F R Om <[email protected]>" format-patch --from --stdout master..side >patch &&
+	sed -e "/^\$/q" patch >hdrs &&
+	check_patch hdrs &&
+	! grep "^From: F R Om <[email protected]>\$" hdrs
 '
 
 test_expect_success '--no-to overrides config.to' '
 	git config --replace-all format.to \
 		"R E Cipient <[email protected]>" &&
-	git format-patch --no-to --stdout master..side |
-	sed -e "/^\$/q" >patch10 &&
-	check_patch patch10 &&
-	! grep "^To: R E Cipient <[email protected]>\$" patch10
+	git format-patch --no-to --stdout master..side >patch10 &&
+	sed -e "/^\$/q" patch10 >hdrs10 &&
+	check_patch hdrs10 &&
+	! grep "^To: R E Cipient <[email protected]>\$" hdrs10
 '
 
 test_expect_success '--no-to and --to replaces config.to' '
 	git config --replace-all format.to \
 		"Someone <[email protected]>" &&
 	git format-patch --no-to --to="Someone Else <[email protected]>" \
-		--stdout master..side |
-	sed -e "/^\$/q" >patch11 &&
-	check_patch patch11 &&
-	! grep "^To: Someone <[email protected]>\$" patch11 &&
-	grep "^To: Someone Else <[email protected]>\$" patch11
+		--stdout master..side >patch11 &&
+	sed -e "/^\$/q" patch11 >hdrs11 &&
+	check_patch hdrs11 &&
+	! grep "^To: Someone <[email protected]>\$" hdrs11 &&
+	grep "^To: Someone Else <[email protected]>\$" hdrs11
 '
 
 test_expect_success '--no-cc overrides config.cc' '
 	git config --replace-all format.cc \
 		"C E Cipient <[email protected]>" &&
-	git format-patch --no-cc --stdout master..side |
-	sed -e "/^\$/q" >patch12 &&
-	check_patch patch12 &&
-	! grep "^Cc: C E Cipient <[email protected]>\$" patch12
+	git format-patch --no-cc --stdout master..side >patch12 &&
+	sed -e "/^\$/q" patch12 >hdrs12 &&
+	check_patch hdrs12 &&
+	! grep "^Cc: C E Cipient <[email protected]>\$" hdrs12
 '
 
 test_expect_success '--no-add-header overrides config.headers' '
 	git config --replace-all format.headers \
 		"Header1: B E Cipient <[email protected]>" &&
-	git format-patch --no-add-header --stdout master..side |
-	sed -e "/^\$/q" >patch13 &&
-	check_patch patch13 &&
-	! grep "^Header1: B E Cipient <[email protected]>\$" patch13
+	git format-patch --no-add-header --stdout master..side >patch13 &&
+	sed -e "/^\$/q" patch13 >hdrs13 &&
+	check_patch hdrs13 &&
+	! grep "^Header1: B E Cipient <[email protected]>\$" hdrs13
 '
 
 test_expect_success 'multiple files' '
@@ -808,20 +821,24 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
 	git format-patch --ignore-if-in-upstream HEAD
 '
 
-git_version="$(git --version | sed "s/.* //")"
+test_expect_success 'get git version' '
+	git_version="$(git --version | sed "s/.* //")"
+'
 
 signature() {
 	printf "%s\n%s\n\n" "-- " "${1:-$git_version}"
 }
 
 test_expect_success 'format-patch default signature' '
-	git format-patch --stdout -1 | tail -n 3 >output &&
+	git format-patch --stdout -1 >patch &&
+	tail -n 3 patch >output &&
 	signature >expect &&
 	test_cmp expect output
 '
 
 test_expect_success 'format-patch --signature' '
-	git format-patch --stdout --signature="my sig" -1 | tail -n 3 >output &&
+	git format-patch --stdout --signature="my sig" -1 >patch &&
+	tail -n 3 patch >output &&
 	signature "my sig" >expect &&
 	test_cmp expect output
 '
@@ -1606,19 +1623,40 @@ test_expect_success 'format-patch -o overrides format.outputDirectory' '
 
 test_expect_success 'format-patch --base' '
 	git checkout patchid &&
-	git format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual1 &&
-	git format-patch --stdout --base=HEAD~3 HEAD~.. | tail -n 7 >actual2 &&
+
+	git format-patch --stdout --base=HEAD~3 -1 >patch &&
+	tail -n 7 patch >actual1 &&
+
+	git format-patch --stdout --base=HEAD~3 HEAD~.. >patch &&
+	tail -n 7 patch >actual2 &&
+
 	echo >expect &&
-	echo "base-commit: $(git rev-parse HEAD~3)" >>expect &&
-	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expect &&
-	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expect &&
+	git rev-parse HEAD~3 >commit-id-base &&
+	echo "base-commit: $(cat commit-id-base)" >>expect &&
+
+	git show --patch HEAD~2 >patch &&
+	git patch-id --stable <patch >patch.id.raw &&
+	awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >>expect &&
+
+	git show --patch HEAD~1 >patch &&
+	git patch-id --stable <patch >patch.id.raw &&
+	awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >>expect &&
+
 	signature >>expect &&
 	test_cmp expect actual1 &&
 	test_cmp expect actual2 &&
+
 	echo >fail &&
-	echo "base-commit: $(git rev-parse HEAD~3)" >>fail &&
-	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --unstable | awk "{print \$1}")" >>fail &&
-	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --unstable | awk "{print \$1}")" >>fail &&
+	echo "base-commit: $(cat commit-id-base)" >>fail &&
+
+	git show --patch HEAD~2 >patch &&
+	git patch-id --unstable <patch >patch.id.raw &&
+	awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >>fail &&
+
+	git show --patch HEAD~1 >patch &&
+	git patch-id --unstable <patch >patch.id.raw &&
+	awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >>fail &&
+
 	signature >>fail &&
 	! test_cmp fail actual1 &&
 	! test_cmp fail actual2
@@ -1629,7 +1667,8 @@ test_expect_success 'format-patch --base errors out when base commit is in revis
 	test_must_fail git format-patch --base=HEAD~1 -2 &&
 	git format-patch --stdout --base=HEAD~2 -2 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse HEAD~2)" >expect &&
+	git rev-parse HEAD~2 >commit-id-base &&
+	echo "base-commit: $(cat commit-id-base)" >expect &&
 	test_cmp expect actual
 '
 
@@ -1668,7 +1707,8 @@ test_expect_success 'format-patch --base=auto' '
 	test_commit N2 &&
 	git format-patch --stdout --base=auto -2 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse upstream)" >expect &&
+	git rev-parse upstream >commit-id-base &&
+	echo "base-commit: $(cat commit-id-base)" >expect &&
 	test_cmp expect actual
 '
 
@@ -1705,7 +1745,8 @@ test_expect_success 'format-patch format.useAutoBaseoption' '
 	git config format.useAutoBase true &&
 	git format-patch --stdout -1 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse upstream)" >expect &&
+	git rev-parse upstream >commit-id-base &&
+	echo "base-commit: $(cat commit-id-base)" >expect &&
 	test_cmp expect actual
 '
 
@@ -1714,7 +1755,8 @@ test_expect_success 'format-patch --base overrides format.useAutoBase' '
 	git config format.useAutoBase true &&
 	git format-patch --stdout --base=HEAD~1 -1 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse HEAD~1)" >expect &&
+	git rev-parse HEAD~1 >commit-id-base &&
+	echo "base-commit: $(cat commit-id-base)" >expect &&
 	test_cmp expect actual
 '
 
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#22 lore raw

Re: [PATCH v3 10/13] t4014: stop losing return codes of git commands

t/t4014-format-patch.sh test_expect_success 'format-patch --ignore-if-in-upstream HEAD' ' · line 826

Quoted 8 lines · Denton Liu
t/t4014-format-patch.sh +3 -1
@@ -808,20 +821,24 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
 	git format-patch --ignore-if-in-upstream HEAD
 '
 
-git_version="$(git --version | sed "s/.* //")"
+test_expect_success 'get git version' '
+	git_version="$(git --version | sed "s/.* //")"
+'

Oops, this should read

	git_version="$(git --version >version && sed "s/.* //" <version)"

Anyway, I was considering keeping the upstream pipe but it feels very weird having an unchecked Git command (especially since, from what I can tell, git --version isn't tested anywhere else). Thoughts?

Quoted 20 lines
t/t4014-format-patch.sh +4 -2
 signature() {
 	printf "%s\n%s\n\n" "-- " "${1:-$git_version}"
 }
 
 test_expect_success 'format-patch default signature' '
-	git format-patch --stdout -1 | tail -n 3 >output &&
+	git format-patch --stdout -1 >patch &&
+	tail -n 3 patch >output &&
 	signature >expect &&
 	test_cmp expect output
 '
 
 test_expect_success 'format-patch --signature' '
-	git format-patch --stdout --signature="my sig" -1 | tail -n 3 >output &&
+	git format-patch --stdout --signature="my sig" -1 >patch &&
+	tail -n 3 patch >output &&
 	signature "my sig" >expect &&
 	test_cmp expect output
 '
#23 lore raw

Re: [PATCH v3 10/13] t4014: stop losing return codes of git commands

Am 20.08.19 um 09:31 schrieb Denton Liu:

Quoted 3 lines

Oops, this should read

	git_version="$(git --version >version && sed "s/.* //" <version)"

sed is not necessary. Make that

	git_version=$(git --version) &&
	git_version=${git_version##* }

-- Hannes

author
#24 lore raw

PATCH v3 11/13 Doc: add more detail for git-format-patch

In reply to Denton Liu

In git-format-patch.txt, we were missing some key user information. First of all, document the special value of --base=auto.

Next, while we're at it, surround option arguments with <>.

Finally, document the format.outputDirectory config and change format.coverletter to use camel case.

---
 Documentation/git-format-patch.txt | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
Documentation/git-format-patch.txt +10 -7
index b9b97e63ae..95bc4d53ca 100644
@@ -17,9 +17,9 @@ SYNOPSIS
 		   [--signature-file=<file>]
 		   [-n | --numbered | -N | --no-numbered]
 		   [--start-number <n>] [--numbered-files]
-		   [--in-reply-to=Message-Id] [--suffix=.<sfx>]
+		   [--in-reply-to=<Message-Id>] [--suffix=.<sfx>]
 		   [--ignore-if-in-upstream]
-		   [--rfc] [--subject-prefix=Subject-Prefix]
+		   [--rfc] [--subject-prefix=<Subject-Prefix>]
 		   [(--reroll-count|-v) <n>]
 		   [--to=<email>] [--cc=<email>]
 		   [--[no-]cover-letter] [--quiet]
@@ -159,7 +159,7 @@ Beware that the default for 'git send-email' is to thread emails
 itself.  If you want `git format-patch` to take care of threading, you
 will want to ensure that threading is disabled for `git send-email`.
 
---in-reply-to=Message-Id::
+--in-reply-to=<Message-Id>::
 	Make the first mail (or all the mails with `--no-thread`) appear as a
 	reply to the given Message-Id, which avoids breaking threads to
 	provide a new patch series.
@@ -314,7 +314,8 @@ you can use `--suffix=-patch` to get `0001-description-of-my-change-patch`.
 --base=<commit>::
 	Record the base tree information to identify the state the
 	patch series applies to.  See the BASE TREE INFORMATION section
-	below for details.
+	below for details. If <commit> is "auto", a base commit is
+	automatically chosen.
 
 --root::
 	Treat the revision argument as a <revision range>, even if it
@@ -330,8 +331,9 @@ CONFIGURATION
 -------------
 You can specify extra mail header lines to be added to each message,
 defaults for the subject prefix and file suffix, number patches when
-outputting more than one patch, add "To" or "Cc:" headers, configure
-attachments, and sign off patches with configuration variables.
+outputting more than one patch, add "To:" or "Cc:" headers, configure
+attachments, change the patch output directory, and sign off patches
+with configuration variables.
 
 ------------
 [format]
@@ -343,7 +345,8 @@ attachments, and sign off patches with configuration variables.
 	cc = <email>
 	attach [ = mime-boundary-string ]
 	signOff = true
-	coverletter = auto
+	outputDirectory = <directory>
+	coverLetter = auto
 ------------
 
 
Signature · 1 line
2.23.0.248.g3a9dd8fb08
#25 lore raw

Re: [PATCH v3 11/13] Doc: add more detail for git-format-patch

Quoted 1 line · Denton Liu

Next, while we're at it, surround option arguments with <>.

I'd suggest squashing this in to complete the above.

cf. <[email protected]>

---
 Documentation/git-format-patch.txt | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
Documentation/git-format-patch.txt +6 -6
index 95bc4d53ca..0ac56f4b70 100644
@@ -17,9 +17,9 @@ SYNOPSIS
 		   [--signature-file=<file>]
 		   [-n | --numbered | -N | --no-numbered]
 		   [--start-number <n>] [--numbered-files]
-		   [--in-reply-to=<Message-Id>] [--suffix=.<sfx>]
+		   [--in-reply-to=<message id>] [--suffix=.<sfx>]
 		   [--ignore-if-in-upstream]
-		   [--rfc] [--subject-prefix=<Subject-Prefix>]
+		   [--rfc] [--subject-prefix=<subject prefix>]
 		   [(--reroll-count|-v) <n>]
 		   [--to=<email>] [--cc=<email>]
 		   [--[no-]cover-letter] [--quiet]
@@ -159,9 +159,9 @@ Beware that the default for 'git send-email' is to thread emails
 itself.  If you want `git format-patch` to take care of threading, you
 will want to ensure that threading is disabled for `git send-email`.
 
---in-reply-to=<Message-Id>::
+--in-reply-to=<message id>::
 	Make the first mail (or all the mails with `--no-thread`) appear as a
-	reply to the given Message-Id, which avoids breaking threads to
+	reply to the given <message id>, which avoids breaking threads to
 	provide a new patch series.
 
 --ignore-if-in-upstream::
@@ -171,9 +171,9 @@ will want to ensure that threading is disabled for `git send-email`.
 	patches being generated, and any patch that matches is
 	ignored.
 
---subject-prefix=<Subject-Prefix>::
+--subject-prefix=<subject prefix>::
 	Instead of the standard '[PATCH]' prefix in the subject
-	line, instead use '[<Subject-Prefix>]'. This
+	line, instead use '[<subject prefix>]'. This
 	allows for useful naming of a patch series, and can be
 	combined with the `--numbered` option.
 
Signature · 1 line
2.23.0-266-g1e4abb0e04
author
#26 lore raw

PATCH v3 12/13 config/format.txt: specify default value of format.coverLetter

In reply to Denton Liu
---
 Documentation/config/format.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/config/format.txt +1 -0
index 414a5a8a9d..cb629fa769 100644
@@ -77,6 +77,7 @@ format.coverLetter::
 	A boolean that controls whether to generate a cover-letter when
 	format-patch is invoked, but in addition can be set to "auto", to
 	generate a cover-letter only when there's more than one patch.
+	Default is false.
 
 format.outputDirectory::
 	Set a custom directory to store the resulting files instead of the
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#27 lore raw

PATCH v3 13/13 format-patch: learn --infer-cover-subject option

In reply to Denton Liu

Teach format-patch to use the first line of the branch description as the Subject: of the generated cover letter, rather than "*** SUBJECT HERE ***" if --infer-cover-subject is specified or the corresponding format.inferCoverSubject option is enabled. This complements the existing inclusion of the branch description in the cover letter body.

The reason why this behaviour is not made default is because this change is not backwards compatible and may break existing tooling that may rely on the default template subject.

---
 Documentation/config/format.txt    |  6 ++++
 Documentation/git-format-patch.txt |  7 ++++
 builtin/log.c                      | 56 +++++++++++++++++++-----------
 t/t4014-format-patch.sh            | 35 ++++++++++++++++++-
 4 files changed, 82 insertions(+), 22 deletions(-)
Documentation/config/format.txt +6 -0
index cb629fa769..2723566289 100644
@@ -36,6 +36,12 @@ format.subjectPrefix::
 	The default for format-patch is to output files with the '[PATCH]'
 	subject prefix. Use this variable to change that prefix.
 
+format.inferCoverSubject::
+	A boolean that controls whether or not to take the first line of
+	the branch description as the subject for the cover letter. See the
+	`--infer-cover-subject` option in linkgit:git-format-patch[1].
+	Default is false.
+
 format.signature::
 	The default for format-patch is to output a signature containing
 	the Git version number. Use this variable to change that default.
Documentation/git-format-patch.txt +7 -0
index 95bc4d53ca..c5bc0bf5c6 100644
@@ -19,6 +19,7 @@ SYNOPSIS
 		   [--start-number <n>] [--numbered-files]
 		   [--in-reply-to=<Message-Id>] [--suffix=.<sfx>]
 		   [--ignore-if-in-upstream]
+		   [--[no-]infer-cover-subject]
 		   [--rfc] [--subject-prefix=<Subject-Prefix>]
 		   [(--reroll-count|-v) <n>]
 		   [--to=<email>] [--cc=<email>]
@@ -171,6 +172,11 @@ will want to ensure that threading is disabled for `git send-email`.
 	patches being generated, and any patch that matches is
 	ignored.
 
+--[no-]infer-cover-subject::
+	Use the beginning of the branch description (up to the first
+	blank line) as the cover letter subject instead of the default
+	"*** SUBJECT HERE ***".
+
 --subject-prefix=<Subject-Prefix>::
 	Instead of the standard '[PATCH]' prefix in the subject
 	line, instead use '[<Subject-Prefix>]'. This
@@ -347,6 +353,7 @@ with configuration variables.
 	signOff = true
 	outputDirectory = <directory>
 	coverLetter = auto
+	inferCoverSubject = true
 ------------
 
 
builtin/log.c +35 -21

110 lines not on this page · raw message

t/t4014-format-patch.sh +34 -1
index 7b8c8fe136..94a3191aca 100755
@@ -822,7 +822,7 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
 '
 
 test_expect_success 'get git version' '
-	git_version="$(git --version | sed "s/.* //")"
+	git_version="$(git --version >version && sed "s/.* //" <version)"
 '
 
 signature() {
@@ -1516,6 +1516,39 @@ test_expect_success 'format patch ignores color.ui' '
 	test_cmp expect actual
 '
 
+test_expect_success 'cover letter with config subject' '
+	test_config branch.rebuild-1.description "config subject
+
+body" &&
+	test_config format.inferCoverSubject true &&
+	git checkout rebuild-1 &&
+	git format-patch --stdout --cover-letter master >actual &&
+	grep "^Subject: \[PATCH 0/2\] config subject$" actual &&
+	grep "^body" actual
+'
+
+test_expect_success 'cover letter with command-line subject' '
+	test_config branch.rebuild-1.description "command-line subject
+
+body" &&
+	git checkout rebuild-1 &&
+	git format-patch --stdout --cover-letter --infer-cover-subject master >actual &&
+	grep "^Subject: \[PATCH 0/2\] command-line subject$" actual &&
+	grep "^body" actual
+'
+
+test_expect_success 'cover letter with command-line --no-infer-cover-subject overrides config' '
+	test_config branch.rebuild-1.description "config subject
+
+body" &&
+	test_config format.inferCoverSubject true &&
+	git checkout rebuild-1 &&
+	git format-patch --stdout --cover-letter --no-infer-cover-subject master >actual &&
+	grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual &&
+	grep "^config subject" actual &&
+	grep "^body" actual
+'
+
 test_expect_success 'cover letter using branch description (1)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
Signature · 1 line
2.23.0.248.g3a9dd8fb08
#28 lore raw
Quoted 2 lines · Denton Liu

Teach format-patch to use the first line of the branch description as the Subject: of the generated cover letter, rather than "*** SUBJECT

I would not say "the first line", as I do not think that is what happens by calling pretty.c::format_subject(). The function is designed to take the first paragraph, and the behaviour is in line with how the subject is formed from the log message in a commit object. I'd say "the first paragraph" instead.

Quoted 7 lines

HERE ***" if --infer-cover-subject is specified or the corresponding format.inferCoverSubject option is enabled. This complements the existing inclusion of the branch description in the cover letter body.

The reason why this behaviour is not made default is because this change is not backwards compatible and may break existing tooling that may rely on the default template subject.

I'd suggest writing it more assertively, rather than appearing to be making lame excuses. Perhaps like

The new behaviour is not made default; doing so would surprise existing users, which is not a good idea.

Or just drop the excuse of not changing the default altogether. It is pretty much the standard practice for us to keep the existing behaviour the same and to make the new behaviour opt-in.

Having said that, I suspect that in the longer term, people would want to see this new behaviour with a bit of tweak become the new default.

The "tweak" I suspect is needed is to behave sensibly when "the first line" ends up to be too long a subject. Whether we make this the new default or keep this optional, the issue exists either way.

One way to make it behave sensibly with overly long first paragraph is to fall back to the current behaviour. We can think about the way an ideally "tweaked" version of this patch uses the branch description like this:

1. Preprocess and prepare the branch description string for use in the next step.

- If there is no branch description, then pretend as if "*** Subject Here ***" followed by a blank line and "*** Blurb here ***" were given as the branch description in the step 2.

- If the first paragraph of the description is overly long, then prepend "*** Subject Here ***" followed by a blank line before the branch description, and use that the branch description string in the step 2 (this is the "tweak to make it behave sensibly" change I suggested above).

- Otherwise, use the given branch description in the step 2. Optionally, when a backward-compatibility knob is in effect, always prepend the "Subject Here" paragraph. That way, step
2. would end up keeping the traditional behaviour.

2. Split the first pragraph out of the branch description. Use it as the subject, and use the remainder in the body.

And if we view the behaviour that way, it becomes clear that the "--infer-cover-subject" is a fairly meaningless name for the option. We unconditionally use the branch description to fill in the subject and the body, but the traditional way and the updated one when the first paragraph is overly long use placeholder string for the subject instead. I.e. a better name for the option may be something like --placeholder-subject-in-cover (as opposed to taking the subject in cover from the branch description), and it can be negated i.e. --no-placeholder-subject-in-cover, to force keeping the old behaviour.

And I suspect that the approach would allow the implementation to become simple and straight-forward. The "branch description" needs to be prepared in a few different ways (i.e. if there is no branch.*.description, you'd fill a fixed string; after reading branch.*.description and measuring the first paragraph, you may prepend another fixed string), but after that is done, the actual generation of the cover letter will need NO conditional logic. It just needs to split that into the first paragraph to be used as the subject, and the remainder used in the body.

Hmm?

Quoted 162 lines
builtin/log.c +34 -21
@@ -887,6 +888,10 @@ static int git_format_config(const char *var, const char *value, void *cb)
 		}
 		return 0;
 	}
+	if (!strcmp(var, "format.infercoversubject")) {
+		infer_cover_subject = git_config_bool(var, value);
+		return 0;
+	}
 
 	return git_log_config(var, value, cb);
 }
@@ -993,20 +998,6 @@ static void print_signature(FILE *file)
 	putc('\n', file);
 }
 
-static void add_branch_description(struct strbuf *buf, const char *branch_name)
-{
-	struct strbuf desc = STRBUF_INIT;
-	if (!branch_name || !*branch_name)
-		return;
-	read_branch_desc(&desc, branch_name);
-	if (desc.len) {
-		strbuf_addch(buf, '\n');
-		strbuf_addbuf(buf, &desc);
-		strbuf_addch(buf, '\n');
-	}
-	strbuf_release(&desc);
-}
-
 static char *find_branch_name(struct rev_info *rev)
 {
 	int i, positive = -1;
@@ -1057,13 +1048,17 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
 			      struct commit *origin,
 			      int nr, struct commit **list,
 			      const char *branch_name,
+			      int infer_subject,
 			      int quiet)
 {
 	const char *committer;
-	const char *body = "*** SUBJECT HERE ***\n\n*** BLURB HERE ***\n";
-	const char *msg;
+	const char *subject = "*** SUBJECT HERE ***";
+	const char *body = "*** BLURB HERE ***";
+	const char *description = NULL;
 	struct shortlog log;
 	struct strbuf sb = STRBUF_INIT;
+	struct strbuf description_sb = STRBUF_INIT;
+	struct strbuf subject_sb = STRBUF_INIT;
 	int i;
 	const char *encoding = "UTF-8";
 	int need_8bit_cte = 0;
@@ -1091,17 +1086,34 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
 	if (!branch_name)
 		branch_name = find_branch_name(rev);
 
-	msg = body;
+	if (branch_name && *branch_name)
+		read_branch_desc(&description_sb, branch_name);
+
+	if (description_sb.len) {
+		if (infer_subject) {
+			description = format_subject(&subject_sb, description_sb.buf, " ");
+			subject = subject_sb.buf;
+		} else {
+			description = description_sb.buf;
+		}
+	}
+
 	pp.fmt = CMIT_FMT_EMAIL;
 	pp.date_mode.type = DATE_RFC2822;
 	pp.rev = rev;
 	pp.print_email_subject = 1;
 	pp_user_info(&pp, NULL, &sb, committer, encoding);
-	pp_title_line(&pp, &msg, &sb, encoding, need_8bit_cte);
-	pp_remainder(&pp, &msg, &sb, 0);
-	add_branch_description(&sb, branch_name);
+	pp_title_line(&pp, &subject, &sb, encoding, need_8bit_cte);
+	pp_remainder(&pp, &body, &sb, 0);
+	if (description) {
+		strbuf_addch(&sb, '\n');
+		strbuf_addstr(&sb, description);
+		strbuf_addch(&sb, '\n');
+	}
 	fprintf(rev->diffopt.file, "%s\n", sb.buf);
 
+	strbuf_release(&description_sb);
+	strbuf_release(&subject_sb);
 	strbuf_release(&sb);
 
 	shortlog_init(&log);
@@ -1577,6 +1589,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 		{ OPTION_CALLBACK, 0, "rfc", &rev, NULL,
 			    N_("Use [RFC PATCH] instead of [PATCH]"),
 			    PARSE_OPT_NOARG | PARSE_OPT_NONEG, rfc_callback },
+		OPT_BOOL(0, "infer-cover-subject", &infer_cover_subject,
+			    N_("infer a cover letter subject from branch description")),
 		{ OPTION_CALLBACK, 0, "subject-prefix", &rev, N_("prefix"),
 			    N_("Use [<prefix>] instead of [PATCH]"),
 			    PARSE_OPT_NONEG, subject_prefix_callback },
@@ -1916,7 +1930,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 		if (thread)
 			gen_message_id(&rev, "cover");
 		make_cover_letter(&rev, use_stdout,
-				  origin, nr, list, branch_name, quiet);
+				  origin, nr, list, branch_name, infer_cover_subject, quiet);
 		print_bases(&bases, rev.diffopt.file);
 		print_signature(rev.diffopt.file);
 		total++;
t/t4014-format-patch.sh +34 -1
index 7b8c8fe136..94a3191aca 100755
@@ -822,7 +822,7 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
 '
 
 test_expect_success 'get git version' '
-	git_version="$(git --version | sed "s/.* //")"
+	git_version="$(git --version >version && sed "s/.* //" <version)"
 '
 
 signature() {
@@ -1516,6 +1516,39 @@ test_expect_success 'format patch ignores color.ui' '
 	test_cmp expect actual
 '
 
+test_expect_success 'cover letter with config subject' '
+	test_config branch.rebuild-1.description "config subject
+
+body" &&
+	test_config format.inferCoverSubject true &&
+	git checkout rebuild-1 &&
+	git format-patch --stdout --cover-letter master >actual &&
+	grep "^Subject: \[PATCH 0/2\] config subject$" actual &&
+	grep "^body" actual
+'
+
+test_expect_success 'cover letter with command-line subject' '
+	test_config branch.rebuild-1.description "command-line subject
+
+body" &&
+	git checkout rebuild-1 &&
+	git format-patch --stdout --cover-letter --infer-cover-subject master >actual &&
+	grep "^Subject: \[PATCH 0/2\] command-line subject$" actual &&
+	grep "^body" actual
+'
+
+test_expect_success 'cover letter with command-line --no-infer-cover-subject overrides config' '
+	test_config branch.rebuild-1.description "config subject
+
+body" &&
+	test_config format.inferCoverSubject true &&
+	git checkout rebuild-1 &&
+	git format-patch --stdout --cover-letter --no-infer-cover-subject master >actual &&
+	grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual &&
+	grep "^config subject" actual &&
+	grep "^body" actual
+'
+
 test_expect_success 'cover letter using branch description (1)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
author
#29 lore raw
Quoted 29 lines · Junio C Hamano
Quoted 2 lines · Denton Liu

Teach format-patch to use the first line of the branch description as the Subject: of the generated cover letter, rather than "*** SUBJECT

I would not say "the first line", as I do not think that is what happens by calling pretty.c::format_subject(). The function is designed to take the first paragraph, and the behaviour is in line with how the subject is formed from the log message in a commit object. I'd say "the first paragraph" instead.

Quoted 7 lines

HERE ***" if --infer-cover-subject is specified or the corresponding format.inferCoverSubject option is enabled. This complements the existing inclusion of the branch description in the cover letter body.

The reason why this behaviour is not made default is because this change is not backwards compatible and may break existing tooling that may rely on the default template subject.

I'd suggest writing it more assertively, rather than appearing to be making lame excuses. Perhaps like

The new behaviour is not made default; doing so would surprise existing users, which is not a good idea.

Or just drop the excuse of not changing the default altogether. It is pretty much the standard practice for us to keep the existing behaviour the same and to make the new behaviour opt-in.

Quoted 7 lines

Having said that, I suspect that in the longer term, people would want to see this new behaviour with a bit of tweak become the new default.

The "tweak" I suspect is needed is to behave sensibly when "the first line" ends up to be too long a subject. Whether we make this the new default or keep this optional, the issue exists either way.

The reason why I chose to make this an "opt-in" option was because there currently doesn't exist a standard on how to write branch descriptions like there does for commit messages (i.e. subject then body, subject less than x characters). However, against best practices, some developers like to have really long subjects. As a result, there's no "real" way of telling whether the first paragraph is a long subject or a short paragraph.

As a result, we should allow the cover subject to be read from the branch description only if the developer explicitly chooses this (either with --infer-cover-subject the config option). This way, we won't have to deal with the ambiguity of deciding whether or not the first paragraph is truly a subject and stepping on users' toes if we end up deciding wrong.

Thoughts?

Quoted 212 lines

One way to make it behave sensibly with overly long first paragraph is to fall back to the current behaviour. We can think about the way an ideally "tweaked" version of this patch uses the branch description like this:

1. Preprocess and prepare the branch description string for use in the next step.

- If there is no branch description, then pretend as if "*** Subject Here ***" followed by a blank line and "*** Blurb here ***" were given as the branch description in the step 2.

- If the first paragraph of the description is overly long, then prepend "*** Subject Here ***" followed by a blank line before the branch description, and use that the branch description string in the step 2 (this is the "tweak to make it behave sensibly" change I suggested above).

- Otherwise, use the given branch description in the step 2. Optionally, when a backward-compatibility knob is in effect, always prepend the "Subject Here" paragraph. That way, step
2. would end up keeping the traditional behaviour.

2. Split the first pragraph out of the branch description. Use it as the subject, and use the remainder in the body.

And if we view the behaviour that way, it becomes clear that the "--infer-cover-subject" is a fairly meaningless name for the option. We unconditionally use the branch description to fill in the subject and the body, but the traditional way and the updated one when the first paragraph is overly long use placeholder string for the subject instead. I.e. a better name for the option may be something like --placeholder-subject-in-cover (as opposed to taking the subject in cover from the branch description), and it can be negated i.e. --no-placeholder-subject-in-cover, to force keeping the old behaviour.

And I suspect that the approach would allow the implementation to become simple and straight-forward. The "branch description" needs to be prepared in a few different ways (i.e. if there is no branch.*.description, you'd fill a fixed string; after reading branch.*.description and measuring the first paragraph, you may prepend another fixed string), but after that is done, the actual generation of the cover letter will need NO conditional logic. It just needs to split that into the first paragraph to be used as the subject, and the remainder used in the body.

Hmm?

Quoted 162 lines
builtin/log.c +34 -21
@@ -887,6 +888,10 @@ static int git_format_config(const char *var, const char *value, void *cb)
 		}
 		return 0;
 	}
+	if (!strcmp(var, "format.infercoversubject")) {
+		infer_cover_subject = git_config_bool(var, value);
+		return 0;
+	}
 
 	return git_log_config(var, value, cb);
 }
@@ -993,20 +998,6 @@ static void print_signature(FILE *file)
 	putc('\n', file);
 }
 
-static void add_branch_description(struct strbuf *buf, const char *branch_name)
-{
-	struct strbuf desc = STRBUF_INIT;
-	if (!branch_name || !*branch_name)
-		return;
-	read_branch_desc(&desc, branch_name);
-	if (desc.len) {
-		strbuf_addch(buf, '\n');
-		strbuf_addbuf(buf, &desc);
-		strbuf_addch(buf, '\n');
-	}
-	strbuf_release(&desc);
-}
-
 static char *find_branch_name(struct rev_info *rev)
 {
 	int i, positive = -1;
@@ -1057,13 +1048,17 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
 			      struct commit *origin,
 			      int nr, struct commit **list,
 			      const char *branch_name,
+			      int infer_subject,
 			      int quiet)
 {
 	const char *committer;
-	const char *body = "*** SUBJECT HERE ***\n\n*** BLURB HERE ***\n";
-	const char *msg;
+	const char *subject = "*** SUBJECT HERE ***";
+	const char *body = "*** BLURB HERE ***";
+	const char *description = NULL;
 	struct shortlog log;
 	struct strbuf sb = STRBUF_INIT;
+	struct strbuf description_sb = STRBUF_INIT;
+	struct strbuf subject_sb = STRBUF_INIT;
 	int i;
 	const char *encoding = "UTF-8";
 	int need_8bit_cte = 0;
@@ -1091,17 +1086,34 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
 	if (!branch_name)
 		branch_name = find_branch_name(rev);
 
-	msg = body;
+	if (branch_name && *branch_name)
+		read_branch_desc(&description_sb, branch_name);
+
+	if (description_sb.len) {
+		if (infer_subject) {
+			description = format_subject(&subject_sb, description_sb.buf, " ");
+			subject = subject_sb.buf;
+		} else {
+			description = description_sb.buf;
+		}
+	}
+
 	pp.fmt = CMIT_FMT_EMAIL;
 	pp.date_mode.type = DATE_RFC2822;
 	pp.rev = rev;
 	pp.print_email_subject = 1;
 	pp_user_info(&pp, NULL, &sb, committer, encoding);
-	pp_title_line(&pp, &msg, &sb, encoding, need_8bit_cte);
-	pp_remainder(&pp, &msg, &sb, 0);
-	add_branch_description(&sb, branch_name);
+	pp_title_line(&pp, &subject, &sb, encoding, need_8bit_cte);
+	pp_remainder(&pp, &body, &sb, 0);
+	if (description) {
+		strbuf_addch(&sb, '\n');
+		strbuf_addstr(&sb, description);
+		strbuf_addch(&sb, '\n');
+	}
 	fprintf(rev->diffopt.file, "%s\n", sb.buf);
 
+	strbuf_release(&description_sb);
+	strbuf_release(&subject_sb);
 	strbuf_release(&sb);
 
 	shortlog_init(&log);
@@ -1577,6 +1589,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 		{ OPTION_CALLBACK, 0, "rfc", &rev, NULL,
 			    N_("Use [RFC PATCH] instead of [PATCH]"),
 			    PARSE_OPT_NOARG | PARSE_OPT_NONEG, rfc_callback },
+		OPT_BOOL(0, "infer-cover-subject", &infer_cover_subject,
+			    N_("infer a cover letter subject from branch description")),
 		{ OPTION_CALLBACK, 0, "subject-prefix", &rev, N_("prefix"),
 			    N_("Use [<prefix>] instead of [PATCH]"),
 			    PARSE_OPT_NONEG, subject_prefix_callback },
@@ -1916,7 +1930,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 		if (thread)
 			gen_message_id(&rev, "cover");
 		make_cover_letter(&rev, use_stdout,
-				  origin, nr, list, branch_name, quiet);
+				  origin, nr, list, branch_name, infer_cover_subject, quiet);
 		print_bases(&bases, rev.diffopt.file);
 		print_signature(rev.diffopt.file);
 		total++;
t/t4014-format-patch.sh +34 -1
index 7b8c8fe136..94a3191aca 100755
@@ -822,7 +822,7 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
 '
 
 test_expect_success 'get git version' '
-	git_version="$(git --version | sed "s/.* //")"
+	git_version="$(git --version >version && sed "s/.* //" <version)"
 '
 
 signature() {
@@ -1516,6 +1516,39 @@ test_expect_success 'format patch ignores color.ui' '
 	test_cmp expect actual
 '
 
+test_expect_success 'cover letter with config subject' '
+	test_config branch.rebuild-1.description "config subject
+
+body" &&
+	test_config format.inferCoverSubject true &&
+	git checkout rebuild-1 &&
+	git format-patch --stdout --cover-letter master >actual &&
+	grep "^Subject: \[PATCH 0/2\] config subject$" actual &&
+	grep "^body" actual
+'
+
+test_expect_success 'cover letter with command-line subject' '
+	test_config branch.rebuild-1.description "command-line subject
+
+body" &&
+	git checkout rebuild-1 &&
+	git format-patch --stdout --cover-letter --infer-cover-subject master >actual &&
+	grep "^Subject: \[PATCH 0/2\] command-line subject$" actual &&
+	grep "^body" actual
+'
+
+test_expect_success 'cover letter with command-line --no-infer-cover-subject overrides config' '
+	test_config branch.rebuild-1.description "config subject
+
+body" &&
+	test_config format.inferCoverSubject true &&
+	git checkout rebuild-1 &&
+	git format-patch --stdout --cover-letter --no-infer-cover-subject master >actual &&
+	grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual &&
+	grep "^config subject" actual &&
+	grep "^body" actual
+'
+
 test_expect_success 'cover letter using branch description (1)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
#30 lore raw
Quoted 15 lines · Denton Liu
Quoted 7 lines

Having said that, I suspect that in the longer term, people would want to see this new behaviour with a bit of tweak become the new default.

The "tweak" I suspect is needed is to behave sensibly when "the first line" ends up to be too long a subject. Whether we make this the new default or keep this optional, the issue exists either way.

The reason why I chose to make this an "opt-in" option was because there currently doesn't exist a standard on how to write branch descriptions like there does for commit messages (i.e. subject then body, subject less than x characters). However, against best practices, some developers like to have really long subjects. As a result, there's no "real" way of telling whether the first paragraph is a long subject or a short paragraph.

Quoted 8 lines

As a result, we should allow the cover subject to be read from the branch description only if the developer explicitly chooses this (either with --infer-cover-subject the config option). This way, we won't have to deal with the ambiguity of deciding whether or not the first paragraph is truly a subject and stepping on users' toes if we end up deciding wrong.

Thoughts?

Perhaps the --infer-cover-subject the config option needs to be multi-valued to include:
     "subject" (always expect short first lines) or
     "message" (always the long paragraph description, still use ***Subject Here***), with the "true" being used when expecting both as previously described.

Signature · 3 lines
Philip

As an aside, for format-patch to learn a --branch-version option that creates a branch with the '-vN' suffix to the current branch when the -vN option is used would be a useful addition (as long as the formatted refs are first parent to the current branch). #todo list #leftoverbits
#31 lore raw
Quoted 7 lines · Philip Oakley

Perhaps the --infer-cover-subject the config option needs to be multi-valued to include:
     "subject" (always expect short first lines) or "message" (always the long paragraph description, still use ***Subject Here***),
     with the "true" being used when expecting both as previously described.

The idea to have three choices feels that this is getting better, but I notice that the choice is no longer about "subject".

I've always felt that the name of this option is way suboptimal. One reason is because the option only says it is about the subject of the cover (letter), and the verb "infer" conveys almost no information---especially it does not say anything about what affects the inference (hint: the branch description value gets used, in a single hardcoded ways right now, but now with the patch we have a choice to control how it gets used).

author
#32 lore raw
Quoted 9 lines · Junio C Hamano
Quoted 7 lines · Philip Oakley

Perhaps the --infer-cover-subject the config option needs to be multi-valued to include:
     "subject" (always expect short first lines) or "message" (always the long paragraph description, still use ***Subject Here***),
     with the "true" being used when expecting both as previously described.

Good idea, I like this a lot!

Quoted 11 lines

The idea to have three choices feels that this is getting better, but I notice that the choice is no longer about "subject".

I've always felt that the name of this option is way suboptimal. One reason is because the option only says it is about the subject of the cover (letter), and the verb "infer" conveys almost no information---especially it does not say anything about what affects the inference (hint: the branch description value gets used, in a single hardcoded ways right now, but now with the patch we have a choice to control how it gets used).

Perhaps something like --cover-subject-from-description={true,auto,false}?

#33 lore raw
Quoted 22 lines · Denton Liu
Quoted 9 lines · Junio C Hamano
Quoted 7 lines · Philip Oakley

Perhaps the --infer-cover-subject the config option needs to be multi-valued to include:
     "subject" (always expect short first lines) or "message" (always the long paragraph description, still use
***Subject Here***),
     with the "true" being used when expecting both as previously
described.

Good idea, I like this a lot!

Quoted 10 lines

The idea to have three choices feels that this is getting better, but I notice that the choice is no longer about "subject".

I've always felt that the name of this option is way suboptimal. One reason is because the option only says it is about the subject of the cover (letter), and the verb "infer" conveys almost no information---especially it does not say anything about what affects the inference (hint: the branch description value gets used, in a single hardcoded ways right now, but now with the patch we have a choice to control how it gets used).

Quoted 2 lines

Perhaps something like --cover-subject-from-description={true,auto,false}?

maybe --cover-letter-from-description={true,auto,subject,message,false}? to cover most eventualities (i.e. letter rather than subject).

I haven't looked at what happens on Windows (CRLF usage?) for multi-line descriptions. The common assumption is LF in repo, with attributes etc, but the branch description is a bit free format in terms of guidance ;-)

Philip

#34 lore raw
Quoted 4 lines · Philip Oakley

I haven't looked at what happens on Windows (CRLF usage?) for multi-line descriptions. The common assumption is LF in repo, with attributes etc, but the branch description is a bit free format in terms of guidance ;-)

The same approach taken by the format-patch to use a commit-log message to form the subject and the body should be applicable; as long as the resulting cover letters are made the same way as the normal patch e-mails, it is OK. If both are broken wrt CRLF usage or whatever, as long as they are broken in the same way, we can correct both at the same time ;-)

#35 lore raw
In reply to Denton Liu
Quoted 2 lines · Denton Liu

Perhaps something like --cover-subject-from-description={true,auto,false}?

Is it still only about "subject"? I thought one of the improved behaviour was to populate the subject header with the title (i.e. the first, often single-line, paragraph) and use the remainder in the body? --use-description-in-cover={both,auto,body} meaning "both subject and body gets filled" (among the three this name is I am least happy with), "automatically decide---if the first paragraph is overly big, it is unwise to use it on the subject", "use it only in body" (implying "use the *** SUBJECT HERE *** placeholder on the subject header), perhaps?

#36 lore raw
Quoted 5 lines · Junio C Hamano
Quoted 2 lines · Denton Liu

Perhaps something like --cover-subject-from-description={true,auto,false}?

Quoted 9 lines

Is it still only about "subject"? I thought one of the improved behaviour was to populate the subject header with the title (i.e. the first, often single-line, paragraph) and use the remainder in the body? --use-description-in-cover={both,auto,body} meaning "both subject and body gets filled" (among the three this name is I am least happy with), "automatically decide---if the first paragraph is overly big, it is unwise to use it on the subject", "use it only in body" (implying "use the *** SUBJECT HERE *** placeholder on the subject header), perhaps?

Ah, I see Philip has suggested "--cover-letter-from-description", which also sounds better by not focusing too much on the 'subject', and I have no strong preference between the two.

#37 lore raw

Re: [PATCH v3 00/13] format-patch: learn --infer-cover-subject option (also t4014 cleanup)

In reply to Denton Liu
Quoted 2 lines · Denton Liu

While we're at it, perform some major cleanup of t4014 including some stylistic cleanup and also, unmasking of Git return codes.

Wow. It seems that "while we're at it" grew quite large and (from purely patch count's point of view) ends up appearing as if it were the primary focus of the series ;-)

Thanks for tackling the age-old mess. Admittedly, this particular script is from the older parts of Git's history and a clean-up was long overdue.

With the "split pipes" approach taken in patches 09 and 10, we'd end up leaving more untracked and unignored cruft in the working tree. I do not think they would cause problems with the existing tests after reading the patches over.

author
#38 lore raw

Re: [PATCH v3 00/13] format-patch: learn --infer-cover-subject option (also t4014 cleanup)

Quoted 8 lines · Junio C Hamano
Quoted 2 lines · Denton Liu

While we're at it, perform some major cleanup of t4014 including some stylistic cleanup and also, unmasking of Git return codes.

Wow. It seems that "while we're at it" grew quite large and (from purely patch count's point of view) ends up appearing as if it were the primary focus of the series ;-)

For housekeeping, since this patchset now exists as two branches (dl/format-patch-cover-letter-subject and dl/format-patch-doc-test-cleanup), would you prefer any new revisions exist as one big patchset or two separate patchsets targeting each individual branch?

Quoted 11 lines

Thanks for tackling the age-old mess. Admittedly, this particular script is from the older parts of Git's history and a clean-up was long overdue.

With the "split pipes" approach taken in patches 09 and 10, we'd end up leaving more untracked and unignored cruft in the working tree. I do not think they would cause problems with the existing tests after reading the patches over.

#39 lore raw

Re: [PATCH v3 00/13] format-patch: learn --infer-cover-subject option (also t4014 cleanup)

Quoted 5 lines · Denton Liu

For housekeeping, since this patchset now exists as two branches (dl/format-patch-cover-letter-subject and dl/format-patch-doc-test-cleanup), would you prefer any new revisions exist as one big patchset or two separate patchsets targeting each individual branch?

I think any updates to the last step would need to build on top of the clean-up series. You might be able to add new tests and update docs in such a way that is independent from the clean-up and then worry about possible merge conflicts later, but with the clean-up series being in reasonably good shape already, I'd expect that the bigger clean-up series can be polished enough before we work on polishing the last step. So perhaps we just focus first on the clean-up series, have them graduate to 'master', and then build the new feature on top, perhaps?

author
#40 lore raw

cover format-patch: clean up tests and documentation

In reply to Denton Liu

*** BLURB HERE ***

As one of the older parts of the Git, the tests and documentation for format-patch have been needing cleanup for a while. Let's do that in this patchset!

This patchset is based on v3 of "format-patch: learn --infer-cover-subject option (also t4014 cleanup)"[1].

Changes since v3 of "format-patch: learn --infer-cover-subject option (also t4014 cleanup)":

* Squash in Junio's and Hannes' suggestions

* Add 't4014: let sed open its own files'

[1]: https://public-inbox.org/git/[email protected]/T/#m19570aff4828dfbd65d57cacf231c2938af1dc9f

Denton Liu (13):
t4014: drop unnecessary blank lines from test cases
t4014: s/expected/expect/
t4014: move closing sq onto its own line
t4014: use sq for test case names
t4014: remove spaces after redirect operators
t4014: use indentable here-docs
t4014: drop redirections to /dev/null
t4014: let sed open its own files
t4014: use test_line_count() where possible
t4014: remove confusing pipe in check_threading()
t4014: stop losing return codes of git commands
Doc: add more detail for git-format-patch config/format.txt: specify default value of format.coverLetter

 Documentation/config/format.txt    |   1 +
 Documentation/git-format-patch.txt |  23 +-
 t/t4014-format-patch.sh            | 814 ++++++++++++++---------------
 3 files changed, 421 insertions(+), 417 deletions(-)

Range-diff:

 1:  fb000bfca2 =  1:  fb000bfca2 t4014: drop unnecessary blank lines from test cases
 2:  568b3a03a0 !  2:  0a5ce9b95f t4014: s/expected/expect/

@@ Commit message
t4014: s/expected/expect/

For test cases, the usual convention is to name expected output files
- "expect", not "expected". Replace all instances with "expected" with
+ "expect", not "expected". Replace all instances of "expected" with
"expect" except for one case where the "expected" is used as the name of a test case.

 3:  a205a920bd =  3:  5c49703aa4 t4014: move closing sq onto its own line
 4:  66bf2e3dd4 =  4:  02a11147fd t4014: use sq for test case names
 5:  6f1371275e =  5:  8d9791c061 t4014: remove spaces after redirect operators
 6:  b4295846f5 =  6:  90ad0fcf70 t4014: use indentable here-docs
 7:  34315412c8 =  7:  804b3163f8 t4014: drop redirections to /dev/null
 -:  ---------- >  8:  7d9a24a979 t4014: let sed open its own files
 8:  de08dd886d =  9:  d068d42098 t4014: use test_line_count() where possible
 9:  dec5a62e82 = 10:  6a9409cee0 t4014: remove confusing pipe in check_threading()
10:  64069c0c54 ! 11:  c580ce447b t4014: stop losing return codes of git commands
    @@ t/t4014-format-patch.sh: test_expect_success 'format-patch --ignore-if-in-upstre
      
     -git_version="$(git --version | sed "s/.* //")"
     +test_expect_success 'get git version' '
    -+	git_version="$(git --version | sed "s/.* //")"
    ++	git_version=$(git --version) &&
    ++	git_version=${git_version##* }
     +'
      
      signature() {
11:  c12534ab5d = 12:  a97f861e6a Doc: add more detail for git-format-patch
12:  a08273ebcc <  -:  ---------- config/format.txt: specify default value of format.coverLetter
13:  de599f7ca9 <  -:  ---------- format-patch: learn --infer-cover-subject option
 -:  ---------- > 13:  7c8522abf2 config/format.txt: specify default value of format.coverLetter
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#41 lore raw

PATCH v3 1/13 t4014: drop unnecessary blank lines from test cases

---
 t/t4014-format-patch.sh | 47 -----------------------------------------
 1 file changed, 47 deletions(-)
t/t4014-format-patch.sh +0 -47
index ca7debf1d4..3ed3feabfe 100755
@@ -9,7 +9,6 @@ test_description='various format-patch tests'
 . "$TEST_DIRECTORY"/lib-terminal.sh
 
 test_expect_success setup '
-
 	for i in 1 2 3 4 5 6 7 8 9 10; do echo "$i"; done >file &&
 	cat file >elif &&
 	git add file elif &&
@@ -60,20 +59,16 @@ test_expect_success setup '
 '
 
 test_expect_success "format-patch --ignore-if-in-upstream" '
-
 	git format-patch --stdout master..side >patch0 &&
 	cnt=$(grep "^From " patch0 | wc -l) &&
 	test $cnt = 3
-
 '
 
 test_expect_success "format-patch --ignore-if-in-upstream" '
-
 	git format-patch --stdout \
 		--ignore-if-in-upstream master..side >patch1 &&
 	cnt=$(grep "^From " patch1 | wc -l) &&
 	test $cnt = 2
-
 '
 
 test_expect_success "format-patch --ignore-if-in-upstream handles tags" '
@@ -85,7 +80,6 @@ test_expect_success "format-patch --ignore-if-in-upstream handles tags" '
 '
 
 test_expect_success "format-patch doesn't consider merge commits" '
-
 	git checkout -b slave master &&
 	echo "Another line" >>file &&
 	test_tick &&
@@ -101,7 +95,6 @@ test_expect_success "format-patch doesn't consider merge commits" '
 '
 
 test_expect_success "format-patch result applies" '
-
 	git checkout -b rebuild-0 master &&
 	git am -3 patch0 &&
 	cnt=$(git rev-list master.. | wc -l) &&
@@ -109,7 +102,6 @@ test_expect_success "format-patch result applies" '
 '
 
 test_expect_success "format-patch --ignore-if-in-upstream result applies" '
-
 	git checkout -b rebuild-1 master &&
 	git am -3 patch1 &&
 	cnt=$(git rev-list master.. | wc -l) &&
@@ -117,26 +109,19 @@ test_expect_success "format-patch --ignore-if-in-upstream result applies" '
 '
 
 test_expect_success 'commit did not screw up the log message' '
-
 	git cat-file commit side | grep "^Side .* with .* backslash-n"
-
 '
 
 test_expect_success 'format-patch did not screw up the log message' '
-
 	grep "^Subject: .*Side changes #3 with .* backslash-n" patch0 &&
 	grep "^Subject: .*Side changes #3 with .* backslash-n" patch1
-
 '
 
 test_expect_success 'replay did not screw up the log message' '
-
 	git cat-file commit rebuild-1 | grep "^Side .* with .* backslash-n"
-
 '
 
 test_expect_success 'extra headers' '
-
 	git config format.headers "To: R E Cipient <[email protected]>
 " &&
 	git config --add format.headers "Cc: S E Cipient <[email protected]>
@@ -145,22 +130,18 @@ test_expect_success 'extra headers' '
 	sed -e "/^\$/q" patch2 > hdrs2 &&
 	grep "^To: R E Cipient <[email protected]>\$" hdrs2 &&
 	grep "^Cc: S E Cipient <[email protected]>\$" hdrs2
-
 '
 
 test_expect_success 'extra headers without newlines' '
-
 	git config --replace-all format.headers "To: R E Cipient <[email protected]>" &&
 	git config --add format.headers "Cc: S E Cipient <[email protected]>" &&
 	git format-patch --stdout master..side >patch3 &&
 	sed -e "/^\$/q" patch3 > hdrs3 &&
 	grep "^To: R E Cipient <[email protected]>\$" hdrs3 &&
 	grep "^Cc: S E Cipient <[email protected]>\$" hdrs3
-
 '
 
 test_expect_success 'extra headers with multiple To:s' '
-
 	git config --replace-all format.headers "To: R E Cipient <[email protected]>" &&
 	git config --add format.headers "To: S E Cipient <[email protected]>" &&
 	git format-patch --stdout master..side > patch4 &&
@@ -170,7 +151,6 @@ test_expect_success 'extra headers with multiple To:s' '
 '
 
 test_expect_success 'additional command line cc (ascii)' '
-
 	git config --replace-all format.headers "Cc: R E Cipient <[email protected]>" &&
 	git format-patch --cc="S E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch5 &&
 	grep "^Cc: R E Cipient <[email protected]>,\$" patch5 &&
@@ -178,7 +158,6 @@ test_expect_success 'additional command line cc (ascii)' '
 '
 
 test_expect_failure 'additional command line cc (rfc822)' '
-
 	git config --replace-all format.headers "Cc: R E Cipient <[email protected]>" &&
 	git format-patch --cc="S. E. Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch5 &&
 	grep "^Cc: R E Cipient <[email protected]>,\$" patch5 &&
@@ -186,14 +165,12 @@ test_expect_failure 'additional command line cc (rfc822)' '
 '
 
 test_expect_success 'command line headers' '
-
 	git config --unset-all format.headers &&
 	git format-patch --add-header="Cc: R E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch6 &&
 	grep "^Cc: R E Cipient <[email protected]>\$" patch6
 '
 
 test_expect_success 'configuration headers and command line headers' '
-
 	git config --replace-all format.headers "Cc: R E Cipient <[email protected]>" &&
 	git format-patch --add-header="Cc: S E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch7 &&
 	grep "^Cc: R E Cipient <[email protected]>,\$" patch7 &&
@@ -201,40 +178,34 @@ test_expect_success 'configuration headers and command line headers' '
 '
 
 test_expect_success 'command line To: header (ascii)' '
-
 	git config --unset-all format.headers &&
 	git format-patch --to="R E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
 	grep "^To: R E Cipient <[email protected]>\$" patch8
 '
 
 test_expect_failure 'command line To: header (rfc822)' '
-
 	git format-patch --to="R. E. Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
 	grep "^To: \"R. E. Cipient\" <[email protected]>\$" patch8
 '
 
 test_expect_failure 'command line To: header (rfc2047)' '
-
 	git format-patch --to="R Ä Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
 	grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected]>\$" patch8
 '
 
 test_expect_success 'configuration To: header (ascii)' '
-
 	git config format.to "R E Cipient <[email protected]>" &&
 	git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
 	grep "^To: R E Cipient <[email protected]>\$" patch9
 '
 
 test_expect_failure 'configuration To: header (rfc822)' '
-
 	git config format.to "R. E. Cipient <[email protected]>" &&
 	git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
 	grep "^To: \"R. E. Cipient\" <[email protected]>\$" patch9
 '
 
 test_expect_failure 'configuration To: header (rfc2047)' '
-
 	git config format.to "R Ä Cipient <[email protected]>" &&
 	git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
 	grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected]>\$" patch9
@@ -249,7 +220,6 @@ check_patch () {
 }
 
 test_expect_success 'format.from=false' '
-
 	git -c format.from=false format-patch --stdout master..side |
 	sed -e "/^\$/q" >patch &&
 	check_patch patch &&
@@ -257,7 +227,6 @@ test_expect_success 'format.from=false' '
 '
 
 test_expect_success 'format.from=true' '
-
 	git -c format.from=true format-patch --stdout master..side |
 	sed -e "/^\$/q" >patch &&
 	check_patch patch &&
@@ -265,7 +234,6 @@ test_expect_success 'format.from=true' '
 '
 
 test_expect_success 'format.from with address' '
-
 	git -c format.from="F R Om <[email protected]>" format-patch --stdout master..side |
 	sed -e "/^\$/q" >patch &&
 	check_patch patch &&
@@ -273,7 +241,6 @@ test_expect_success 'format.from with address' '
 '
 
 test_expect_success '--no-from overrides format.from' '
-
 	git -c format.from="F R Om <[email protected]>" format-patch --no-from --stdout master..side |
 	sed -e "/^\$/q" >patch &&
 	check_patch patch &&
@@ -281,7 +248,6 @@ test_expect_success '--no-from overrides format.from' '
 '
 
 test_expect_success '--from overrides format.from' '
-
 	git -c format.from="F R Om <[email protected]>" format-patch --from --stdout master..side |
 	sed -e "/^\$/q" >patch &&
 	check_patch patch &&
@@ -289,7 +255,6 @@ test_expect_success '--from overrides format.from' '
 '
 
 test_expect_success '--no-to overrides config.to' '
-
 	git config --replace-all format.to \
 		"R E Cipient <[email protected]>" &&
 	git format-patch --no-to --stdout master..side |
@@ -299,7 +264,6 @@ test_expect_success '--no-to overrides config.to' '
 '
 
 test_expect_success '--no-to and --to replaces config.to' '
-
 	git config --replace-all format.to \
 		"Someone <[email protected]>" &&
 	git format-patch --no-to --to="Someone Else <[email protected]>" \
@@ -311,7 +275,6 @@ test_expect_success '--no-to and --to replaces config.to' '
 '
 
 test_expect_success '--no-cc overrides config.cc' '
-
 	git config --replace-all format.cc \
 		"C E Cipient <[email protected]>" &&
 	git format-patch --no-cc --stdout master..side |
@@ -321,7 +284,6 @@ test_expect_success '--no-cc overrides config.cc' '
 '
 
 test_expect_success '--no-add-header overrides config.headers' '
-
 	git config --replace-all format.headers \
 		"Header1: B E Cipient <[email protected]>" &&
 	git format-patch --no-add-header --stdout master..side |
@@ -331,7 +293,6 @@ test_expect_success '--no-add-header overrides config.headers' '
 '
 
 test_expect_success 'multiple files' '
-
 	rm -rf patches/ &&
 	git checkout side &&
 	git format-patch -o patches/ master &&
@@ -594,7 +555,6 @@ test_expect_success 'thread config + --no-thread' '
 '
 
 test_expect_success 'excessive subject' '
-
 	rm -rf patches/ &&
 	git checkout side &&
 	before=$(git hash-object file) &&
@@ -622,7 +582,6 @@ test_expect_success 'cover-letter inherits diff options' '
 	! grep "file => foo .* 0 *\$" 0000-cover-letter.patch &&
 	git format-patch --cover-letter -1 -M &&
 	grep "file => foo .* 0 *\$" 0000-cover-letter.patch
-
 '
 
 cat > expect << EOF
@@ -636,11 +595,9 @@ cat > expect << EOF
 EOF
 
 test_expect_success 'shortlog of cover-letter wraps overly-long onelines' '
-
 	git format-patch --cover-letter -2 &&
 	sed -e "1,/A U Thor/d" -e "/^\$/q" < 0000-cover-letter.patch > output &&
 	test_cmp expect output
-
 '
 
 cat > expect << EOF
@@ -656,13 +613,11 @@ index $before..$after 100644
 EOF
 
 test_expect_success 'format-patch respects -U' '
-
 	git format-patch -U4 -2 &&
 	sed -e "1,/^diff/d" -e "/^+5/q" \
 		<0001-This-is-an-excessively-long-subject-line-for-a-messa.patch \
 		>output &&
 	test_cmp expect output
-
 '
 
 cat > expect << EOF
@@ -679,11 +634,9 @@ index $before..$after 100644
 EOF
 
 test_expect_success 'format-patch -p suppresses stat' '
-
 	git format-patch -p -2 &&
 	sed -e "1,/^\$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output &&
 	test_cmp expect output
-
 '
 
 test_expect_success 'format-patch from a subdirectory (1)' '
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#42 lore raw

PATCH v3 2/13 t4014: s/expected/expect/

In reply to Denton Liu

For test cases, the usual convention is to name expected output files "expect", not "expected". Replace all instances of "expected" with "expect" except for one case where the "expected" is used as the name of a test case.

---
 t/t4014-format-patch.sh | 106 ++++++++++++++++++++--------------------
 1 file changed, 53 insertions(+), 53 deletions(-)
t/t4014-format-patch.sh +53 -53
index 3ed3feabfe..62f5680f05 100755
@@ -1209,32 +1209,32 @@ append_signoff()
 
 test_expect_success 'signoff: commit with no body' '
 	append_signoff </dev/null >actual &&
-	cat <<\EOF | sed "s/EOL$//" >expected &&
+	cat <<\EOF | sed "s/EOL$//" >expect &&
 4:Subject: [PATCH] EOL
 8:
 9:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: commit with only subject' '
 	echo subject | append_signoff >actual &&
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 9:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: commit with only subject that does not end with NL' '
 	printf subject | append_signoff >actual &&
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 9:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: no existing signoffs' '
@@ -1243,24 +1243,24 @@ subject
 
 body
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
 11:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: no existing signoffs and no trailing NL' '
 	printf "subject\n\nbody" | append_signoff >actual &&
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
 11:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: some random signoff' '
@@ -1271,14 +1271,14 @@ body
 
 Signed-off-by: my@house
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
 11:Signed-off-by: my@house
 12:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: misc conforming footer elements' '
@@ -1292,14 +1292,14 @@ Signed-off-by: my@house
 Tested-by: Some One <[email protected]>
 Bug: 1234
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
 11:Signed-off-by: my@house
 15:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: some random signoff-alike' '
@@ -1309,13 +1309,13 @@ subject
 body
 Fooled-by-me: my@house
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 11:
 12:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: not really a signoff' '
@@ -1324,14 +1324,14 @@ subject
 
 I want to mention about Signed-off-by: here.
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 9:I want to mention about Signed-off-by: here.
 10:
 11:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: not really a signoff (2)' '
@@ -1341,13 +1341,13 @@ subject
 My unfortunate
 Signed-off-by: example happens to be wrapped here.
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:Signed-off-by: example happens to be wrapped here.
 11:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: valid S-o-b paragraph in the middle' '
@@ -1359,7 +1359,7 @@ Signed-off-by: your@house
 
 A lot of houses.
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 9:Signed-off-by: my@house
@@ -1368,7 +1368,7 @@ EOF
 13:
 14:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: the same signoff at the end' '
@@ -1379,24 +1379,24 @@ body
 
 Signed-off-by: C O Mitter <[email protected]>
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
 11:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: the same signoff at the end, no trailing NL' '
 	printf "subject\n\nSigned-off-by: C O Mitter <[email protected]>" |
 		append_signoff >actual &&
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 9:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: the same signoff NOT at the end' '
@@ -1408,14 +1408,14 @@ body
 Signed-off-by: C O Mitter <[email protected]>
 Signed-off-by: my@house
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
 11:Signed-off-by: C O Mitter <[email protected]>
 12:Signed-off-by: my@house
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: tolerate garbage in conforming footer' '
@@ -1428,13 +1428,13 @@ Tested-by: my@house
 Some Trash
 Signed-off-by: C O Mitter <[email protected]>
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
 13:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: respect trailer config' '
@@ -1444,13 +1444,13 @@ subject
 Myfooter: x
 Some Trash
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 11:
 12:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual &&
+	test_cmp expect actual &&
 
 	test_config trailer.Myfooter.ifexists add &&
 	append_signoff <<\EOF >actual &&
@@ -1459,12 +1459,12 @@ subject
 Myfooter: x
 Some Trash
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 11:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: footer begins with non-signoff without @ sign' '
@@ -1479,13 +1479,13 @@ Change-id: Ideadbeef
 Signed-off-by: C O Mitter <[email protected]>
 Bug: 1234
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
 14:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'format patch ignores color.ui' '
@@ -1604,13 +1604,13 @@ test_expect_success 'format-patch --base' '
 	git checkout patchid &&
 	git format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual1 &&
 	git format-patch --stdout --base=HEAD~3 HEAD~.. | tail -n 7 >actual2 &&
-	echo >expected &&
-	echo "base-commit: $(git rev-parse HEAD~3)" >>expected &&
-	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expected &&
-	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expected &&
-	signature >> expected &&
-	test_cmp expected actual1 &&
-	test_cmp expected actual2 &&
+	echo >expect &&
+	echo "base-commit: $(git rev-parse HEAD~3)" >>expect &&
+	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expect &&
+	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expect &&
+	signature >> expect &&
+	test_cmp expect actual1 &&
+	test_cmp expect actual2 &&
 	echo >fail &&
 	echo "base-commit: $(git rev-parse HEAD~3)" >>fail &&
 	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --unstable | awk "{print \$1}")" >>fail &&
@@ -1625,8 +1625,8 @@ test_expect_success 'format-patch --base errors out when base commit is in revis
 	test_must_fail git format-patch --base=HEAD~1 -2 &&
 	git format-patch --stdout --base=HEAD~2 -2 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse HEAD~2)" >expected &&
-	test_cmp expected actual
+	echo "base-commit: $(git rev-parse HEAD~2)" >expect &&
+	test_cmp expect actual
 '
 
 test_expect_success 'format-patch --base errors out when base commit is not ancestor of revision list' '
@@ -1652,8 +1652,8 @@ test_expect_success 'format-patch --base errors out when base commit is not ance
 	test_must_fail git format-patch --base=$(cat commit-id-Z) -3 &&
 	git format-patch --stdout --base=$(cat commit-id-base) -3 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(cat commit-id-base)" >expected &&
-	test_cmp expected actual
+	echo "base-commit: $(cat commit-id-base)" >expect &&
+	test_cmp expect actual
 '
 
 test_expect_success 'format-patch --base=auto' '
@@ -1664,8 +1664,8 @@ test_expect_success 'format-patch --base=auto' '
 	test_commit N2 &&
 	git format-patch --stdout --base=auto -2 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse upstream)" >expected &&
-	test_cmp expected actual
+	echo "base-commit: $(git rev-parse upstream)" >expect &&
+	test_cmp expect actual
 '
 
 test_expect_success 'format-patch errors out when history involves criss-cross' '
@@ -1701,8 +1701,8 @@ test_expect_success 'format-patch format.useAutoBaseoption' '
 	git config format.useAutoBase true &&
 	git format-patch --stdout -1 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse upstream)" >expected &&
-	test_cmp expected actual
+	echo "base-commit: $(git rev-parse upstream)" >expect &&
+	test_cmp expect actual
 '
 
 test_expect_success 'format-patch --base overrides format.useAutoBase' '
@@ -1710,8 +1710,8 @@ test_expect_success 'format-patch --base overrides format.useAutoBase' '
 	git config format.useAutoBase true &&
 	git format-patch --stdout --base=HEAD~1 -1 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse HEAD~1)" >expected &&
-	test_cmp expected actual
+	echo "base-commit: $(git rev-parse HEAD~1)" >expect &&
+	test_cmp expect actual
 '
 
 test_expect_success 'format-patch --base with --attach' '
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#43 lore raw

PATCH v3 3/13 t4014: move closing sq onto its own line

In reply to Denton Liu

The usual convention for test cases is for the closing sq to be on its own line. Move the sq onto its own line for cases that do not conform to this style.

---
 t/t4014-format-patch.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
t/t4014-format-patch.sh +4 -2
index 62f5680f05..5e8eb6fb27 100755
@@ -790,11 +790,13 @@ test_expect_success 'options no longer allowed for format-patch' '
 	test_must_fail git format-patch --name-status 2> output &&
 	test_i18ncmp expect.name-status output &&
 	test_must_fail git format-patch --check 2> output &&
-	test_i18ncmp expect.check output'
+	test_i18ncmp expect.check output
+'
 
 test_expect_success 'format-patch --numstat should produce a patch' '
 	git format-patch --numstat --stdout master..side > output &&
-	test 5 = $(grep "^diff --git a/" output | wc -l)'
+	test 5 = $(grep "^diff --git a/" output | wc -l)
+'
 
 test_expect_success 'format-patch -- <path>' '
 	git format-patch master..side -- file 2>error &&
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#44 lore raw

PATCH v3 4/13 t4014: use sq for test case names

In reply to Denton Liu

The usual convention is for test case names to be written between single-quotes. Change all double-quoted test case names to single-quotes except for one test case name that uses a sq for a contraction.

---
 t/t4014-format-patch.sh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
t/t4014-format-patch.sh +5 -5
index 5e8eb6fb27..a7b440b003 100755
@@ -58,20 +58,20 @@ test_expect_success setup '
 	git checkout master
 '
 
-test_expect_success "format-patch --ignore-if-in-upstream" '
+test_expect_success 'format-patch --ignore-if-in-upstream' '
 	git format-patch --stdout master..side >patch0 &&
 	cnt=$(grep "^From " patch0 | wc -l) &&
 	test $cnt = 3
 '
 
-test_expect_success "format-patch --ignore-if-in-upstream" '
+test_expect_success 'format-patch --ignore-if-in-upstream' '
 	git format-patch --stdout \
 		--ignore-if-in-upstream master..side >patch1 &&
 	cnt=$(grep "^From " patch1 | wc -l) &&
 	test $cnt = 2
 '
 
-test_expect_success "format-patch --ignore-if-in-upstream handles tags" '
+test_expect_success 'format-patch --ignore-if-in-upstream handles tags' '
 	git tag -a v1 -m tag side &&
 	git tag -a v2 -m tag master &&
 	git format-patch --stdout --ignore-if-in-upstream v2..v1 >patch1 &&
@@ -94,14 +94,14 @@ test_expect_success "format-patch doesn't consider merge commits" '
 	test $cnt = 3
 '
 
-test_expect_success "format-patch result applies" '
+test_expect_success 'format-patch result applies' '
 	git checkout -b rebuild-0 master &&
 	git am -3 patch0 &&
 	cnt=$(git rev-list master.. | wc -l) &&
 	test $cnt = 2
 '
 
-test_expect_success "format-patch --ignore-if-in-upstream result applies" '
+test_expect_success 'format-patch --ignore-if-in-upstream result applies' '
 	git checkout -b rebuild-1 master &&
 	git am -3 patch1 &&
 	cnt=$(git rev-list master.. | wc -l) &&
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#45 lore raw

PATCH v3 5/13 t4014: remove spaces after redirect operators

In reply to Denton Liu

For shell scripts, the usual convention is for there to be no space after redirection operators, (e.g. >file, not > file). Remove these spaces wherever they appear.

---
 t/t4014-format-patch.sh | 62 ++++++++++++++++++++---------------------
 1 file changed, 31 insertions(+), 31 deletions(-)
t/t4014-format-patch.sh +31 -31
index a7b440b003..075affb1e5 100755
@@ -126,8 +126,8 @@ test_expect_success 'extra headers' '
 " &&
 	git config --add format.headers "Cc: S E Cipient <[email protected]>
 " &&
-	git format-patch --stdout master..side > patch2 &&
-	sed -e "/^\$/q" patch2 > hdrs2 &&
+	git format-patch --stdout master..side >patch2 &&
+	sed -e "/^\$/q" patch2 >hdrs2 &&
 	grep "^To: R E Cipient <[email protected]>\$" hdrs2 &&
 	grep "^Cc: S E Cipient <[email protected]>\$" hdrs2
 '
@@ -136,7 +136,7 @@ test_expect_success 'extra headers without newlines' '
 	git config --replace-all format.headers "To: R E Cipient <[email protected]>" &&
 	git config --add format.headers "Cc: S E Cipient <[email protected]>" &&
 	git format-patch --stdout master..side >patch3 &&
-	sed -e "/^\$/q" patch3 > hdrs3 &&
+	sed -e "/^\$/q" patch3 >hdrs3 &&
 	grep "^To: R E Cipient <[email protected]>\$" hdrs3 &&
 	grep "^Cc: S E Cipient <[email protected]>\$" hdrs3
 '
@@ -144,8 +144,8 @@ test_expect_success 'extra headers without newlines' '
 test_expect_success 'extra headers with multiple To:s' '
 	git config --replace-all format.headers "To: R E Cipient <[email protected]>" &&
 	git config --add format.headers "To: S E Cipient <[email protected]>" &&
-	git format-patch --stdout master..side > patch4 &&
-	sed -e "/^\$/q" patch4 > hdrs4 &&
+	git format-patch --stdout master..side >patch4 &&
+	sed -e "/^\$/q" patch4 >hdrs4 &&
 	grep "^To: R E Cipient <[email protected]>,\$" hdrs4 &&
 	grep "^ *S E Cipient <[email protected]>\$" hdrs4
 '
@@ -318,7 +318,7 @@ test_expect_success 'reroll count (-v)' '
 check_threading () {
 	expect="$1" &&
 	shift &&
-	(git format-patch --stdout "$@"; echo $? > status.out) |
+	(git format-patch --stdout "$@"; echo $? >status.out) |
 	# Prints everything between the Message-ID and In-Reply-To,
 	# and replaces all Message-ID-lookalikes by a sequence number
 	perl -ne '
@@ -333,12 +333,12 @@ check_threading () {
 			print;
 		}
 		print "---\n" if /^From /i;
-	' > actual &&
+	' >actual &&
 	test 0 = "$(cat status.out)" &&
 	test_cmp "$expect" actual
 }
 
-cat >> expect.no-threading <<EOF
+cat >>expect.no-threading <<EOF
 ---
 ---
 ---
@@ -349,7 +349,7 @@ test_expect_success 'no threading' '
 	check_threading expect.no-threading master
 '
 
-cat > expect.thread <<EOF
+cat >expect.thread <<EOF
 ---
 Message-Id: <0>
 ---
@@ -366,7 +366,7 @@ test_expect_success 'thread' '
 	check_threading expect.thread --thread master
 '
 
-cat > expect.in-reply-to <<EOF
+cat >expect.in-reply-to <<EOF
 ---
 Message-Id: <0>
 In-Reply-To: <1>
@@ -386,7 +386,7 @@ test_expect_success 'thread in-reply-to' '
 		--thread master
 '
 
-cat > expect.cover-letter <<EOF
+cat >expect.cover-letter <<EOF
 ---
 Message-Id: <0>
 ---
@@ -407,7 +407,7 @@ test_expect_success 'thread cover-letter' '
 	check_threading expect.cover-letter --cover-letter --thread master
 '
 
-cat > expect.cl-irt <<EOF
+cat >expect.cl-irt <<EOF
 ---
 Message-Id: <0>
 In-Reply-To: <1>
@@ -439,7 +439,7 @@ test_expect_success 'thread explicit shallow' '
 		--in-reply-to="<test.message>" --thread=shallow master
 '
 
-cat > expect.deep <<EOF
+cat >expect.deep <<EOF
 ---
 Message-Id: <0>
 ---
@@ -457,7 +457,7 @@ test_expect_success 'thread deep' '
 	check_threading expect.deep --thread=deep master
 '
 
-cat > expect.deep-irt <<EOF
+cat >expect.deep-irt <<EOF
 ---
 Message-Id: <0>
 In-Reply-To: <1>
@@ -480,7 +480,7 @@ test_expect_success 'thread deep in-reply-to' '
 		--in-reply-to="<test.message>" master
 '
 
-cat > expect.deep-cl <<EOF
+cat >expect.deep-cl <<EOF
 ---
 Message-Id: <0>
 ---
@@ -504,7 +504,7 @@ test_expect_success 'thread deep cover-letter' '
 	check_threading expect.deep-cl --cover-letter --thread=deep master
 '
 
-cat > expect.deep-cl-irt <<EOF
+cat >expect.deep-cl-irt <<EOF
 ---
 Message-Id: <0>
 In-Reply-To: <1>
@@ -584,7 +584,7 @@ test_expect_success 'cover-letter inherits diff options' '
 	grep "file => foo .* 0 *\$" 0000-cover-letter.patch
 '
 
-cat > expect << EOF
+cat >expect <<EOF
   This is an excessively long subject line for a message due to the
     habit some projects have of not having a short, one-line subject at
     the start of the commit message, but rather sticking a whole
@@ -596,11 +596,11 @@ EOF
 
 test_expect_success 'shortlog of cover-letter wraps overly-long onelines' '
 	git format-patch --cover-letter -2 &&
-	sed -e "1,/A U Thor/d" -e "/^\$/q" < 0000-cover-letter.patch > output &&
+	sed -e "1,/A U Thor/d" -e "/^\$/q" <0000-cover-letter.patch >output &&
 	test_cmp expect output
 '
 
-cat > expect << EOF
+cat >expect <<EOF
 index $before..$after 100644
 --- a/file
 +++ b/file
@@ -620,7 +620,7 @@ test_expect_success 'format-patch respects -U' '
 	test_cmp expect output
 '
 
-cat > expect << EOF
+cat >expect <<EOF
 
 diff --git a/file b/file
 index $before..$after 100644
@@ -635,7 +635,7 @@ EOF
 
 test_expect_success 'format-patch -p suppresses stat' '
 	git format-patch -p -2 &&
-	sed -e "1,/^\$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output &&
+	sed -e "1,/^\$/d" -e "/^+5/q" <0001-This-is-an-excessively-long-subject-line-for-a-messa.patch >output &&
 	test_cmp expect output
 '
 
@@ -689,7 +689,7 @@ test_expect_success 'format-patch from a subdirectory (3)' '
 '
 
 test_expect_success 'format-patch --in-reply-to' '
-	git format-patch -1 --stdout --in-reply-to "[email protected]" > patch8 &&
+	git format-patch -1 --stdout --in-reply-to "[email protected]" >patch8 &&
 	grep "^In-Reply-To: <[email protected]>" patch8 &&
 	grep "^References: <[email protected]>" patch8
 '
@@ -780,21 +780,21 @@ test_expect_success 'format-patch with multiple notes refs' '
 	! grep "this is note 2" out
 '
 
-echo "fatal: --name-only does not make sense" > expect.name-only
-echo "fatal: --name-status does not make sense" > expect.name-status
-echo "fatal: --check does not make sense" > expect.check
+echo "fatal: --name-only does not make sense" >expect.name-only
+echo "fatal: --name-status does not make sense" >expect.name-status
+echo "fatal: --check does not make sense" >expect.check
 
 test_expect_success 'options no longer allowed for format-patch' '
-	test_must_fail git format-patch --name-only 2> output &&
+	test_must_fail git format-patch --name-only 2>output &&
 	test_i18ncmp expect.name-only output &&
-	test_must_fail git format-patch --name-status 2> output &&
+	test_must_fail git format-patch --name-status 2>output &&
 	test_i18ncmp expect.name-status output &&
-	test_must_fail git format-patch --check 2> output &&
+	test_must_fail git format-patch --check 2>output &&
 	test_i18ncmp expect.check output
 '
 
 test_expect_success 'format-patch --numstat should produce a patch' '
-	git format-patch --numstat --stdout master..side > output &&
+	git format-patch --numstat --stdout master..side >output &&
 	test 5 = $(grep "^diff --git a/" output | wc -l)
 '
 
@@ -1610,14 +1610,14 @@ test_expect_success 'format-patch --base' '
 	echo "base-commit: $(git rev-parse HEAD~3)" >>expect &&
 	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expect &&
 	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expect &&
-	signature >> expect &&
+	signature >>expect &&
 	test_cmp expect actual1 &&
 	test_cmp expect actual2 &&
 	echo >fail &&
 	echo "base-commit: $(git rev-parse HEAD~3)" >>fail &&
 	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --unstable | awk "{print \$1}")" >>fail &&
 	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --unstable | awk "{print \$1}")" >>fail &&
-	signature >> fail &&
+	signature >>fail &&
 	! test_cmp fail actual1 &&
 	! test_cmp fail actual2
 '
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#46 lore raw

PATCH v3 6/13 t4014: use indentable here-docs

In reply to Denton Liu

The convention is to use indentable here-docs within test cases so that the here-docs line up with the rest of the code within the test case. Change here-docs from <<\EOF to <<-\EOF so that they can be indented along with the rest of the test case.

---
 t/t4014-format-patch.sh | 368 ++++++++++++++++++++--------------------
 1 file changed, 184 insertions(+), 184 deletions(-)
t/t4014-format-patch.sh +184 -184
index 075affb1e5..c07d868491 100755
@@ -1211,282 +1211,282 @@ append_signoff()
 
 test_expect_success 'signoff: commit with no body' '
 	append_signoff </dev/null >actual &&
-	cat <<\EOF | sed "s/EOL$//" >expect &&
-4:Subject: [PATCH] EOL
-8:
-9:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	cat <<-\EOF | sed "s/EOL$//" >expect &&
+	4:Subject: [PATCH] EOL
+	8:
+	9:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: commit with only subject' '
 	echo subject | append_signoff >actual &&
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-9:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	9:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: commit with only subject that does not end with NL' '
 	printf subject | append_signoff >actual &&
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-9:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	9:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: no existing signoffs' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-11:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	body
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	11:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: no existing signoffs and no trailing NL' '
 	printf "subject\n\nbody" | append_signoff >actual &&
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-11:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	11:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: some random signoff' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
+	body
 
-Signed-off-by: my@house
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-11:Signed-off-by: my@house
-12:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	Signed-off-by: my@house
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	11:Signed-off-by: my@house
+	12:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: misc conforming footer elements' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
+	body
 
-Signed-off-by: my@house
-(cherry picked from commit da39a3ee5e6b4b0d3255bfef95601890afd80709)
-Tested-by: Some One <[email protected]>
-Bug: 1234
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-11:Signed-off-by: my@house
-15:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	Signed-off-by: my@house
+	(cherry picked from commit da39a3ee5e6b4b0d3255bfef95601890afd80709)
+	Tested-by: Some One <[email protected]>
+	Bug: 1234
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	11:Signed-off-by: my@house
+	15:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: some random signoff-alike' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
-Fooled-by-me: my@house
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-11:
-12:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	body
+	Fooled-by-me: my@house
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	11:
+	12:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: not really a signoff' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-I want to mention about Signed-off-by: here.
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-9:I want to mention about Signed-off-by: here.
-10:
-11:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	I want to mention about Signed-off-by: here.
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	9:I want to mention about Signed-off-by: here.
+	10:
+	11:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: not really a signoff (2)' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-My unfortunate
-Signed-off-by: example happens to be wrapped here.
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:Signed-off-by: example happens to be wrapped here.
-11:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	My unfortunate
+	Signed-off-by: example happens to be wrapped here.
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:Signed-off-by: example happens to be wrapped here.
+	11:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: valid S-o-b paragraph in the middle' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-Signed-off-by: my@house
-Signed-off-by: your@house
+	Signed-off-by: my@house
+	Signed-off-by: your@house
 
-A lot of houses.
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-9:Signed-off-by: my@house
-10:Signed-off-by: your@house
-11:
-13:
-14:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	A lot of houses.
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	9:Signed-off-by: my@house
+	10:Signed-off-by: your@house
+	11:
+	13:
+	14:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: the same signoff at the end' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
+	body
 
-Signed-off-by: C O Mitter <[email protected]>
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-11:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	11:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: the same signoff at the end, no trailing NL' '
 	printf "subject\n\nSigned-off-by: C O Mitter <[email protected]>" |
 		append_signoff >actual &&
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-9:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	9:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: the same signoff NOT at the end' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
+	body
 
-Signed-off-by: C O Mitter <[email protected]>
-Signed-off-by: my@house
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-11:Signed-off-by: C O Mitter <[email protected]>
-12:Signed-off-by: my@house
-EOF
+	Signed-off-by: C O Mitter <[email protected]>
+	Signed-off-by: my@house
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	11:Signed-off-by: C O Mitter <[email protected]>
+	12:Signed-off-by: my@house
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: tolerate garbage in conforming footer' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
+	body
 
-Tested-by: my@house
-Some Trash
-Signed-off-by: C O Mitter <[email protected]>
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-13:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	Tested-by: my@house
+	Some Trash
+	Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	13:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: respect trailer config' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-Myfooter: x
-Some Trash
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-11:
-12:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	Myfooter: x
+	Some Trash
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	11:
+	12:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual &&
 
 	test_config trailer.Myfooter.ifexists add &&
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-Myfooter: x
-Some Trash
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-11:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	Myfooter: x
+	Some Trash
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	11:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: footer begins with non-signoff without @ sign' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
+	body
 
-Reviewed-id: Noone
-Tested-by: my@house
-Change-id: Ideadbeef
-Signed-off-by: C O Mitter <[email protected]>
-Bug: 1234
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-14:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	Reviewed-id: Noone
+	Tested-by: my@house
+	Change-id: Ideadbeef
+	Signed-off-by: C O Mitter <[email protected]>
+	Bug: 1234
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	14:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#47 lore raw

PATCH v3 7/13 t4014: drop redirections to /dev/null

In reply to Denton Liu

Since output is silenced when running without -v and debugging output is useful with -v, remove redirections to /dev/null as it is not useful.

---
 t/t4014-format-patch.sh | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
t/t4014-format-patch.sh +6 -6
index c07d868491..2048fb2008 100755
@@ -1502,42 +1502,42 @@ test_expect_success 'cover letter using branch description (1)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
 	git format-patch --stdout --cover-letter master >actual &&
-	grep hello actual >/dev/null
+	grep hello actual
 '
 
 test_expect_success 'cover letter using branch description (2)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
 	git format-patch --stdout --cover-letter rebuild-1~2..rebuild-1 >actual &&
-	grep hello actual >/dev/null
+	grep hello actual
 '
 
 test_expect_success 'cover letter using branch description (3)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
 	git format-patch --stdout --cover-letter ^master rebuild-1 >actual &&
-	grep hello actual >/dev/null
+	grep hello actual
 '
 
 test_expect_success 'cover letter using branch description (4)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
 	git format-patch --stdout --cover-letter master.. >actual &&
-	grep hello actual >/dev/null
+	grep hello actual
 '
 
 test_expect_success 'cover letter using branch description (5)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
 	git format-patch --stdout --cover-letter -2 HEAD >actual &&
-	grep hello actual >/dev/null
+	grep hello actual
 '
 
 test_expect_success 'cover letter using branch description (6)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
 	git format-patch --stdout --cover-letter -2 >actual &&
-	grep hello actual >/dev/null
+	grep hello actual
 '
 
 test_expect_success 'cover letter with nothing' '
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#48 lore raw

PATCH v3 8/13 t4014: let sed open its own files

In reply to Denton Liu

In some cases, we were using a redirection operator to feed input into sed. However, since sed is capable of opening its own files and provides better error messages on IO failure, make sed open its own files instead of redirecting input into it.

---
 t/t4014-format-patch.sh | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
t/t4014-format-patch.sh +14 -14
index 2048fb2008..35cf798847 100755
@@ -596,7 +596,7 @@ EOF
 
 test_expect_success 'shortlog of cover-letter wraps overly-long onelines' '
 	git format-patch --cover-letter -2 &&
-	sed -e "1,/A U Thor/d" -e "/^\$/q" <0000-cover-letter.patch >output &&
+	sed -e "1,/A U Thor/d" -e "/^\$/q" 0000-cover-letter.patch >output &&
 	test_cmp expect output
 '
 
@@ -635,7 +635,7 @@ EOF
 
 test_expect_success 'format-patch -p suppresses stat' '
 	git format-patch -p -2 &&
-	sed -e "1,/^\$/d" -e "/^+5/q" <0001-This-is-an-excessively-long-subject-line-for-a-messa.patch >output &&
+	sed -e "1,/^\$/d" -e "/^+5/q" 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch >output &&
 	test_cmp expect output
 '
 
@@ -890,7 +890,7 @@ test_expect_success 'prepare mail-signature input' '
 test_expect_success '--signature-file=file works' '
 	git format-patch --stdout --signature-file=mail-signature -1 >output &&
 	check_patch output &&
-	sed -e "1,/^-- \$/d" <output >actual &&
+	sed -e "1,/^-- \$/d" output >actual &&
 	{
 		cat mail-signature && echo
 	} >expect &&
@@ -901,7 +901,7 @@ test_expect_success 'format.signaturefile works' '
 	test_config format.signaturefile mail-signature &&
 	git format-patch --stdout -1 >output &&
 	check_patch output &&
-	sed -e "1,/^-- \$/d" <output >actual &&
+	sed -e "1,/^-- \$/d" output >actual &&
 	{
 		cat mail-signature && echo
 	} >expect &&
@@ -923,7 +923,7 @@ test_expect_success '--signature-file overrides format.signaturefile' '
 	git format-patch --stdout \
 			--signature-file=other-mail-signature -1 >output &&
 	check_patch output &&
-	sed -e "1,/^-- \$/d" <output >actual &&
+	sed -e "1,/^-- \$/d" output >actual &&
 	{
 		cat other-mail-signature && echo
 	} >expect &&
@@ -992,7 +992,7 @@ test_expect_success 'format-patch wraps extremely long subject (ascii)' '
 	git add file &&
 	git commit -m "$M512" &&
 	git format-patch --stdout -1 >patch &&
-	sed -n "/^Subject/p; /^ /p; /^$/q" <patch >subject &&
+	sed -n "/^Subject/p; /^ /p; /^$/q" patch >subject &&
 	test_cmp expect subject
 '
 
@@ -1031,7 +1031,7 @@ test_expect_success 'format-patch wraps extremely long subject (rfc2047)' '
 	git add file &&
 	git commit -m "$M512" &&
 	git format-patch --stdout -1 >patch &&
-	sed -n "/^Subject/p; /^ /p; /^$/q" <patch >subject &&
+	sed -n "/^Subject/p; /^ /p; /^$/q" patch >subject &&
 	test_cmp expect subject
 '
 
@@ -1040,7 +1040,7 @@ check_author() {
 	git add file &&
 	GIT_AUTHOR_NAME=$1 git commit -m author-check &&
 	git format-patch --stdout -1 >patch &&
-	sed -n "/^From: /p; /^ /p; /^$/q" <patch >actual &&
+	sed -n "/^From: /p; /^ /p; /^$/q" patch >actual &&
 	test_cmp expect actual
 }
 
@@ -1160,7 +1160,7 @@ test_expect_success '--from=ident replaces author' '
 	From: A U Thor <[email protected]>
 
 	EOF
-	sed -ne "/^From:/p; /^$/p; /^---$/q" <patch >patch.head &&
+	sed -ne "/^From:/p; /^$/p; /^---$/q" patch >patch.head &&
 	test_cmp expect patch.head
 '
 
@@ -1172,7 +1172,7 @@ test_expect_success '--from uses committer ident' '
 	From: A U Thor <[email protected]>
 
 	EOF
-	sed -ne "/^From:/p; /^$/p; /^---$/q" <patch >patch.head &&
+	sed -ne "/^From:/p; /^$/p; /^---$/q" patch >patch.head &&
 	test_cmp expect patch.head
 '
 
@@ -1182,7 +1182,7 @@ test_expect_success '--from omits redundant in-body header' '
 	From: A U Thor <[email protected]>
 
 	EOF
-	sed -ne "/^From:/p; /^$/p; /^---$/q" <patch >patch.head &&
+	sed -ne "/^From:/p; /^$/p; /^---$/q" patch >patch.head &&
 	test_cmp expect patch.head
 '
 
@@ -1197,7 +1197,7 @@ test_expect_success 'in-body headers trigger content encoding' '
 	From: éxötìc <[email protected]>
 
 	EOF
-	sed -ne "/^From:/p; /^$/p; /^Content-Type/p; /^---$/q" <patch >patch.head &&
+	sed -ne "/^From:/p; /^$/p; /^Content-Type/p; /^---$/q" patch >patch.head &&
 	test_cmp expect patch.head
 '
 
@@ -1788,7 +1788,7 @@ test_expect_success 'interdiff: cover-letter' '
 	git format-patch --cover-letter --interdiff=boop~2 -1 boop &&
 	test_i18ngrep "^Interdiff:$" 0000-cover-letter.patch &&
 	test_i18ngrep ! "^Interdiff:$" 0001-fleep.patch &&
-	sed "1,/^@@ /d; /^-- $/q" <0000-cover-letter.patch >actual &&
+	sed "1,/^@@ /d; /^-- $/q" 0000-cover-letter.patch >actual &&
 	test_cmp expect actual
 '
 
@@ -1804,7 +1804,7 @@ test_expect_success 'interdiff: solo-patch' '
 	EOF
 	git format-patch --interdiff=boop~2 -1 boop &&
 	test_i18ngrep "^Interdiff:$" 0001-fleep.patch &&
-	sed "1,/^  @@ /d; /^$/q" <0001-fleep.patch >actual &&
+	sed "1,/^  @@ /d; /^$/q" 0001-fleep.patch >actual &&
 	test_cmp expect actual
 '
 
Signature · 1 line
2.23.0.248.g3a9dd8fb08
#49 lore raw

Re: [PATCH 08/13] t4014: let sed open its own files

Quoted 4 lines · Denton Liu

In some cases, we were using a redirection operator to feed input into sed. However, since sed is capable of opening its own files and provides better error messages on IO failure, make sed open its own files instead of redirecting input into it.

I don't care strongly one way or the other, but the justification of "better error message" is rather weak:

    % sed '/^$/d' <foo
    sh: foo: No such file or directory
    % sed '/^$/d' foo
    sed: foo: No such file or directory
    %

I doubt it's worth a re-roll, though.

Quoted 1 line
author
#50 lore raw

PATCH v3 9/13 t4014: use test_line_count() where possible

In reply to Denton Liu

Convert all instances of cnt=$(... | wc -l) && test $cnt = N into uses of test_line_count().

While we're at it, convert one instance of a Git command upstream of a pipe into two commands. This prevents a failure of a Git command from being masked since only the return code of the last member of the pipe is shown.

---
 t/t4014-format-patch.sh | 35 +++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)
t/t4014-format-patch.sh +19 -16
index 35cf798847..18142ee5fa 100755
@@ -60,23 +60,23 @@ test_expect_success setup '
 
 test_expect_success 'format-patch --ignore-if-in-upstream' '
 	git format-patch --stdout master..side >patch0 &&
-	cnt=$(grep "^From " patch0 | wc -l) &&
-	test $cnt = 3
+	grep "^From " patch0 >from0 &&
+	test_line_count = 3 from0
 '
 
 test_expect_success 'format-patch --ignore-if-in-upstream' '
 	git format-patch --stdout \
 		--ignore-if-in-upstream master..side >patch1 &&
-	cnt=$(grep "^From " patch1 | wc -l) &&
-	test $cnt = 2
+	grep "^From " patch1 >from1 &&
+	test_line_count = 2 from1
 '
 
 test_expect_success 'format-patch --ignore-if-in-upstream handles tags' '
 	git tag -a v1 -m tag side &&
 	git tag -a v2 -m tag master &&
 	git format-patch --stdout --ignore-if-in-upstream v2..v1 >patch1 &&
-	cnt=$(grep "^From " patch1 | wc -l) &&
-	test $cnt = 2
+	grep "^From " patch1 >from1 &&
+	test_line_count = 2 from1
 '
 
 test_expect_success "format-patch doesn't consider merge commits" '
@@ -90,22 +90,23 @@ test_expect_success "format-patch doesn't consider merge commits" '
 	git checkout -b merger master &&
 	test_tick &&
 	git merge --no-ff slave &&
-	cnt=$(git format-patch -3 --stdout | grep "^From " | wc -l) &&
-	test $cnt = 3
+	git format-patch -3 --stdout >patch &&
+	grep "^From " patch >from &&
+	test_line_count = 3 from
 '
 
 test_expect_success 'format-patch result applies' '
 	git checkout -b rebuild-0 master &&
 	git am -3 patch0 &&
-	cnt=$(git rev-list master.. | wc -l) &&
-	test $cnt = 2
+	git rev-list master.. >list &&
+	test_line_count = 2 list
 '
 
 test_expect_success 'format-patch --ignore-if-in-upstream result applies' '
 	git checkout -b rebuild-1 master &&
 	git am -3 patch1 &&
-	cnt=$(git rev-list master.. | wc -l) &&
-	test $cnt = 2
+	git rev-list master.. >list &&
+	test_line_count = 2 list
 '
 
 test_expect_success 'commit did not screw up the log message' '
@@ -795,7 +796,8 @@ test_expect_success 'options no longer allowed for format-patch' '
 
 test_expect_success 'format-patch --numstat should produce a patch' '
 	git format-patch --numstat --stdout master..side >output &&
-	test 5 = $(grep "^diff --git a/" output | wc -l)
+	grep "^diff --git a/" output >diff &&
+	test_line_count = 5 diff
 '
 
 test_expect_success 'format-patch -- <path>' '
@@ -852,8 +854,8 @@ test_expect_success 'format-patch --signature --cover-letter' '
 	git config --unset-all format.signature &&
 	git format-patch --stdout --signature="my sig" --cover-letter \
 		-1 >output &&
-	grep "my sig" output &&
-	test 2 = $(grep "my sig" output | wc -l)
+	grep "my sig" output >sig &&
+	test_line_count = 2 sig
 '
 
 test_expect_success 'format.signature="" suppresses signatures' '
@@ -1591,7 +1593,8 @@ test_expect_success 'format-patch format.outputDirectory option' '
 	test_config format.outputDirectory patches &&
 	rm -fr patches &&
 	git format-patch master..side &&
-	test $(git rev-list master..side | wc -l) -eq $(ls patches | wc -l)
+	git rev-list master..side >list &&
+	test_line_count = $(ls patches | wc -l) list
 '
 
 test_expect_success 'format-patch -o overrides format.outputDirectory' '
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#51 lore raw

PATCH v3 10/13 t4014: remove confusing pipe in check_threading()

In reply to Denton Liu

In check_threading(), there was a Git command in the upstream of a pipe. In order to not lose its status code, it was saved into a file. However, this may be confusing so rewrite to redirect IO to file. This allows us to directly use the conventional &&-chain.

---
 t/t4014-format-patch.sh | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
t/t4014-format-patch.sh +2 -3
index 18142ee5fa..67f4c62ed6 100755
@@ -319,7 +319,7 @@ test_expect_success 'reroll count (-v)' '
 check_threading () {
 	expect="$1" &&
 	shift &&
-	(git format-patch --stdout "$@"; echo $? >status.out) |
+	git format-patch --stdout "$@" >patch &&
 	# Prints everything between the Message-ID and In-Reply-To,
 	# and replaces all Message-ID-lookalikes by a sequence number
 	perl -ne '
@@ -334,8 +334,7 @@ check_threading () {
 			print;
 		}
 		print "---\n" if /^From /i;
-	' >actual &&
-	test 0 = "$(cat status.out)" &&
+	' <patch >actual &&
 	test_cmp "$expect" actual
 }
 
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#52 lore raw

PATCH v3 11/13 t4014: stop losing return codes of git commands

In reply to Denton Liu

Currently, there are two ways where the return codes of Git commands are lost. The first way is when a command is in the upstream of a pipe. In a pipe, only the return code of the last command is used. Thus, all other commands will have their return codes masked. Rewrite pipes so that there are no Git commands upstream.

The other way is when a command is in a non-assignment subshell. The return code will be lost in favour of the surrounding command's. Rewrite instances of this such that Git commands output to a file and surrounding commands only call subshells with non-Git commands.

---
 t/t4014-format-patch.sh | 197 ++++++++++++++++++++++++----------------
 1 file changed, 120 insertions(+), 77 deletions(-)
t/t4014-format-patch.sh +120 -77
index 67f4c62ed6..83f52614d3 100755
@@ -33,7 +33,8 @@ test_expect_success setup '
 	git commit -m "Side changes #3 with \\n backslash-n in it." &&
 
 	git checkout master &&
-	git diff-tree -p C2 | git apply --index &&
+	git diff-tree -p C2 >patch &&
+	git apply --index <patch &&
 	test_tick &&
 	git commit -m "Master accepts moral equivalent of #2" &&
 
@@ -110,7 +111,8 @@ test_expect_success 'format-patch --ignore-if-in-upstream result applies' '
 '
 
 test_expect_success 'commit did not screw up the log message' '
-	git cat-file commit side | grep "^Side .* with .* backslash-n"
+	git cat-file commit side >actual &&
+	grep "^Side .* with .* backslash-n" actual
 '
 
 test_expect_success 'format-patch did not screw up the log message' '
@@ -119,7 +121,8 @@ test_expect_success 'format-patch did not screw up the log message' '
 '
 
 test_expect_success 'replay did not screw up the log message' '
-	git cat-file commit rebuild-1 | grep "^Side .* with .* backslash-n"
+	git cat-file commit rebuild-1 >actual &&
+	grep "^Side .* with .* backslash-n" actual
 '
 
 test_expect_success 'extra headers' '
@@ -153,63 +156,73 @@ test_expect_success 'extra headers with multiple To:s' '
 
 test_expect_success 'additional command line cc (ascii)' '
 	git config --replace-all format.headers "Cc: R E Cipient <[email protected]>" &&
-	git format-patch --cc="S E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch5 &&
-	grep "^Cc: R E Cipient <[email protected]>,\$" patch5 &&
-	grep "^ *S E Cipient <[email protected]>\$" patch5
+	git format-patch --cc="S E Cipient <[email protected]>" --stdout master..side >patch5 &&
+	sed -e "/^\$/q" patch5 >hdrs5 &&
+	grep "^Cc: R E Cipient <[email protected]>,\$" hdrs5 &&
+	grep "^ *S E Cipient <[email protected]>\$" hdrs5
 '
 
 test_expect_failure 'additional command line cc (rfc822)' '
 	git config --replace-all format.headers "Cc: R E Cipient <[email protected]>" &&
-	git format-patch --cc="S. E. Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch5 &&
-	grep "^Cc: R E Cipient <[email protected]>,\$" patch5 &&
-	grep "^ *\"S. E. Cipient\" <[email protected]>\$" patch5
+	git format-patch --cc="S. E. Cipient <[email protected]>" --stdout master..side >patch5 &&
+	sed -e "/^\$/q" patch5 >hdrs5 &&
+	grep "^Cc: R E Cipient <[email protected]>,\$" hdrs5 &&
+	grep "^ *\"S. E. Cipient\" <[email protected]>\$" hdrs5
 '
 
 test_expect_success 'command line headers' '
 	git config --unset-all format.headers &&
-	git format-patch --add-header="Cc: R E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch6 &&
-	grep "^Cc: R E Cipient <[email protected]>\$" patch6
+	git format-patch --add-header="Cc: R E Cipient <[email protected]>" --stdout master..side >patch6 &&
+	sed -e "/^\$/q" patch6 >hdrs6 &&
+	grep "^Cc: R E Cipient <[email protected]>\$" hdrs6
 '
 
 test_expect_success 'configuration headers and command line headers' '
 	git config --replace-all format.headers "Cc: R E Cipient <[email protected]>" &&
-	git format-patch --add-header="Cc: S E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch7 &&
-	grep "^Cc: R E Cipient <[email protected]>,\$" patch7 &&
-	grep "^ *S E Cipient <[email protected]>\$" patch7
+	git format-patch --add-header="Cc: S E Cipient <[email protected]>" --stdout master..side >patch7 &&
+	sed -e "/^\$/q" patch7 >hdrs7 &&
+	grep "^Cc: R E Cipient <[email protected]>,\$" hdrs7 &&
+	grep "^ *S E Cipient <[email protected]>\$" hdrs7
 '
 
 test_expect_success 'command line To: header (ascii)' '
 	git config --unset-all format.headers &&
-	git format-patch --to="R E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
-	grep "^To: R E Cipient <[email protected]>\$" patch8
+	git format-patch --to="R E Cipient <[email protected]>" --stdout master..side >patch8 &&
+	sed -e "/^\$/q" patch8 >hdrs8 &&
+	grep "^To: R E Cipient <[email protected]>\$" hdrs8
 '
 
 test_expect_failure 'command line To: header (rfc822)' '
-	git format-patch --to="R. E. Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
-	grep "^To: \"R. E. Cipient\" <[email protected]>\$" patch8
+	git format-patch --to="R. E. Cipient <[email protected]>" --stdout master..side >patch8 &&
+	sed -e "/^\$/q" patch8 >hdrs8 &&
+	grep "^To: \"R. E. Cipient\" <[email protected]>\$" hdrs8
 '
 
 test_expect_failure 'command line To: header (rfc2047)' '
-	git format-patch --to="R Ä Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
-	grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected]>\$" patch8
+	git format-patch --to="R Ä Cipient <[email protected]>" --stdout master..side >patch8 &&
+	sed -e "/^\$/q" patch8 >hdrs8 &&
+	grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected]>\$" hdrs8
 '
 
 test_expect_success 'configuration To: header (ascii)' '
 	git config format.to "R E Cipient <[email protected]>" &&
-	git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
-	grep "^To: R E Cipient <[email protected]>\$" patch9
+	git format-patch --stdout master..side >patch9 &&
+	sed -e "/^\$/q" patch9 >hdrs9 &&
+	grep "^To: R E Cipient <[email protected]>\$" hdrs9
 '
 
 test_expect_failure 'configuration To: header (rfc822)' '
 	git config format.to "R. E. Cipient <[email protected]>" &&
-	git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
-	grep "^To: \"R. E. Cipient\" <[email protected]>\$" patch9
+	git format-patch --stdout master..side >patch9 &&
+	sed -e "/^\$/q" patch9 >hdrs9 &&
+	grep "^To: \"R. E. Cipient\" <[email protected]>\$" hdrs9
 '
 
 test_expect_failure 'configuration To: header (rfc2047)' '
 	git config format.to "R Ä Cipient <[email protected]>" &&
-	git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
-	grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected]>\$" patch9
+	git format-patch --stdout master..side >patch9 &&
+	sed -e "/^\$/q" patch9 >hdrs9 &&
+	grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected]>\$" hdrs9
 '
 
 # check_patch <patch>: Verify that <patch> looks like a half-sane
@@ -221,76 +234,76 @@ check_patch () {
 }
 
 test_expect_success 'format.from=false' '
-	git -c format.from=false format-patch --stdout master..side |
-	sed -e "/^\$/q" >patch &&
+	git -c format.from=false format-patch --stdout master..side >patch &&
+	sed -e "/^\$/q" patch >hdrs &&
 	check_patch patch &&
-	! grep "^From: C O Mitter <[email protected]>\$" patch
+	! grep "^From: C O Mitter <[email protected]>\$" hdrs
 '
 
 test_expect_success 'format.from=true' '
-	git -c format.from=true format-patch --stdout master..side |
-	sed -e "/^\$/q" >patch &&
-	check_patch patch &&
-	grep "^From: C O Mitter <[email protected]>\$" patch
+	git -c format.from=true format-patch --stdout master..side >patch &&
+	sed -e "/^\$/q" patch >hdrs &&
+	check_patch hdrs &&
+	grep "^From: C O Mitter <[email protected]>\$" hdrs
 '
 
 test_expect_success 'format.from with address' '
-	git -c format.from="F R Om <[email protected]>" format-patch --stdout master..side |
-	sed -e "/^\$/q" >patch &&
-	check_patch patch &&
-	grep "^From: F R Om <[email protected]>\$" patch
+	git -c format.from="F R Om <[email protected]>" format-patch --stdout master..side >patch &&
+	sed -e "/^\$/q" patch >hdrs &&
+	check_patch hdrs &&
+	grep "^From: F R Om <[email protected]>\$" hdrs
 '
 
 test_expect_success '--no-from overrides format.from' '
-	git -c format.from="F R Om <[email protected]>" format-patch --no-from --stdout master..side |
-	sed -e "/^\$/q" >patch &&
-	check_patch patch &&
-	! grep "^From: F R Om <[email protected]>\$" patch
+	git -c format.from="F R Om <[email protected]>" format-patch --no-from --stdout master..side >patch &&
+	sed -e "/^\$/q" patch >hdrs &&
+	check_patch hdrs &&
+	! grep "^From: F R Om <[email protected]>\$" hdrs
 '
 
 test_expect_success '--from overrides format.from' '
-	git -c format.from="F R Om <[email protected]>" format-patch --from --stdout master..side |
-	sed -e "/^\$/q" >patch &&
-	check_patch patch &&
-	! grep "^From: F R Om <[email protected]>\$" patch
+	git -c format.from="F R Om <[email protected]>" format-patch --from --stdout master..side >patch &&
+	sed -e "/^\$/q" patch >hdrs &&
+	check_patch hdrs &&
+	! grep "^From: F R Om <[email protected]>\$" hdrs
 '
 
 test_expect_success '--no-to overrides config.to' '
 	git config --replace-all format.to \
 		"R E Cipient <[email protected]>" &&
-	git format-patch --no-to --stdout master..side |
-	sed -e "/^\$/q" >patch10 &&
-	check_patch patch10 &&
-	! grep "^To: R E Cipient <[email protected]>\$" patch10
+	git format-patch --no-to --stdout master..side >patch10 &&
+	sed -e "/^\$/q" patch10 >hdrs10 &&
+	check_patch hdrs10 &&
+	! grep "^To: R E Cipient <[email protected]>\$" hdrs10
 '
 
 test_expect_success '--no-to and --to replaces config.to' '
 	git config --replace-all format.to \
 		"Someone <[email protected]>" &&
 	git format-patch --no-to --to="Someone Else <[email protected]>" \
-		--stdout master..side |
-	sed -e "/^\$/q" >patch11 &&
-	check_patch patch11 &&
-	! grep "^To: Someone <[email protected]>\$" patch11 &&
-	grep "^To: Someone Else <[email protected]>\$" patch11
+		--stdout master..side >patch11 &&
+	sed -e "/^\$/q" patch11 >hdrs11 &&
+	check_patch hdrs11 &&
+	! grep "^To: Someone <[email protected]>\$" hdrs11 &&
+	grep "^To: Someone Else <[email protected]>\$" hdrs11
 '
 
 test_expect_success '--no-cc overrides config.cc' '
 	git config --replace-all format.cc \
 		"C E Cipient <[email protected]>" &&
-	git format-patch --no-cc --stdout master..side |
-	sed -e "/^\$/q" >patch12 &&
-	check_patch patch12 &&
-	! grep "^Cc: C E Cipient <[email protected]>\$" patch12
+	git format-patch --no-cc --stdout master..side >patch12 &&
+	sed -e "/^\$/q" patch12 >hdrs12 &&
+	check_patch hdrs12 &&
+	! grep "^Cc: C E Cipient <[email protected]>\$" hdrs12
 '
 
 test_expect_success '--no-add-header overrides config.headers' '
 	git config --replace-all format.headers \
 		"Header1: B E Cipient <[email protected]>" &&
-	git format-patch --no-add-header --stdout master..side |
-	sed -e "/^\$/q" >patch13 &&
-	check_patch patch13 &&
-	! grep "^Header1: B E Cipient <[email protected]>\$" patch13
+	git format-patch --no-add-header --stdout master..side >patch13 &&
+	sed -e "/^\$/q" patch13 >hdrs13 &&
+	check_patch hdrs13 &&
+	! grep "^Header1: B E Cipient <[email protected]>\$" hdrs13
 '
 
 test_expect_success 'multiple files' '
@@ -808,20 +821,25 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
 	git format-patch --ignore-if-in-upstream HEAD
 '
 
-git_version="$(git --version | sed "s/.* //")"
+test_expect_success 'get git version' '
+	git_version=$(git --version) &&
+	git_version=${git_version##* }
+'
 
 signature() {
 	printf "%s\n%s\n\n" "-- " "${1:-$git_version}"
 }
 
 test_expect_success 'format-patch default signature' '
-	git format-patch --stdout -1 | tail -n 3 >output &&
+	git format-patch --stdout -1 >patch &&
+	tail -n 3 patch >output &&
 	signature >expect &&
 	test_cmp expect output
 '
 
 test_expect_success 'format-patch --signature' '
-	git format-patch --stdout --signature="my sig" -1 | tail -n 3 >output &&
+	git format-patch --stdout --signature="my sig" -1 >patch &&
+	tail -n 3 patch >output &&
 	signature "my sig" >expect &&
 	test_cmp expect output
 '
@@ -1606,19 +1624,40 @@ test_expect_success 'format-patch -o overrides format.outputDirectory' '
 
 test_expect_success 'format-patch --base' '
 	git checkout patchid &&
-	git format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual1 &&
-	git format-patch --stdout --base=HEAD~3 HEAD~.. | tail -n 7 >actual2 &&
+
+	git format-patch --stdout --base=HEAD~3 -1 >patch &&
+	tail -n 7 patch >actual1 &&
+
+	git format-patch --stdout --base=HEAD~3 HEAD~.. >patch &&
+	tail -n 7 patch >actual2 &&
+
 	echo >expect &&
-	echo "base-commit: $(git rev-parse HEAD~3)" >>expect &&
-	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expect &&
-	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expect &&
+	git rev-parse HEAD~3 >commit-id-base &&
+	echo "base-commit: $(cat commit-id-base)" >>expect &&
+
+	git show --patch HEAD~2 >patch &&
+	git patch-id --stable <patch >patch.id.raw &&
+	awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >>expect &&
+
+	git show --patch HEAD~1 >patch &&
+	git patch-id --stable <patch >patch.id.raw &&
+	awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >>expect &&
+
 	signature >>expect &&
 	test_cmp expect actual1 &&
 	test_cmp expect actual2 &&
+
 	echo >fail &&
-	echo "base-commit: $(git rev-parse HEAD~3)" >>fail &&
-	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --unstable | awk "{print \$1}")" >>fail &&
-	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --unstable | awk "{print \$1}")" >>fail &&
+	echo "base-commit: $(cat commit-id-base)" >>fail &&
+
+	git show --patch HEAD~2 >patch &&
+	git patch-id --unstable <patch >patch.id.raw &&
+	awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >>fail &&
+
+	git show --patch HEAD~1 >patch &&
+	git patch-id --unstable <patch >patch.id.raw &&
+	awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >>fail &&
+
 	signature >>fail &&
 	! test_cmp fail actual1 &&
 	! test_cmp fail actual2
@@ -1629,7 +1668,8 @@ test_expect_success 'format-patch --base errors out when base commit is in revis
 	test_must_fail git format-patch --base=HEAD~1 -2 &&
 	git format-patch --stdout --base=HEAD~2 -2 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse HEAD~2)" >expect &&
+	git rev-parse HEAD~2 >commit-id-base &&
+	echo "base-commit: $(cat commit-id-base)" >expect &&
 	test_cmp expect actual
 '
 
@@ -1668,7 +1708,8 @@ test_expect_success 'format-patch --base=auto' '
 	test_commit N2 &&
 	git format-patch --stdout --base=auto -2 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse upstream)" >expect &&
+	git rev-parse upstream >commit-id-base &&
+	echo "base-commit: $(cat commit-id-base)" >expect &&
 	test_cmp expect actual
 '
 
@@ -1705,7 +1746,8 @@ test_expect_success 'format-patch format.useAutoBaseoption' '
 	git config format.useAutoBase true &&
 	git format-patch --stdout -1 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse upstream)" >expect &&
+	git rev-parse upstream >commit-id-base &&
+	echo "base-commit: $(cat commit-id-base)" >expect &&
 	test_cmp expect actual
 '
 
@@ -1714,7 +1756,8 @@ test_expect_success 'format-patch --base overrides format.useAutoBase' '
 	git config format.useAutoBase true &&
 	git format-patch --stdout --base=HEAD~1 -1 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse HEAD~1)" >expect &&
+	git rev-parse HEAD~1 >commit-id-base &&
+	echo "base-commit: $(cat commit-id-base)" >expect &&
 	test_cmp expect actual
 '
 
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#53 lore raw

PATCH v3 12/13 Doc: add more detail for git-format-patch

In reply to Denton Liu

In git-format-patch.txt, we were missing some key user information. First of all, document the special value of --base=auto.

Next, while we're at it, surround option arguments with <>.

Finally, document the format.outputDirectory config and change format.coverletter to use camel case.

---
 Documentation/git-format-patch.txt | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
Documentation/git-format-patch.txt +10 -7
index b9b97e63ae..95bc4d53ca 100644
@@ -17,9 +17,9 @@ SYNOPSIS
 		   [--signature-file=<file>]
 		   [-n | --numbered | -N | --no-numbered]
 		   [--start-number <n>] [--numbered-files]
-		   [--in-reply-to=Message-Id] [--suffix=.<sfx>]
+		   [--in-reply-to=<Message-Id>] [--suffix=.<sfx>]
 		   [--ignore-if-in-upstream]
-		   [--rfc] [--subject-prefix=Subject-Prefix]
+		   [--rfc] [--subject-prefix=<Subject-Prefix>]
 		   [(--reroll-count|-v) <n>]
 		   [--to=<email>] [--cc=<email>]
 		   [--[no-]cover-letter] [--quiet]
@@ -159,7 +159,7 @@ Beware that the default for 'git send-email' is to thread emails
 itself.  If you want `git format-patch` to take care of threading, you
 will want to ensure that threading is disabled for `git send-email`.
 
---in-reply-to=Message-Id::
+--in-reply-to=<Message-Id>::
 	Make the first mail (or all the mails with `--no-thread`) appear as a
 	reply to the given Message-Id, which avoids breaking threads to
 	provide a new patch series.
@@ -314,7 +314,8 @@ you can use `--suffix=-patch` to get `0001-description-of-my-change-patch`.
 --base=<commit>::
 	Record the base tree information to identify the state the
 	patch series applies to.  See the BASE TREE INFORMATION section
-	below for details.
+	below for details. If <commit> is "auto", a base commit is
+	automatically chosen.
 
 --root::
 	Treat the revision argument as a <revision range>, even if it
@@ -330,8 +331,9 @@ CONFIGURATION
 -------------
 You can specify extra mail header lines to be added to each message,
 defaults for the subject prefix and file suffix, number patches when
-outputting more than one patch, add "To" or "Cc:" headers, configure
-attachments, and sign off patches with configuration variables.
+outputting more than one patch, add "To:" or "Cc:" headers, configure
+attachments, change the patch output directory, and sign off patches
+with configuration variables.
 
 ------------
 [format]
@@ -343,7 +345,8 @@ attachments, and sign off patches with configuration variables.
 	cc = <email>
 	attach [ = mime-boundary-string ]
 	signOff = true
-	coverletter = auto
+	outputDirectory = <directory>
+	coverLetter = auto
 ------------
 
 
Signature · 1 line
2.23.0.248.g3a9dd8fb08
#54 lore raw

Re: [PATCH 12/13] Doc: add more detail for git-format-patch

Quoted 4 lines · Denton Liu

In git-format-patch.txt, we were missing some key user information. First of all, document the special value of --base=auto.

Next, while we're at it, surround option arguments with <>.

I'd suggest squashing this in to complete the above.

cf. <[email protected]>
cf. <[email protected]>

---
 Documentation/git-format-patch.txt | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
Documentation/git-format-patch.txt +6 -6
index 95bc4d53ca..0ac56f4b70 100644
@@ -17,9 +17,9 @@ SYNOPSIS
 		   [--signature-file=<file>]
 		   [-n | --numbered | -N | --no-numbered]
 		   [--start-number <n>] [--numbered-files]
-		   [--in-reply-to=<Message-Id>] [--suffix=.<sfx>]
+		   [--in-reply-to=<message id>] [--suffix=.<sfx>]
 		   [--ignore-if-in-upstream]
-		   [--rfc] [--subject-prefix=<Subject-Prefix>]
+		   [--rfc] [--subject-prefix=<subject prefix>]
 		   [(--reroll-count|-v) <n>]
 		   [--to=<email>] [--cc=<email>]
 		   [--[no-]cover-letter] [--quiet]
@@ -159,9 +159,9 @@ Beware that the default for 'git send-email' is to thread emails
 itself.  If you want `git format-patch` to take care of threading, you
 will want to ensure that threading is disabled for `git send-email`.
 
---in-reply-to=<Message-Id>::
+--in-reply-to=<message id>::
 	Make the first mail (or all the mails with `--no-thread`) appear as a
-	reply to the given Message-Id, which avoids breaking threads to
+	reply to the given <message id>, which avoids breaking threads to
 	provide a new patch series.
 
 --ignore-if-in-upstream::
@@ -171,9 +171,9 @@ will want to ensure that threading is disabled for `git send-email`.
 	patches being generated, and any patch that matches is
 	ignored.
 
---subject-prefix=<Subject-Prefix>::
+--subject-prefix=<subject prefix>::
 	Instead of the standard '[PATCH]' prefix in the subject
-	line, instead use '[<Subject-Prefix>]'. This
+	line, instead use '[<subject prefix>]'. This
 	allows for useful naming of a patch series, and can be
 	combined with the `--numbered` option.
 
Signature · 1 line
2.23.0-266-g1e4abb0e04
#55 lore raw

Re: [PATCH 12/13] Doc: add more detail for git-format-patch

Quoted 7 lines · Junio C Hamano
Quoted 4 lines · Denton Liu

In git-format-patch.txt, we were missing some key user information. First of all, document the special value of --base=auto.

Next, while we're at it, surround option arguments with <>.

Quoted 7 lines

I'd suggest squashing this in to complete the above.

cf. <[email protected]>
cf. <[email protected]>

---
 Documentation/git-format-patch.txt | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Ah, I see that you have squashed this into the next step. I do not think it belongs there, though.

author
#56 lore raw

PATCH v3 13/13 config/format.txt: specify default value of format.coverLetter

In reply to Denton Liu
---
 Documentation/config/format.txt    |  1 +
 Documentation/git-format-patch.txt | 12 ++++++------
 2 files changed, 7 insertions(+), 6 deletions(-)
Documentation/config/format.txt +1 -0
index 414a5a8a9d..cb629fa769 100644
@@ -77,6 +77,7 @@ format.coverLetter::
 	A boolean that controls whether to generate a cover-letter when
 	format-patch is invoked, but in addition can be set to "auto", to
 	generate a cover-letter only when there's more than one patch.
+	Default is false.
 
 format.outputDirectory::
 	Set a custom directory to store the resulting files instead of the
Documentation/git-format-patch.txt +6 -6
index 95bc4d53ca..0ac56f4b70 100644
@@ -17,9 +17,9 @@ SYNOPSIS
 		   [--signature-file=<file>]
 		   [-n | --numbered | -N | --no-numbered]
 		   [--start-number <n>] [--numbered-files]
-		   [--in-reply-to=<Message-Id>] [--suffix=.<sfx>]
+		   [--in-reply-to=<message id>] [--suffix=.<sfx>]
 		   [--ignore-if-in-upstream]
-		   [--rfc] [--subject-prefix=<Subject-Prefix>]
+		   [--rfc] [--subject-prefix=<subject prefix>]
 		   [(--reroll-count|-v) <n>]
 		   [--to=<email>] [--cc=<email>]
 		   [--[no-]cover-letter] [--quiet]
@@ -159,9 +159,9 @@ Beware that the default for 'git send-email' is to thread emails
 itself.  If you want `git format-patch` to take care of threading, you
 will want to ensure that threading is disabled for `git send-email`.
 
---in-reply-to=<Message-Id>::
+--in-reply-to=<message id>::
 	Make the first mail (or all the mails with `--no-thread`) appear as a
-	reply to the given Message-Id, which avoids breaking threads to
+	reply to the given <message id>, which avoids breaking threads to
 	provide a new patch series.
 
 --ignore-if-in-upstream::
@@ -171,9 +171,9 @@ will want to ensure that threading is disabled for `git send-email`.
 	patches being generated, and any patch that matches is
 	ignored.
 
---subject-prefix=<Subject-Prefix>::
+--subject-prefix=<subject prefix>::
 	Instead of the standard '[PATCH]' prefix in the subject
-	line, instead use '[<Subject-Prefix>]'. This
+	line, instead use '[<subject prefix>]'. This
 	allows for useful naming of a patch series, and can be
 	combined with the `--numbered` option.
 
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#57 lore raw

Re: [PATCH 00/13] format-patch: clean up tests and documentation

In reply to Denton Liu
Quoted 1 line · Denton Liu

*** BLURB HERE ***

Whoops, perhaps we also need a configuration option for turning this off as well ;)

Quoted 76 lines

As one of the older parts of the Git, the tests and documentation for format-patch have been needing cleanup for a while. Let's do that in this patchset!

This patchset is based on v3 of "format-patch: learn --infer-cover-subject option (also t4014 cleanup)"[1].

Changes since v3 of "format-patch: learn --infer-cover-subject option (also t4014 cleanup)":

* Squash in Junio's and Hannes' suggestions

* Add 't4014: let sed open its own files'

[1]: https://public-inbox.org/git/[email protected]/T/#m19570aff4828dfbd65d57cacf231c2938af1dc9f

Denton Liu (13):
t4014: drop unnecessary blank lines from test cases
t4014: s/expected/expect/
t4014: move closing sq onto its own line
t4014: use sq for test case names
t4014: remove spaces after redirect operators
t4014: use indentable here-docs
t4014: drop redirections to /dev/null
t4014: let sed open its own files
t4014: use test_line_count() where possible
t4014: remove confusing pipe in check_threading()
t4014: stop losing return codes of git commands
Doc: add more detail for git-format-patch config/format.txt: specify default value of format.coverLetter

 Documentation/config/format.txt    |   1 +
 Documentation/git-format-patch.txt |  23 +-
 t/t4014-format-patch.sh            | 814 ++++++++++++++---------------
 3 files changed, 421 insertions(+), 417 deletions(-)

Range-diff:

 1:  fb000bfca2 =  1:  fb000bfca2 t4014: drop unnecessary blank lines from test cases
 2:  568b3a03a0 !  2:  0a5ce9b95f t4014: s/expected/expect/

@@ Commit message
t4014: s/expected/expect/

For test cases, the usual convention is to name expected output files
- "expect", not "expected". Replace all instances with "expected" with
+ "expect", not "expected". Replace all instances of "expected" with
"expect" except for one case where the "expected" is used as the name of a test case.

 3:  a205a920bd =  3:  5c49703aa4 t4014: move closing sq onto its own line
 4:  66bf2e3dd4 =  4:  02a11147fd t4014: use sq for test case names
 5:  6f1371275e =  5:  8d9791c061 t4014: remove spaces after redirect operators
 6:  b4295846f5 =  6:  90ad0fcf70 t4014: use indentable here-docs
 7:  34315412c8 =  7:  804b3163f8 t4014: drop redirections to /dev/null
 -:  ---------- >  8:  7d9a24a979 t4014: let sed open its own files
 8:  de08dd886d =  9:  d068d42098 t4014: use test_line_count() where possible
 9:  dec5a62e82 = 10:  6a9409cee0 t4014: remove confusing pipe in check_threading()
10:  64069c0c54 ! 11:  c580ce447b t4014: stop losing return codes of git commands
    @@ t/t4014-format-patch.sh: test_expect_success 'format-patch --ignore-if-in-upstre
      
     -git_version="$(git --version | sed "s/.* //")"
     +test_expect_success 'get git version' '
    -+	git_version="$(git --version | sed "s/.* //")"
    ++	git_version=$(git --version) &&
    ++	git_version=${git_version##* }
     +'
      
      signature() {
11:  c12534ab5d = 12:  a97f861e6a Doc: add more detail for git-format-patch
12:  a08273ebcc <  -:  ---------- config/format.txt: specify default value of format.coverLetter
13:  de599f7ca9 <  -:  ---------- format-patch: learn --infer-cover-subject option
 -:  ---------- > 13:  7c8522abf2 config/format.txt: specify default value of format.coverLetter
Signature · 1 line
2.23.0.248.g3a9dd8fb08
#58 lore raw

Re: [PATCH 00/13] format-patch: clean up tests and documentation

Quoted 5 lines · Denton Liu
Quoted 1 line · Denton Liu

*** BLURB HERE ***

Whoops, perhaps we also need a configuration option for turning this off as well ;)

Yes.

I think it is OK to just remove it when we are taking anything from the branch.*.description (and any other stuff that leaves human readable text in the future) to add to the body.

author
#59 lore raw

v2 cover format-patch: clean up tests and documentation

In reply to Denton Liu

In this reroll, I squashed Junio's suggestion into the correct patch. Also, I took Eric's suggestion and removed the weak justification (i.e. better error messages) from the sed patch since it doesn't really contribute.

As one of the older parts of the Git, the tests and documentation for format-patch have been needing cleanup for a while. Let's do that in this patchset!

This patchset is based on v3 of "format-patch: learn --infer-cover-subject option (also t4014 cleanup)"[1].

Changes since v1:

* Squash Junio's patch into the correct patch ;)

* Remove weak justification (better error messages) in 8/13

Changes since v3 of "format-patch: learn --infer-cover-subject option (also t4014 cleanup)":

* Squash in Junio's and Hannes' suggestions

* Add 't4014: let sed open its own files'

[1]: https://public-inbox.org/git/[email protected]/T/#m19570aff4828dfbd65d57cacf231c2938af1dc9f

Denton Liu (13):
t4014: drop unnecessary blank lines from test cases
t4014: s/expected/expect/
t4014: move closing sq onto its own line
t4014: use sq for test case names
t4014: remove spaces after redirect operators
t4014: use indentable here-docs
t4014: drop redirections to /dev/null
t4014: let sed open its own files
t4014: use test_line_count() where possible
t4014: remove confusing pipe in check_threading()
t4014: stop losing return codes of git commands
Doc: add more detail for git-format-patch config/format.txt: specify default value of format.coverLetter

 Documentation/config/format.txt    |   1 +
 Documentation/git-format-patch.txt |  23 +-
 t/t4014-format-patch.sh            | 814 ++++++++++++++---------------
 3 files changed, 421 insertions(+), 417 deletions(-)

Range-diff against v1:

 1:  fb000bfca2 =  1:  fb000bfca2 t4014: drop unnecessary blank lines from test cases
 2:  0a5ce9b95f =  2:  0a5ce9b95f t4014: s/expected/expect/
 3:  5c49703aa4 =  3:  5c49703aa4 t4014: move closing sq onto its own line
 4:  02a11147fd =  4:  02a11147fd t4014: use sq for test case names
 5:  8d9791c061 =  5:  8d9791c061 t4014: remove spaces after redirect operators
 6:  90ad0fcf70 =  6:  90ad0fcf70 t4014: use indentable here-docs
 7:  804b3163f8 =  7:  804b3163f8 t4014: drop redirections to /dev/null
 8:  7d9a24a979 !  8:  967e624bb4 t4014: let sed open its own files

@@ Commit message
t4014: let sed open its own files

In some cases, we were using a redirection operator to feed input into
- sed. However, since sed is capable of opening its own files and provides
- better error messages on IO failure, make sed open its own files instead
- of redirecting input into it.
+ sed. However, since sed is capable of opening its own files, make sed
+ open its own files instead of redirecting input into it.

 9:  d068d42098 =  9:  9a42ec2b7e t4014: use test_line_count() where possible
10:  6a9409cee0 = 10:  8acc90f74d t4014: remove confusing pipe in check_threading()
11:  c580ce447b = 11:  bc7355485f t4014: stop losing return codes of git commands
12:  a97f861e6a ! 12:  fd343b99c5 Doc: add more detail for git-format-patch

@@ Commit message
In git-format-patch.txt, we were missing some key user information. First of all, document the special value of --base=auto.

- Next, while we're at it, surround option arguments with <>.
+ Next, while we're at it, surround option arguments with <> and change
+ existing names such as "Message-Id" to "message id", which conforms with
+ how existing documentation is written.

Finally, document the format.outputDirectory config and change format.coverletter to use camel case.
@@ Documentation/git-format-patch.txt: SYNOPSIS
[-n | --numbered | -N | --no-numbered]
[--start-number <n>] [--numbered-files]
- [--in-reply-to=Message-Id] [--suffix=.<sfx>]
-+ [--in-reply-to=<Message-Id>] [--suffix=.<sfx>]
++ [--in-reply-to=<message id>] [--suffix=.<sfx>]
[--ignore-if-in-upstream]
- [--rfc] [--subject-prefix=Subject-Prefix]
-+ [--rfc] [--subject-prefix=<Subject-Prefix>]
++ [--rfc] [--subject-prefix=<subject prefix>]
[(--reroll-count|-v) <n>]
[--to=<email>] [--cc=<email>]
[--[no-]cover-letter] [--quiet]
@@ Documentation/git-format-patch.txt: Beware that the default for 'git send-email'
will want to ensure that threading is disabled for git send-email.

---in-reply-to=Message-Id::
-+--in-reply-to=<Message-Id>::
++--in-reply-to=<message id>::
Make the first mail (or all the mails with --no-thread) appear as a
- reply to the given Message-Id, which avoids breaking threads to
+- reply to the given Message-Id, which avoids breaking threads to
++ reply to the given <message id>, which avoids breaking threads to
provide a new patch series.
+
+ --ignore-if-in-upstream::
+@@ Documentation/git-format-patch.txt: will want to ensure that threading is disabled for git send-email.
+ patches being generated, and any patch that matches is
+ ignored.
+
+---subject-prefix=<Subject-Prefix>::
++--subject-prefix=<subject prefix>::
+ Instead of the standard '[PATCH]' prefix in the subject
+- line, instead use '[<Subject-Prefix>]'. This
++ line, instead use '[<subject prefix>]'. This
+ allows for useful naming of a patch series, and can be
+ combined with the --numbered option.
+
@@ Documentation/git-format-patch.txt: you can use --suffix=-patch to get 0001-description-of-my-change-patch.
--base=<commit>::
Record the base tree information to identify the state the

13:  7c8522abf2 <  -:  ---------- config/format.txt: specify default value of format.coverLetter
 -:  ---------- > 13:  4e429e1989 config/format.txt: specify default value of format.coverLetter
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#60 lore raw

PATCH v2 1/13 t4014: drop unnecessary blank lines from test cases

---
 t/t4014-format-patch.sh | 47 -----------------------------------------
 1 file changed, 47 deletions(-)
t/t4014-format-patch.sh +0 -47
index ca7debf1d4..3ed3feabfe 100755
@@ -9,7 +9,6 @@ test_description='various format-patch tests'
 . "$TEST_DIRECTORY"/lib-terminal.sh
 
 test_expect_success setup '
-
 	for i in 1 2 3 4 5 6 7 8 9 10; do echo "$i"; done >file &&
 	cat file >elif &&
 	git add file elif &&
@@ -60,20 +59,16 @@ test_expect_success setup '
 '
 
 test_expect_success "format-patch --ignore-if-in-upstream" '
-
 	git format-patch --stdout master..side >patch0 &&
 	cnt=$(grep "^From " patch0 | wc -l) &&
 	test $cnt = 3
-
 '
 
 test_expect_success "format-patch --ignore-if-in-upstream" '
-
 	git format-patch --stdout \
 		--ignore-if-in-upstream master..side >patch1 &&
 	cnt=$(grep "^From " patch1 | wc -l) &&
 	test $cnt = 2
-
 '
 
 test_expect_success "format-patch --ignore-if-in-upstream handles tags" '
@@ -85,7 +80,6 @@ test_expect_success "format-patch --ignore-if-in-upstream handles tags" '
 '
 
 test_expect_success "format-patch doesn't consider merge commits" '
-
 	git checkout -b slave master &&
 	echo "Another line" >>file &&
 	test_tick &&
@@ -101,7 +95,6 @@ test_expect_success "format-patch doesn't consider merge commits" '
 '
 
 test_expect_success "format-patch result applies" '
-
 	git checkout -b rebuild-0 master &&
 	git am -3 patch0 &&
 	cnt=$(git rev-list master.. | wc -l) &&
@@ -109,7 +102,6 @@ test_expect_success "format-patch result applies" '
 '
 
 test_expect_success "format-patch --ignore-if-in-upstream result applies" '
-
 	git checkout -b rebuild-1 master &&
 	git am -3 patch1 &&
 	cnt=$(git rev-list master.. | wc -l) &&
@@ -117,26 +109,19 @@ test_expect_success "format-patch --ignore-if-in-upstream result applies" '
 '
 
 test_expect_success 'commit did not screw up the log message' '
-
 	git cat-file commit side | grep "^Side .* with .* backslash-n"
-
 '
 
 test_expect_success 'format-patch did not screw up the log message' '
-
 	grep "^Subject: .*Side changes #3 with .* backslash-n" patch0 &&
 	grep "^Subject: .*Side changes #3 with .* backslash-n" patch1
-
 '
 
 test_expect_success 'replay did not screw up the log message' '
-
 	git cat-file commit rebuild-1 | grep "^Side .* with .* backslash-n"
-
 '
 
 test_expect_success 'extra headers' '
-
 	git config format.headers "To: R E Cipient <[email protected]>
 " &&
 	git config --add format.headers "Cc: S E Cipient <[email protected]>
@@ -145,22 +130,18 @@ test_expect_success 'extra headers' '
 	sed -e "/^\$/q" patch2 > hdrs2 &&
 	grep "^To: R E Cipient <[email protected]>\$" hdrs2 &&
 	grep "^Cc: S E Cipient <[email protected]>\$" hdrs2
-
 '
 
 test_expect_success 'extra headers without newlines' '
-
 	git config --replace-all format.headers "To: R E Cipient <[email protected]>" &&
 	git config --add format.headers "Cc: S E Cipient <[email protected]>" &&
 	git format-patch --stdout master..side >patch3 &&
 	sed -e "/^\$/q" patch3 > hdrs3 &&
 	grep "^To: R E Cipient <[email protected]>\$" hdrs3 &&
 	grep "^Cc: S E Cipient <[email protected]>\$" hdrs3
-
 '
 
 test_expect_success 'extra headers with multiple To:s' '
-
 	git config --replace-all format.headers "To: R E Cipient <[email protected]>" &&
 	git config --add format.headers "To: S E Cipient <[email protected]>" &&
 	git format-patch --stdout master..side > patch4 &&
@@ -170,7 +151,6 @@ test_expect_success 'extra headers with multiple To:s' '
 '
 
 test_expect_success 'additional command line cc (ascii)' '
-
 	git config --replace-all format.headers "Cc: R E Cipient <[email protected]>" &&
 	git format-patch --cc="S E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch5 &&
 	grep "^Cc: R E Cipient <[email protected]>,\$" patch5 &&
@@ -178,7 +158,6 @@ test_expect_success 'additional command line cc (ascii)' '
 '
 
 test_expect_failure 'additional command line cc (rfc822)' '
-
 	git config --replace-all format.headers "Cc: R E Cipient <[email protected]>" &&
 	git format-patch --cc="S. E. Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch5 &&
 	grep "^Cc: R E Cipient <[email protected]>,\$" patch5 &&
@@ -186,14 +165,12 @@ test_expect_failure 'additional command line cc (rfc822)' '
 '
 
 test_expect_success 'command line headers' '
-
 	git config --unset-all format.headers &&
 	git format-patch --add-header="Cc: R E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch6 &&
 	grep "^Cc: R E Cipient <[email protected]>\$" patch6
 '
 
 test_expect_success 'configuration headers and command line headers' '
-
 	git config --replace-all format.headers "Cc: R E Cipient <[email protected]>" &&
 	git format-patch --add-header="Cc: S E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch7 &&
 	grep "^Cc: R E Cipient <[email protected]>,\$" patch7 &&
@@ -201,40 +178,34 @@ test_expect_success 'configuration headers and command line headers' '
 '
 
 test_expect_success 'command line To: header (ascii)' '
-
 	git config --unset-all format.headers &&
 	git format-patch --to="R E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
 	grep "^To: R E Cipient <[email protected]>\$" patch8
 '
 
 test_expect_failure 'command line To: header (rfc822)' '
-
 	git format-patch --to="R. E. Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
 	grep "^To: \"R. E. Cipient\" <[email protected]>\$" patch8
 '
 
 test_expect_failure 'command line To: header (rfc2047)' '
-
 	git format-patch --to="R Ä Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
 	grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected]>\$" patch8
 '
 
 test_expect_success 'configuration To: header (ascii)' '
-
 	git config format.to "R E Cipient <[email protected]>" &&
 	git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
 	grep "^To: R E Cipient <[email protected]>\$" patch9
 '
 
 test_expect_failure 'configuration To: header (rfc822)' '
-
 	git config format.to "R. E. Cipient <[email protected]>" &&
 	git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
 	grep "^To: \"R. E. Cipient\" <[email protected]>\$" patch9
 '
 
 test_expect_failure 'configuration To: header (rfc2047)' '
-
 	git config format.to "R Ä Cipient <[email protected]>" &&
 	git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
 	grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected]>\$" patch9
@@ -249,7 +220,6 @@ check_patch () {
 }
 
 test_expect_success 'format.from=false' '
-
 	git -c format.from=false format-patch --stdout master..side |
 	sed -e "/^\$/q" >patch &&
 	check_patch patch &&
@@ -257,7 +227,6 @@ test_expect_success 'format.from=false' '
 '
 
 test_expect_success 'format.from=true' '
-
 	git -c format.from=true format-patch --stdout master..side |
 	sed -e "/^\$/q" >patch &&
 	check_patch patch &&
@@ -265,7 +234,6 @@ test_expect_success 'format.from=true' '
 '
 
 test_expect_success 'format.from with address' '
-
 	git -c format.from="F R Om <[email protected]>" format-patch --stdout master..side |
 	sed -e "/^\$/q" >patch &&
 	check_patch patch &&
@@ -273,7 +241,6 @@ test_expect_success 'format.from with address' '
 '
 
 test_expect_success '--no-from overrides format.from' '
-
 	git -c format.from="F R Om <[email protected]>" format-patch --no-from --stdout master..side |
 	sed -e "/^\$/q" >patch &&
 	check_patch patch &&
@@ -281,7 +248,6 @@ test_expect_success '--no-from overrides format.from' '
 '
 
 test_expect_success '--from overrides format.from' '
-
 	git -c format.from="F R Om <[email protected]>" format-patch --from --stdout master..side |
 	sed -e "/^\$/q" >patch &&
 	check_patch patch &&
@@ -289,7 +255,6 @@ test_expect_success '--from overrides format.from' '
 '
 
 test_expect_success '--no-to overrides config.to' '
-
 	git config --replace-all format.to \
 		"R E Cipient <[email protected]>" &&
 	git format-patch --no-to --stdout master..side |
@@ -299,7 +264,6 @@ test_expect_success '--no-to overrides config.to' '
 '
 
 test_expect_success '--no-to and --to replaces config.to' '
-
 	git config --replace-all format.to \
 		"Someone <[email protected]>" &&
 	git format-patch --no-to --to="Someone Else <[email protected]>" \
@@ -311,7 +275,6 @@ test_expect_success '--no-to and --to replaces config.to' '
 '
 
 test_expect_success '--no-cc overrides config.cc' '
-
 	git config --replace-all format.cc \
 		"C E Cipient <[email protected]>" &&
 	git format-patch --no-cc --stdout master..side |
@@ -321,7 +284,6 @@ test_expect_success '--no-cc overrides config.cc' '
 '
 
 test_expect_success '--no-add-header overrides config.headers' '
-
 	git config --replace-all format.headers \
 		"Header1: B E Cipient <[email protected]>" &&
 	git format-patch --no-add-header --stdout master..side |
@@ -331,7 +293,6 @@ test_expect_success '--no-add-header overrides config.headers' '
 '
 
 test_expect_success 'multiple files' '
-
 	rm -rf patches/ &&
 	git checkout side &&
 	git format-patch -o patches/ master &&
@@ -594,7 +555,6 @@ test_expect_success 'thread config + --no-thread' '
 '
 
 test_expect_success 'excessive subject' '
-
 	rm -rf patches/ &&
 	git checkout side &&
 	before=$(git hash-object file) &&
@@ -622,7 +582,6 @@ test_expect_success 'cover-letter inherits diff options' '
 	! grep "file => foo .* 0 *\$" 0000-cover-letter.patch &&
 	git format-patch --cover-letter -1 -M &&
 	grep "file => foo .* 0 *\$" 0000-cover-letter.patch
-
 '
 
 cat > expect << EOF
@@ -636,11 +595,9 @@ cat > expect << EOF
 EOF
 
 test_expect_success 'shortlog of cover-letter wraps overly-long onelines' '
-
 	git format-patch --cover-letter -2 &&
 	sed -e "1,/A U Thor/d" -e "/^\$/q" < 0000-cover-letter.patch > output &&
 	test_cmp expect output
-
 '
 
 cat > expect << EOF
@@ -656,13 +613,11 @@ index $before..$after 100644
 EOF
 
 test_expect_success 'format-patch respects -U' '
-
 	git format-patch -U4 -2 &&
 	sed -e "1,/^diff/d" -e "/^+5/q" \
 		<0001-This-is-an-excessively-long-subject-line-for-a-messa.patch \
 		>output &&
 	test_cmp expect output
-
 '
 
 cat > expect << EOF
@@ -679,11 +634,9 @@ index $before..$after 100644
 EOF
 
 test_expect_success 'format-patch -p suppresses stat' '
-
 	git format-patch -p -2 &&
 	sed -e "1,/^\$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output &&
 	test_cmp expect output
-
 '
 
 test_expect_success 'format-patch from a subdirectory (1)' '
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#61 lore raw

PATCH v2 2/13 t4014: s/expected/expect/

In reply to Denton Liu

For test cases, the usual convention is to name expected output files "expect", not "expected". Replace all instances of "expected" with "expect" except for one case where the "expected" is used as the name of a test case.

---
 t/t4014-format-patch.sh | 106 ++++++++++++++++++++--------------------
 1 file changed, 53 insertions(+), 53 deletions(-)
t/t4014-format-patch.sh +53 -53
index 3ed3feabfe..62f5680f05 100755
@@ -1209,32 +1209,32 @@ append_signoff()
 
 test_expect_success 'signoff: commit with no body' '
 	append_signoff </dev/null >actual &&
-	cat <<\EOF | sed "s/EOL$//" >expected &&
+	cat <<\EOF | sed "s/EOL$//" >expect &&
 4:Subject: [PATCH] EOL
 8:
 9:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: commit with only subject' '
 	echo subject | append_signoff >actual &&
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 9:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: commit with only subject that does not end with NL' '
 	printf subject | append_signoff >actual &&
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 9:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: no existing signoffs' '
@@ -1243,24 +1243,24 @@ subject
 
 body
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
 11:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: no existing signoffs and no trailing NL' '
 	printf "subject\n\nbody" | append_signoff >actual &&
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
 11:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: some random signoff' '
@@ -1271,14 +1271,14 @@ body
 
 Signed-off-by: my@house
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
 11:Signed-off-by: my@house
 12:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: misc conforming footer elements' '
@@ -1292,14 +1292,14 @@ Signed-off-by: my@house
 Tested-by: Some One <[email protected]>
 Bug: 1234
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
 11:Signed-off-by: my@house
 15:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: some random signoff-alike' '
@@ -1309,13 +1309,13 @@ subject
 body
 Fooled-by-me: my@house
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 11:
 12:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: not really a signoff' '
@@ -1324,14 +1324,14 @@ subject
 
 I want to mention about Signed-off-by: here.
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 9:I want to mention about Signed-off-by: here.
 10:
 11:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: not really a signoff (2)' '
@@ -1341,13 +1341,13 @@ subject
 My unfortunate
 Signed-off-by: example happens to be wrapped here.
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:Signed-off-by: example happens to be wrapped here.
 11:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: valid S-o-b paragraph in the middle' '
@@ -1359,7 +1359,7 @@ Signed-off-by: your@house
 
 A lot of houses.
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 9:Signed-off-by: my@house
@@ -1368,7 +1368,7 @@ EOF
 13:
 14:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: the same signoff at the end' '
@@ -1379,24 +1379,24 @@ body
 
 Signed-off-by: C O Mitter <[email protected]>
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
 11:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: the same signoff at the end, no trailing NL' '
 	printf "subject\n\nSigned-off-by: C O Mitter <[email protected]>" |
 		append_signoff >actual &&
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 9:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: the same signoff NOT at the end' '
@@ -1408,14 +1408,14 @@ body
 Signed-off-by: C O Mitter <[email protected]>
 Signed-off-by: my@house
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
 11:Signed-off-by: C O Mitter <[email protected]>
 12:Signed-off-by: my@house
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: tolerate garbage in conforming footer' '
@@ -1428,13 +1428,13 @@ Tested-by: my@house
 Some Trash
 Signed-off-by: C O Mitter <[email protected]>
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
 13:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: respect trailer config' '
@@ -1444,13 +1444,13 @@ subject
 Myfooter: x
 Some Trash
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 11:
 12:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual &&
+	test_cmp expect actual &&
 
 	test_config trailer.Myfooter.ifexists add &&
 	append_signoff <<\EOF >actual &&
@@ -1459,12 +1459,12 @@ subject
 Myfooter: x
 Some Trash
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 11:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'signoff: footer begins with non-signoff without @ sign' '
@@ -1479,13 +1479,13 @@ Change-id: Ideadbeef
 Signed-off-by: C O Mitter <[email protected]>
 Bug: 1234
 EOF
-	cat >expected <<\EOF &&
+	cat >expect <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
 14:Signed-off-by: C O Mitter <[email protected]>
 EOF
-	test_cmp expected actual
+	test_cmp expect actual
 '
 
 test_expect_success 'format patch ignores color.ui' '
@@ -1604,13 +1604,13 @@ test_expect_success 'format-patch --base' '
 	git checkout patchid &&
 	git format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual1 &&
 	git format-patch --stdout --base=HEAD~3 HEAD~.. | tail -n 7 >actual2 &&
-	echo >expected &&
-	echo "base-commit: $(git rev-parse HEAD~3)" >>expected &&
-	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expected &&
-	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expected &&
-	signature >> expected &&
-	test_cmp expected actual1 &&
-	test_cmp expected actual2 &&
+	echo >expect &&
+	echo "base-commit: $(git rev-parse HEAD~3)" >>expect &&
+	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expect &&
+	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expect &&
+	signature >> expect &&
+	test_cmp expect actual1 &&
+	test_cmp expect actual2 &&
 	echo >fail &&
 	echo "base-commit: $(git rev-parse HEAD~3)" >>fail &&
 	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --unstable | awk "{print \$1}")" >>fail &&
@@ -1625,8 +1625,8 @@ test_expect_success 'format-patch --base errors out when base commit is in revis
 	test_must_fail git format-patch --base=HEAD~1 -2 &&
 	git format-patch --stdout --base=HEAD~2 -2 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse HEAD~2)" >expected &&
-	test_cmp expected actual
+	echo "base-commit: $(git rev-parse HEAD~2)" >expect &&
+	test_cmp expect actual
 '
 
 test_expect_success 'format-patch --base errors out when base commit is not ancestor of revision list' '
@@ -1652,8 +1652,8 @@ test_expect_success 'format-patch --base errors out when base commit is not ance
 	test_must_fail git format-patch --base=$(cat commit-id-Z) -3 &&
 	git format-patch --stdout --base=$(cat commit-id-base) -3 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(cat commit-id-base)" >expected &&
-	test_cmp expected actual
+	echo "base-commit: $(cat commit-id-base)" >expect &&
+	test_cmp expect actual
 '
 
 test_expect_success 'format-patch --base=auto' '
@@ -1664,8 +1664,8 @@ test_expect_success 'format-patch --base=auto' '
 	test_commit N2 &&
 	git format-patch --stdout --base=auto -2 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse upstream)" >expected &&
-	test_cmp expected actual
+	echo "base-commit: $(git rev-parse upstream)" >expect &&
+	test_cmp expect actual
 '
 
 test_expect_success 'format-patch errors out when history involves criss-cross' '
@@ -1701,8 +1701,8 @@ test_expect_success 'format-patch format.useAutoBaseoption' '
 	git config format.useAutoBase true &&
 	git format-patch --stdout -1 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse upstream)" >expected &&
-	test_cmp expected actual
+	echo "base-commit: $(git rev-parse upstream)" >expect &&
+	test_cmp expect actual
 '
 
 test_expect_success 'format-patch --base overrides format.useAutoBase' '
@@ -1710,8 +1710,8 @@ test_expect_success 'format-patch --base overrides format.useAutoBase' '
 	git config format.useAutoBase true &&
 	git format-patch --stdout --base=HEAD~1 -1 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse HEAD~1)" >expected &&
-	test_cmp expected actual
+	echo "base-commit: $(git rev-parse HEAD~1)" >expect &&
+	test_cmp expect actual
 '
 
 test_expect_success 'format-patch --base with --attach' '
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#62 lore raw

PATCH v2 3/13 t4014: move closing sq onto its own line

In reply to Denton Liu

The usual convention for test cases is for the closing sq to be on its own line. Move the sq onto its own line for cases that do not conform to this style.

---
 t/t4014-format-patch.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
t/t4014-format-patch.sh +4 -2
index 62f5680f05..5e8eb6fb27 100755
@@ -790,11 +790,13 @@ test_expect_success 'options no longer allowed for format-patch' '
 	test_must_fail git format-patch --name-status 2> output &&
 	test_i18ncmp expect.name-status output &&
 	test_must_fail git format-patch --check 2> output &&
-	test_i18ncmp expect.check output'
+	test_i18ncmp expect.check output
+'
 
 test_expect_success 'format-patch --numstat should produce a patch' '
 	git format-patch --numstat --stdout master..side > output &&
-	test 5 = $(grep "^diff --git a/" output | wc -l)'
+	test 5 = $(grep "^diff --git a/" output | wc -l)
+'
 
 test_expect_success 'format-patch -- <path>' '
 	git format-patch master..side -- file 2>error &&
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#63 lore raw

PATCH v2 4/13 t4014: use sq for test case names

In reply to Denton Liu

The usual convention is for test case names to be written between single-quotes. Change all double-quoted test case names to single-quotes except for one test case name that uses a sq for a contraction.

---
 t/t4014-format-patch.sh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
t/t4014-format-patch.sh +5 -5
index 5e8eb6fb27..a7b440b003 100755
@@ -58,20 +58,20 @@ test_expect_success setup '
 	git checkout master
 '
 
-test_expect_success "format-patch --ignore-if-in-upstream" '
+test_expect_success 'format-patch --ignore-if-in-upstream' '
 	git format-patch --stdout master..side >patch0 &&
 	cnt=$(grep "^From " patch0 | wc -l) &&
 	test $cnt = 3
 '
 
-test_expect_success "format-patch --ignore-if-in-upstream" '
+test_expect_success 'format-patch --ignore-if-in-upstream' '
 	git format-patch --stdout \
 		--ignore-if-in-upstream master..side >patch1 &&
 	cnt=$(grep "^From " patch1 | wc -l) &&
 	test $cnt = 2
 '
 
-test_expect_success "format-patch --ignore-if-in-upstream handles tags" '
+test_expect_success 'format-patch --ignore-if-in-upstream handles tags' '
 	git tag -a v1 -m tag side &&
 	git tag -a v2 -m tag master &&
 	git format-patch --stdout --ignore-if-in-upstream v2..v1 >patch1 &&
@@ -94,14 +94,14 @@ test_expect_success "format-patch doesn't consider merge commits" '
 	test $cnt = 3
 '
 
-test_expect_success "format-patch result applies" '
+test_expect_success 'format-patch result applies' '
 	git checkout -b rebuild-0 master &&
 	git am -3 patch0 &&
 	cnt=$(git rev-list master.. | wc -l) &&
 	test $cnt = 2
 '
 
-test_expect_success "format-patch --ignore-if-in-upstream result applies" '
+test_expect_success 'format-patch --ignore-if-in-upstream result applies' '
 	git checkout -b rebuild-1 master &&
 	git am -3 patch1 &&
 	cnt=$(git rev-list master.. | wc -l) &&
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#64 lore raw

PATCH v2 5/13 t4014: remove spaces after redirect operators

In reply to Denton Liu

For shell scripts, the usual convention is for there to be no space after redirection operators, (e.g. >file, not > file). Remove these spaces wherever they appear.

---
 t/t4014-format-patch.sh | 62 ++++++++++++++++++++---------------------
 1 file changed, 31 insertions(+), 31 deletions(-)
t/t4014-format-patch.sh +31 -31
index a7b440b003..075affb1e5 100755
@@ -126,8 +126,8 @@ test_expect_success 'extra headers' '
 " &&
 	git config --add format.headers "Cc: S E Cipient <[email protected]>
 " &&
-	git format-patch --stdout master..side > patch2 &&
-	sed -e "/^\$/q" patch2 > hdrs2 &&
+	git format-patch --stdout master..side >patch2 &&
+	sed -e "/^\$/q" patch2 >hdrs2 &&
 	grep "^To: R E Cipient <[email protected]>\$" hdrs2 &&
 	grep "^Cc: S E Cipient <[email protected]>\$" hdrs2
 '
@@ -136,7 +136,7 @@ test_expect_success 'extra headers without newlines' '
 	git config --replace-all format.headers "To: R E Cipient <[email protected]>" &&
 	git config --add format.headers "Cc: S E Cipient <[email protected]>" &&
 	git format-patch --stdout master..side >patch3 &&
-	sed -e "/^\$/q" patch3 > hdrs3 &&
+	sed -e "/^\$/q" patch3 >hdrs3 &&
 	grep "^To: R E Cipient <[email protected]>\$" hdrs3 &&
 	grep "^Cc: S E Cipient <[email protected]>\$" hdrs3
 '
@@ -144,8 +144,8 @@ test_expect_success 'extra headers without newlines' '
 test_expect_success 'extra headers with multiple To:s' '
 	git config --replace-all format.headers "To: R E Cipient <[email protected]>" &&
 	git config --add format.headers "To: S E Cipient <[email protected]>" &&
-	git format-patch --stdout master..side > patch4 &&
-	sed -e "/^\$/q" patch4 > hdrs4 &&
+	git format-patch --stdout master..side >patch4 &&
+	sed -e "/^\$/q" patch4 >hdrs4 &&
 	grep "^To: R E Cipient <[email protected]>,\$" hdrs4 &&
 	grep "^ *S E Cipient <[email protected]>\$" hdrs4
 '
@@ -318,7 +318,7 @@ test_expect_success 'reroll count (-v)' '
 check_threading () {
 	expect="$1" &&
 	shift &&
-	(git format-patch --stdout "$@"; echo $? > status.out) |
+	(git format-patch --stdout "$@"; echo $? >status.out) |
 	# Prints everything between the Message-ID and In-Reply-To,
 	# and replaces all Message-ID-lookalikes by a sequence number
 	perl -ne '
@@ -333,12 +333,12 @@ check_threading () {
 			print;
 		}
 		print "---\n" if /^From /i;
-	' > actual &&
+	' >actual &&
 	test 0 = "$(cat status.out)" &&
 	test_cmp "$expect" actual
 }
 
-cat >> expect.no-threading <<EOF
+cat >>expect.no-threading <<EOF
 ---
 ---
 ---
@@ -349,7 +349,7 @@ test_expect_success 'no threading' '
 	check_threading expect.no-threading master
 '
 
-cat > expect.thread <<EOF
+cat >expect.thread <<EOF
 ---
 Message-Id: <0>
 ---
@@ -366,7 +366,7 @@ test_expect_success 'thread' '
 	check_threading expect.thread --thread master
 '
 
-cat > expect.in-reply-to <<EOF
+cat >expect.in-reply-to <<EOF
 ---
 Message-Id: <0>
 In-Reply-To: <1>
@@ -386,7 +386,7 @@ test_expect_success 'thread in-reply-to' '
 		--thread master
 '
 
-cat > expect.cover-letter <<EOF
+cat >expect.cover-letter <<EOF
 ---
 Message-Id: <0>
 ---
@@ -407,7 +407,7 @@ test_expect_success 'thread cover-letter' '
 	check_threading expect.cover-letter --cover-letter --thread master
 '
 
-cat > expect.cl-irt <<EOF
+cat >expect.cl-irt <<EOF
 ---
 Message-Id: <0>
 In-Reply-To: <1>
@@ -439,7 +439,7 @@ test_expect_success 'thread explicit shallow' '
 		--in-reply-to="<test.message>" --thread=shallow master
 '
 
-cat > expect.deep <<EOF
+cat >expect.deep <<EOF
 ---
 Message-Id: <0>
 ---
@@ -457,7 +457,7 @@ test_expect_success 'thread deep' '
 	check_threading expect.deep --thread=deep master
 '
 
-cat > expect.deep-irt <<EOF
+cat >expect.deep-irt <<EOF
 ---
 Message-Id: <0>
 In-Reply-To: <1>
@@ -480,7 +480,7 @@ test_expect_success 'thread deep in-reply-to' '
 		--in-reply-to="<test.message>" master
 '
 
-cat > expect.deep-cl <<EOF
+cat >expect.deep-cl <<EOF
 ---
 Message-Id: <0>
 ---
@@ -504,7 +504,7 @@ test_expect_success 'thread deep cover-letter' '
 	check_threading expect.deep-cl --cover-letter --thread=deep master
 '
 
-cat > expect.deep-cl-irt <<EOF
+cat >expect.deep-cl-irt <<EOF
 ---
 Message-Id: <0>
 In-Reply-To: <1>
@@ -584,7 +584,7 @@ test_expect_success 'cover-letter inherits diff options' '
 	grep "file => foo .* 0 *\$" 0000-cover-letter.patch
 '
 
-cat > expect << EOF
+cat >expect <<EOF
   This is an excessively long subject line for a message due to the
     habit some projects have of not having a short, one-line subject at
     the start of the commit message, but rather sticking a whole
@@ -596,11 +596,11 @@ EOF
 
 test_expect_success 'shortlog of cover-letter wraps overly-long onelines' '
 	git format-patch --cover-letter -2 &&
-	sed -e "1,/A U Thor/d" -e "/^\$/q" < 0000-cover-letter.patch > output &&
+	sed -e "1,/A U Thor/d" -e "/^\$/q" <0000-cover-letter.patch >output &&
 	test_cmp expect output
 '
 
-cat > expect << EOF
+cat >expect <<EOF
 index $before..$after 100644
 --- a/file
 +++ b/file
@@ -620,7 +620,7 @@ test_expect_success 'format-patch respects -U' '
 	test_cmp expect output
 '
 
-cat > expect << EOF
+cat >expect <<EOF
 
 diff --git a/file b/file
 index $before..$after 100644
@@ -635,7 +635,7 @@ EOF
 
 test_expect_success 'format-patch -p suppresses stat' '
 	git format-patch -p -2 &&
-	sed -e "1,/^\$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output &&
+	sed -e "1,/^\$/d" -e "/^+5/q" <0001-This-is-an-excessively-long-subject-line-for-a-messa.patch >output &&
 	test_cmp expect output
 '
 
@@ -689,7 +689,7 @@ test_expect_success 'format-patch from a subdirectory (3)' '
 '
 
 test_expect_success 'format-patch --in-reply-to' '
-	git format-patch -1 --stdout --in-reply-to "[email protected]" > patch8 &&
+	git format-patch -1 --stdout --in-reply-to "[email protected]" >patch8 &&
 	grep "^In-Reply-To: <[email protected]>" patch8 &&
 	grep "^References: <[email protected]>" patch8
 '
@@ -780,21 +780,21 @@ test_expect_success 'format-patch with multiple notes refs' '
 	! grep "this is note 2" out
 '
 
-echo "fatal: --name-only does not make sense" > expect.name-only
-echo "fatal: --name-status does not make sense" > expect.name-status
-echo "fatal: --check does not make sense" > expect.check
+echo "fatal: --name-only does not make sense" >expect.name-only
+echo "fatal: --name-status does not make sense" >expect.name-status
+echo "fatal: --check does not make sense" >expect.check
 
 test_expect_success 'options no longer allowed for format-patch' '
-	test_must_fail git format-patch --name-only 2> output &&
+	test_must_fail git format-patch --name-only 2>output &&
 	test_i18ncmp expect.name-only output &&
-	test_must_fail git format-patch --name-status 2> output &&
+	test_must_fail git format-patch --name-status 2>output &&
 	test_i18ncmp expect.name-status output &&
-	test_must_fail git format-patch --check 2> output &&
+	test_must_fail git format-patch --check 2>output &&
 	test_i18ncmp expect.check output
 '
 
 test_expect_success 'format-patch --numstat should produce a patch' '
-	git format-patch --numstat --stdout master..side > output &&
+	git format-patch --numstat --stdout master..side >output &&
 	test 5 = $(grep "^diff --git a/" output | wc -l)
 '
 
@@ -1610,14 +1610,14 @@ test_expect_success 'format-patch --base' '
 	echo "base-commit: $(git rev-parse HEAD~3)" >>expect &&
 	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expect &&
 	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expect &&
-	signature >> expect &&
+	signature >>expect &&
 	test_cmp expect actual1 &&
 	test_cmp expect actual2 &&
 	echo >fail &&
 	echo "base-commit: $(git rev-parse HEAD~3)" >>fail &&
 	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --unstable | awk "{print \$1}")" >>fail &&
 	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --unstable | awk "{print \$1}")" >>fail &&
-	signature >> fail &&
+	signature >>fail &&
 	! test_cmp fail actual1 &&
 	! test_cmp fail actual2
 '
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#65 lore raw

PATCH v2 6/13 t4014: use indentable here-docs

In reply to Denton Liu

The convention is to use indentable here-docs within test cases so that the here-docs line up with the rest of the code within the test case. Change here-docs from <<\EOF to <<-\EOF so that they can be indented along with the rest of the test case.

---
 t/t4014-format-patch.sh | 368 ++++++++++++++++++++--------------------
 1 file changed, 184 insertions(+), 184 deletions(-)
t/t4014-format-patch.sh +184 -184
index 075affb1e5..c07d868491 100755
@@ -1211,282 +1211,282 @@ append_signoff()
 
 test_expect_success 'signoff: commit with no body' '
 	append_signoff </dev/null >actual &&
-	cat <<\EOF | sed "s/EOL$//" >expect &&
-4:Subject: [PATCH] EOL
-8:
-9:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	cat <<-\EOF | sed "s/EOL$//" >expect &&
+	4:Subject: [PATCH] EOL
+	8:
+	9:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: commit with only subject' '
 	echo subject | append_signoff >actual &&
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-9:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	9:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: commit with only subject that does not end with NL' '
 	printf subject | append_signoff >actual &&
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-9:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	9:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: no existing signoffs' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-11:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	body
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	11:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: no existing signoffs and no trailing NL' '
 	printf "subject\n\nbody" | append_signoff >actual &&
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-11:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	11:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: some random signoff' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
+	body
 
-Signed-off-by: my@house
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-11:Signed-off-by: my@house
-12:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	Signed-off-by: my@house
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	11:Signed-off-by: my@house
+	12:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: misc conforming footer elements' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
+	body
 
-Signed-off-by: my@house
-(cherry picked from commit da39a3ee5e6b4b0d3255bfef95601890afd80709)
-Tested-by: Some One <[email protected]>
-Bug: 1234
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-11:Signed-off-by: my@house
-15:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	Signed-off-by: my@house
+	(cherry picked from commit da39a3ee5e6b4b0d3255bfef95601890afd80709)
+	Tested-by: Some One <[email protected]>
+	Bug: 1234
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	11:Signed-off-by: my@house
+	15:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: some random signoff-alike' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
-Fooled-by-me: my@house
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-11:
-12:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	body
+	Fooled-by-me: my@house
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	11:
+	12:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: not really a signoff' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-I want to mention about Signed-off-by: here.
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-9:I want to mention about Signed-off-by: here.
-10:
-11:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	I want to mention about Signed-off-by: here.
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	9:I want to mention about Signed-off-by: here.
+	10:
+	11:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: not really a signoff (2)' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-My unfortunate
-Signed-off-by: example happens to be wrapped here.
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:Signed-off-by: example happens to be wrapped here.
-11:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	My unfortunate
+	Signed-off-by: example happens to be wrapped here.
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:Signed-off-by: example happens to be wrapped here.
+	11:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: valid S-o-b paragraph in the middle' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-Signed-off-by: my@house
-Signed-off-by: your@house
+	Signed-off-by: my@house
+	Signed-off-by: your@house
 
-A lot of houses.
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-9:Signed-off-by: my@house
-10:Signed-off-by: your@house
-11:
-13:
-14:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	A lot of houses.
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	9:Signed-off-by: my@house
+	10:Signed-off-by: your@house
+	11:
+	13:
+	14:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: the same signoff at the end' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
+	body
 
-Signed-off-by: C O Mitter <[email protected]>
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-11:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	11:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: the same signoff at the end, no trailing NL' '
 	printf "subject\n\nSigned-off-by: C O Mitter <[email protected]>" |
 		append_signoff >actual &&
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-9:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	9:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: the same signoff NOT at the end' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
+	body
 
-Signed-off-by: C O Mitter <[email protected]>
-Signed-off-by: my@house
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-11:Signed-off-by: C O Mitter <[email protected]>
-12:Signed-off-by: my@house
-EOF
+	Signed-off-by: C O Mitter <[email protected]>
+	Signed-off-by: my@house
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	11:Signed-off-by: C O Mitter <[email protected]>
+	12:Signed-off-by: my@house
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: tolerate garbage in conforming footer' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
+	body
 
-Tested-by: my@house
-Some Trash
-Signed-off-by: C O Mitter <[email protected]>
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-13:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	Tested-by: my@house
+	Some Trash
+	Signed-off-by: C O Mitter <[email protected]>
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	13:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: respect trailer config' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-Myfooter: x
-Some Trash
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-11:
-12:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	Myfooter: x
+	Some Trash
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	11:
+	12:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual &&
 
 	test_config trailer.Myfooter.ifexists add &&
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-Myfooter: x
-Some Trash
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-11:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	Myfooter: x
+	Some Trash
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	11:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
 test_expect_success 'signoff: footer begins with non-signoff without @ sign' '
-	append_signoff <<\EOF >actual &&
-subject
+	append_signoff <<-\EOF >actual &&
+	subject
 
-body
+	body
 
-Reviewed-id: Noone
-Tested-by: my@house
-Change-id: Ideadbeef
-Signed-off-by: C O Mitter <[email protected]>
-Bug: 1234
-EOF
-	cat >expect <<\EOF &&
-4:Subject: [PATCH] subject
-8:
-10:
-14:Signed-off-by: C O Mitter <[email protected]>
-EOF
+	Reviewed-id: Noone
+	Tested-by: my@house
+	Change-id: Ideadbeef
+	Signed-off-by: C O Mitter <[email protected]>
+	Bug: 1234
+	EOF
+	cat >expect <<-\EOF &&
+	4:Subject: [PATCH] subject
+	8:
+	10:
+	14:Signed-off-by: C O Mitter <[email protected]>
+	EOF
 	test_cmp expect actual
 '
 
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#66 lore raw

PATCH v2 7/13 t4014: drop redirections to /dev/null

In reply to Denton Liu

Since output is silenced when running without -v and debugging output is useful with -v, remove redirections to /dev/null as it is not useful.

---
 t/t4014-format-patch.sh | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
t/t4014-format-patch.sh +6 -6
index c07d868491..2048fb2008 100755
@@ -1502,42 +1502,42 @@ test_expect_success 'cover letter using branch description (1)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
 	git format-patch --stdout --cover-letter master >actual &&
-	grep hello actual >/dev/null
+	grep hello actual
 '
 
 test_expect_success 'cover letter using branch description (2)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
 	git format-patch --stdout --cover-letter rebuild-1~2..rebuild-1 >actual &&
-	grep hello actual >/dev/null
+	grep hello actual
 '
 
 test_expect_success 'cover letter using branch description (3)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
 	git format-patch --stdout --cover-letter ^master rebuild-1 >actual &&
-	grep hello actual >/dev/null
+	grep hello actual
 '
 
 test_expect_success 'cover letter using branch description (4)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
 	git format-patch --stdout --cover-letter master.. >actual &&
-	grep hello actual >/dev/null
+	grep hello actual
 '
 
 test_expect_success 'cover letter using branch description (5)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
 	git format-patch --stdout --cover-letter -2 HEAD >actual &&
-	grep hello actual >/dev/null
+	grep hello actual
 '
 
 test_expect_success 'cover letter using branch description (6)' '
 	git checkout rebuild-1 &&
 	test_config branch.rebuild-1.description hello &&
 	git format-patch --stdout --cover-letter -2 >actual &&
-	grep hello actual >/dev/null
+	grep hello actual
 '
 
 test_expect_success 'cover letter with nothing' '
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#67 lore raw

PATCH v2 8/13 t4014: let sed open its own files

In reply to Denton Liu

In some cases, we were using a redirection operator to feed input into sed. However, since sed is capable of opening its own files, make sed open its own files instead of redirecting input into it.

---
 t/t4014-format-patch.sh | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
t/t4014-format-patch.sh +14 -14
index 2048fb2008..35cf798847 100755
@@ -596,7 +596,7 @@ EOF
 
 test_expect_success 'shortlog of cover-letter wraps overly-long onelines' '
 	git format-patch --cover-letter -2 &&
-	sed -e "1,/A U Thor/d" -e "/^\$/q" <0000-cover-letter.patch >output &&
+	sed -e "1,/A U Thor/d" -e "/^\$/q" 0000-cover-letter.patch >output &&
 	test_cmp expect output
 '
 
@@ -635,7 +635,7 @@ EOF
 
 test_expect_success 'format-patch -p suppresses stat' '
 	git format-patch -p -2 &&
-	sed -e "1,/^\$/d" -e "/^+5/q" <0001-This-is-an-excessively-long-subject-line-for-a-messa.patch >output &&
+	sed -e "1,/^\$/d" -e "/^+5/q" 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch >output &&
 	test_cmp expect output
 '
 
@@ -890,7 +890,7 @@ test_expect_success 'prepare mail-signature input' '
 test_expect_success '--signature-file=file works' '
 	git format-patch --stdout --signature-file=mail-signature -1 >output &&
 	check_patch output &&
-	sed -e "1,/^-- \$/d" <output >actual &&
+	sed -e "1,/^-- \$/d" output >actual &&
 	{
 		cat mail-signature && echo
 	} >expect &&
@@ -901,7 +901,7 @@ test_expect_success 'format.signaturefile works' '
 	test_config format.signaturefile mail-signature &&
 	git format-patch --stdout -1 >output &&
 	check_patch output &&
-	sed -e "1,/^-- \$/d" <output >actual &&
+	sed -e "1,/^-- \$/d" output >actual &&
 	{
 		cat mail-signature && echo
 	} >expect &&
@@ -923,7 +923,7 @@ test_expect_success '--signature-file overrides format.signaturefile' '
 	git format-patch --stdout \
 			--signature-file=other-mail-signature -1 >output &&
 	check_patch output &&
-	sed -e "1,/^-- \$/d" <output >actual &&
+	sed -e "1,/^-- \$/d" output >actual &&
 	{
 		cat other-mail-signature && echo
 	} >expect &&
@@ -992,7 +992,7 @@ test_expect_success 'format-patch wraps extremely long subject (ascii)' '
 	git add file &&
 	git commit -m "$M512" &&
 	git format-patch --stdout -1 >patch &&
-	sed -n "/^Subject/p; /^ /p; /^$/q" <patch >subject &&
+	sed -n "/^Subject/p; /^ /p; /^$/q" patch >subject &&
 	test_cmp expect subject
 '
 
@@ -1031,7 +1031,7 @@ test_expect_success 'format-patch wraps extremely long subject (rfc2047)' '
 	git add file &&
 	git commit -m "$M512" &&
 	git format-patch --stdout -1 >patch &&
-	sed -n "/^Subject/p; /^ /p; /^$/q" <patch >subject &&
+	sed -n "/^Subject/p; /^ /p; /^$/q" patch >subject &&
 	test_cmp expect subject
 '
 
@@ -1040,7 +1040,7 @@ check_author() {
 	git add file &&
 	GIT_AUTHOR_NAME=$1 git commit -m author-check &&
 	git format-patch --stdout -1 >patch &&
-	sed -n "/^From: /p; /^ /p; /^$/q" <patch >actual &&
+	sed -n "/^From: /p; /^ /p; /^$/q" patch >actual &&
 	test_cmp expect actual
 }
 
@@ -1160,7 +1160,7 @@ test_expect_success '--from=ident replaces author' '
 	From: A U Thor <[email protected]>
 
 	EOF
-	sed -ne "/^From:/p; /^$/p; /^---$/q" <patch >patch.head &&
+	sed -ne "/^From:/p; /^$/p; /^---$/q" patch >patch.head &&
 	test_cmp expect patch.head
 '
 
@@ -1172,7 +1172,7 @@ test_expect_success '--from uses committer ident' '
 	From: A U Thor <[email protected]>
 
 	EOF
-	sed -ne "/^From:/p; /^$/p; /^---$/q" <patch >patch.head &&
+	sed -ne "/^From:/p; /^$/p; /^---$/q" patch >patch.head &&
 	test_cmp expect patch.head
 '
 
@@ -1182,7 +1182,7 @@ test_expect_success '--from omits redundant in-body header' '
 	From: A U Thor <[email protected]>
 
 	EOF
-	sed -ne "/^From:/p; /^$/p; /^---$/q" <patch >patch.head &&
+	sed -ne "/^From:/p; /^$/p; /^---$/q" patch >patch.head &&
 	test_cmp expect patch.head
 '
 
@@ -1197,7 +1197,7 @@ test_expect_success 'in-body headers trigger content encoding' '
 	From: éxötìc <[email protected]>
 
 	EOF
-	sed -ne "/^From:/p; /^$/p; /^Content-Type/p; /^---$/q" <patch >patch.head &&
+	sed -ne "/^From:/p; /^$/p; /^Content-Type/p; /^---$/q" patch >patch.head &&
 	test_cmp expect patch.head
 '
 
@@ -1788,7 +1788,7 @@ test_expect_success 'interdiff: cover-letter' '
 	git format-patch --cover-letter --interdiff=boop~2 -1 boop &&
 	test_i18ngrep "^Interdiff:$" 0000-cover-letter.patch &&
 	test_i18ngrep ! "^Interdiff:$" 0001-fleep.patch &&
-	sed "1,/^@@ /d; /^-- $/q" <0000-cover-letter.patch >actual &&
+	sed "1,/^@@ /d; /^-- $/q" 0000-cover-letter.patch >actual &&
 	test_cmp expect actual
 '
 
@@ -1804,7 +1804,7 @@ test_expect_success 'interdiff: solo-patch' '
 	EOF
 	git format-patch --interdiff=boop~2 -1 boop &&
 	test_i18ngrep "^Interdiff:$" 0001-fleep.patch &&
-	sed "1,/^  @@ /d; /^$/q" <0001-fleep.patch >actual &&
+	sed "1,/^  @@ /d; /^$/q" 0001-fleep.patch >actual &&
 	test_cmp expect actual
 '
 
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#68 lore raw

PATCH v2 9/13 t4014: use test_line_count() where possible

In reply to Denton Liu

Convert all instances of cnt=$(... | wc -l) && test $cnt = N into uses of test_line_count().

While we're at it, convert one instance of a Git command upstream of a pipe into two commands. This prevents a failure of a Git command from being masked since only the return code of the last member of the pipe is shown.

---
 t/t4014-format-patch.sh | 35 +++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)
t/t4014-format-patch.sh +19 -16
index 35cf798847..18142ee5fa 100755
@@ -60,23 +60,23 @@ test_expect_success setup '
 
 test_expect_success 'format-patch --ignore-if-in-upstream' '
 	git format-patch --stdout master..side >patch0 &&
-	cnt=$(grep "^From " patch0 | wc -l) &&
-	test $cnt = 3
+	grep "^From " patch0 >from0 &&
+	test_line_count = 3 from0
 '
 
 test_expect_success 'format-patch --ignore-if-in-upstream' '
 	git format-patch --stdout \
 		--ignore-if-in-upstream master..side >patch1 &&
-	cnt=$(grep "^From " patch1 | wc -l) &&
-	test $cnt = 2
+	grep "^From " patch1 >from1 &&
+	test_line_count = 2 from1
 '
 
 test_expect_success 'format-patch --ignore-if-in-upstream handles tags' '
 	git tag -a v1 -m tag side &&
 	git tag -a v2 -m tag master &&
 	git format-patch --stdout --ignore-if-in-upstream v2..v1 >patch1 &&
-	cnt=$(grep "^From " patch1 | wc -l) &&
-	test $cnt = 2
+	grep "^From " patch1 >from1 &&
+	test_line_count = 2 from1
 '
 
 test_expect_success "format-patch doesn't consider merge commits" '
@@ -90,22 +90,23 @@ test_expect_success "format-patch doesn't consider merge commits" '
 	git checkout -b merger master &&
 	test_tick &&
 	git merge --no-ff slave &&
-	cnt=$(git format-patch -3 --stdout | grep "^From " | wc -l) &&
-	test $cnt = 3
+	git format-patch -3 --stdout >patch &&
+	grep "^From " patch >from &&
+	test_line_count = 3 from
 '
 
 test_expect_success 'format-patch result applies' '
 	git checkout -b rebuild-0 master &&
 	git am -3 patch0 &&
-	cnt=$(git rev-list master.. | wc -l) &&
-	test $cnt = 2
+	git rev-list master.. >list &&
+	test_line_count = 2 list
 '
 
 test_expect_success 'format-patch --ignore-if-in-upstream result applies' '
 	git checkout -b rebuild-1 master &&
 	git am -3 patch1 &&
-	cnt=$(git rev-list master.. | wc -l) &&
-	test $cnt = 2
+	git rev-list master.. >list &&
+	test_line_count = 2 list
 '
 
 test_expect_success 'commit did not screw up the log message' '
@@ -795,7 +796,8 @@ test_expect_success 'options no longer allowed for format-patch' '
 
 test_expect_success 'format-patch --numstat should produce a patch' '
 	git format-patch --numstat --stdout master..side >output &&
-	test 5 = $(grep "^diff --git a/" output | wc -l)
+	grep "^diff --git a/" output >diff &&
+	test_line_count = 5 diff
 '
 
 test_expect_success 'format-patch -- <path>' '
@@ -852,8 +854,8 @@ test_expect_success 'format-patch --signature --cover-letter' '
 	git config --unset-all format.signature &&
 	git format-patch --stdout --signature="my sig" --cover-letter \
 		-1 >output &&
-	grep "my sig" output &&
-	test 2 = $(grep "my sig" output | wc -l)
+	grep "my sig" output >sig &&
+	test_line_count = 2 sig
 '
 
 test_expect_success 'format.signature="" suppresses signatures' '
@@ -1591,7 +1593,8 @@ test_expect_success 'format-patch format.outputDirectory option' '
 	test_config format.outputDirectory patches &&
 	rm -fr patches &&
 	git format-patch master..side &&
-	test $(git rev-list master..side | wc -l) -eq $(ls patches | wc -l)
+	git rev-list master..side >list &&
+	test_line_count = $(ls patches | wc -l) list
 '
 
 test_expect_success 'format-patch -o overrides format.outputDirectory' '
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#69 lore raw

PATCH v2 10/13 t4014: remove confusing pipe in check_threading()

In reply to Denton Liu

In check_threading(), there was a Git command in the upstream of a pipe. In order to not lose its status code, it was saved into a file. However, this may be confusing so rewrite to redirect IO to file. This allows us to directly use the conventional &&-chain.

---
 t/t4014-format-patch.sh | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
t/t4014-format-patch.sh +2 -3
index 18142ee5fa..67f4c62ed6 100755
@@ -319,7 +319,7 @@ test_expect_success 'reroll count (-v)' '
 check_threading () {
 	expect="$1" &&
 	shift &&
-	(git format-patch --stdout "$@"; echo $? >status.out) |
+	git format-patch --stdout "$@" >patch &&
 	# Prints everything between the Message-ID and In-Reply-To,
 	# and replaces all Message-ID-lookalikes by a sequence number
 	perl -ne '
@@ -334,8 +334,7 @@ check_threading () {
 			print;
 		}
 		print "---\n" if /^From /i;
-	' >actual &&
-	test 0 = "$(cat status.out)" &&
+	' <patch >actual &&
 	test_cmp "$expect" actual
 }
 
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#70 lore raw

PATCH v2 11/13 t4014: stop losing return codes of git commands

In reply to Denton Liu

Currently, there are two ways where the return codes of Git commands are lost. The first way is when a command is in the upstream of a pipe. In a pipe, only the return code of the last command is used. Thus, all other commands will have their return codes masked. Rewrite pipes so that there are no Git commands upstream.

The other way is when a command is in a non-assignment subshell. The return code will be lost in favour of the surrounding command's. Rewrite instances of this such that Git commands output to a file and surrounding commands only call subshells with non-Git commands.

---
 t/t4014-format-patch.sh | 197 ++++++++++++++++++++++++----------------
 1 file changed, 120 insertions(+), 77 deletions(-)
t/t4014-format-patch.sh +120 -77
index 67f4c62ed6..83f52614d3 100755
@@ -33,7 +33,8 @@ test_expect_success setup '
 	git commit -m "Side changes #3 with \\n backslash-n in it." &&
 
 	git checkout master &&
-	git diff-tree -p C2 | git apply --index &&
+	git diff-tree -p C2 >patch &&
+	git apply --index <patch &&
 	test_tick &&
 	git commit -m "Master accepts moral equivalent of #2" &&
 
@@ -110,7 +111,8 @@ test_expect_success 'format-patch --ignore-if-in-upstream result applies' '
 '
 
 test_expect_success 'commit did not screw up the log message' '
-	git cat-file commit side | grep "^Side .* with .* backslash-n"
+	git cat-file commit side >actual &&
+	grep "^Side .* with .* backslash-n" actual
 '
 
 test_expect_success 'format-patch did not screw up the log message' '
@@ -119,7 +121,8 @@ test_expect_success 'format-patch did not screw up the log message' '
 '
 
 test_expect_success 'replay did not screw up the log message' '
-	git cat-file commit rebuild-1 | grep "^Side .* with .* backslash-n"
+	git cat-file commit rebuild-1 >actual &&
+	grep "^Side .* with .* backslash-n" actual
 '
 
 test_expect_success 'extra headers' '
@@ -153,63 +156,73 @@ test_expect_success 'extra headers with multiple To:s' '
 
 test_expect_success 'additional command line cc (ascii)' '
 	git config --replace-all format.headers "Cc: R E Cipient <[email protected]>" &&
-	git format-patch --cc="S E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch5 &&
-	grep "^Cc: R E Cipient <[email protected]>,\$" patch5 &&
-	grep "^ *S E Cipient <[email protected]>\$" patch5
+	git format-patch --cc="S E Cipient <[email protected]>" --stdout master..side >patch5 &&
+	sed -e "/^\$/q" patch5 >hdrs5 &&
+	grep "^Cc: R E Cipient <[email protected]>,\$" hdrs5 &&
+	grep "^ *S E Cipient <[email protected]>\$" hdrs5
 '
 
 test_expect_failure 'additional command line cc (rfc822)' '
 	git config --replace-all format.headers "Cc: R E Cipient <[email protected]>" &&
-	git format-patch --cc="S. E. Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch5 &&
-	grep "^Cc: R E Cipient <[email protected]>,\$" patch5 &&
-	grep "^ *\"S. E. Cipient\" <[email protected]>\$" patch5
+	git format-patch --cc="S. E. Cipient <[email protected]>" --stdout master..side >patch5 &&
+	sed -e "/^\$/q" patch5 >hdrs5 &&
+	grep "^Cc: R E Cipient <[email protected]>,\$" hdrs5 &&
+	grep "^ *\"S. E. Cipient\" <[email protected]>\$" hdrs5
 '
 
 test_expect_success 'command line headers' '
 	git config --unset-all format.headers &&
-	git format-patch --add-header="Cc: R E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch6 &&
-	grep "^Cc: R E Cipient <[email protected]>\$" patch6
+	git format-patch --add-header="Cc: R E Cipient <[email protected]>" --stdout master..side >patch6 &&
+	sed -e "/^\$/q" patch6 >hdrs6 &&
+	grep "^Cc: R E Cipient <[email protected]>\$" hdrs6
 '
 
 test_expect_success 'configuration headers and command line headers' '
 	git config --replace-all format.headers "Cc: R E Cipient <[email protected]>" &&
-	git format-patch --add-header="Cc: S E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch7 &&
-	grep "^Cc: R E Cipient <[email protected]>,\$" patch7 &&
-	grep "^ *S E Cipient <[email protected]>\$" patch7
+	git format-patch --add-header="Cc: S E Cipient <[email protected]>" --stdout master..side >patch7 &&
+	sed -e "/^\$/q" patch7 >hdrs7 &&
+	grep "^Cc: R E Cipient <[email protected]>,\$" hdrs7 &&
+	grep "^ *S E Cipient <[email protected]>\$" hdrs7
 '
 
 test_expect_success 'command line To: header (ascii)' '
 	git config --unset-all format.headers &&
-	git format-patch --to="R E Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
-	grep "^To: R E Cipient <[email protected]>\$" patch8
+	git format-patch --to="R E Cipient <[email protected]>" --stdout master..side >patch8 &&
+	sed -e "/^\$/q" patch8 >hdrs8 &&
+	grep "^To: R E Cipient <[email protected]>\$" hdrs8
 '
 
 test_expect_failure 'command line To: header (rfc822)' '
-	git format-patch --to="R. E. Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
-	grep "^To: \"R. E. Cipient\" <[email protected]>\$" patch8
+	git format-patch --to="R. E. Cipient <[email protected]>" --stdout master..side >patch8 &&
+	sed -e "/^\$/q" patch8 >hdrs8 &&
+	grep "^To: \"R. E. Cipient\" <[email protected]>\$" hdrs8
 '
 
 test_expect_failure 'command line To: header (rfc2047)' '
-	git format-patch --to="R Ä Cipient <[email protected]>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
-	grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected]>\$" patch8
+	git format-patch --to="R Ä Cipient <[email protected]>" --stdout master..side >patch8 &&
+	sed -e "/^\$/q" patch8 >hdrs8 &&
+	grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected]>\$" hdrs8
 '
 
 test_expect_success 'configuration To: header (ascii)' '
 	git config format.to "R E Cipient <[email protected]>" &&
-	git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
-	grep "^To: R E Cipient <[email protected]>\$" patch9
+	git format-patch --stdout master..side >patch9 &&
+	sed -e "/^\$/q" patch9 >hdrs9 &&
+	grep "^To: R E Cipient <[email protected]>\$" hdrs9
 '
 
 test_expect_failure 'configuration To: header (rfc822)' '
 	git config format.to "R. E. Cipient <[email protected]>" &&
-	git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
-	grep "^To: \"R. E. Cipient\" <[email protected]>\$" patch9
+	git format-patch --stdout master..side >patch9 &&
+	sed -e "/^\$/q" patch9 >hdrs9 &&
+	grep "^To: \"R. E. Cipient\" <[email protected]>\$" hdrs9
 '
 
 test_expect_failure 'configuration To: header (rfc2047)' '
 	git config format.to "R Ä Cipient <[email protected]>" &&
-	git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
-	grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected]>\$" patch9
+	git format-patch --stdout master..side >patch9 &&
+	sed -e "/^\$/q" patch9 >hdrs9 &&
+	grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected]>\$" hdrs9
 '
 
 # check_patch <patch>: Verify that <patch> looks like a half-sane
@@ -221,76 +234,76 @@ check_patch () {
 }
 
 test_expect_success 'format.from=false' '
-	git -c format.from=false format-patch --stdout master..side |
-	sed -e "/^\$/q" >patch &&
+	git -c format.from=false format-patch --stdout master..side >patch &&
+	sed -e "/^\$/q" patch >hdrs &&
 	check_patch patch &&
-	! grep "^From: C O Mitter <[email protected]>\$" patch
+	! grep "^From: C O Mitter <[email protected]>\$" hdrs
 '
 
 test_expect_success 'format.from=true' '
-	git -c format.from=true format-patch --stdout master..side |
-	sed -e "/^\$/q" >patch &&
-	check_patch patch &&
-	grep "^From: C O Mitter <[email protected]>\$" patch
+	git -c format.from=true format-patch --stdout master..side >patch &&
+	sed -e "/^\$/q" patch >hdrs &&
+	check_patch hdrs &&
+	grep "^From: C O Mitter <[email protected]>\$" hdrs
 '
 
 test_expect_success 'format.from with address' '
-	git -c format.from="F R Om <[email protected]>" format-patch --stdout master..side |
-	sed -e "/^\$/q" >patch &&
-	check_patch patch &&
-	grep "^From: F R Om <[email protected]>\$" patch
+	git -c format.from="F R Om <[email protected]>" format-patch --stdout master..side >patch &&
+	sed -e "/^\$/q" patch >hdrs &&
+	check_patch hdrs &&
+	grep "^From: F R Om <[email protected]>\$" hdrs
 '
 
 test_expect_success '--no-from overrides format.from' '
-	git -c format.from="F R Om <[email protected]>" format-patch --no-from --stdout master..side |
-	sed -e "/^\$/q" >patch &&
-	check_patch patch &&
-	! grep "^From: F R Om <[email protected]>\$" patch
+	git -c format.from="F R Om <[email protected]>" format-patch --no-from --stdout master..side >patch &&
+	sed -e "/^\$/q" patch >hdrs &&
+	check_patch hdrs &&
+	! grep "^From: F R Om <[email protected]>\$" hdrs
 '
 
 test_expect_success '--from overrides format.from' '
-	git -c format.from="F R Om <[email protected]>" format-patch --from --stdout master..side |
-	sed -e "/^\$/q" >patch &&
-	check_patch patch &&
-	! grep "^From: F R Om <[email protected]>\$" patch
+	git -c format.from="F R Om <[email protected]>" format-patch --from --stdout master..side >patch &&
+	sed -e "/^\$/q" patch >hdrs &&
+	check_patch hdrs &&
+	! grep "^From: F R Om <[email protected]>\$" hdrs
 '
 
 test_expect_success '--no-to overrides config.to' '
 	git config --replace-all format.to \
 		"R E Cipient <[email protected]>" &&
-	git format-patch --no-to --stdout master..side |
-	sed -e "/^\$/q" >patch10 &&
-	check_patch patch10 &&
-	! grep "^To: R E Cipient <[email protected]>\$" patch10
+	git format-patch --no-to --stdout master..side >patch10 &&
+	sed -e "/^\$/q" patch10 >hdrs10 &&
+	check_patch hdrs10 &&
+	! grep "^To: R E Cipient <[email protected]>\$" hdrs10
 '
 
 test_expect_success '--no-to and --to replaces config.to' '
 	git config --replace-all format.to \
 		"Someone <[email protected]>" &&
 	git format-patch --no-to --to="Someone Else <[email protected]>" \
-		--stdout master..side |
-	sed -e "/^\$/q" >patch11 &&
-	check_patch patch11 &&
-	! grep "^To: Someone <[email protected]>\$" patch11 &&
-	grep "^To: Someone Else <[email protected]>\$" patch11
+		--stdout master..side >patch11 &&
+	sed -e "/^\$/q" patch11 >hdrs11 &&
+	check_patch hdrs11 &&
+	! grep "^To: Someone <[email protected]>\$" hdrs11 &&
+	grep "^To: Someone Else <[email protected]>\$" hdrs11
 '
 
 test_expect_success '--no-cc overrides config.cc' '
 	git config --replace-all format.cc \
 		"C E Cipient <[email protected]>" &&
-	git format-patch --no-cc --stdout master..side |
-	sed -e "/^\$/q" >patch12 &&
-	check_patch patch12 &&
-	! grep "^Cc: C E Cipient <[email protected]>\$" patch12
+	git format-patch --no-cc --stdout master..side >patch12 &&
+	sed -e "/^\$/q" patch12 >hdrs12 &&
+	check_patch hdrs12 &&
+	! grep "^Cc: C E Cipient <[email protected]>\$" hdrs12
 '
 
 test_expect_success '--no-add-header overrides config.headers' '
 	git config --replace-all format.headers \
 		"Header1: B E Cipient <[email protected]>" &&
-	git format-patch --no-add-header --stdout master..side |
-	sed -e "/^\$/q" >patch13 &&
-	check_patch patch13 &&
-	! grep "^Header1: B E Cipient <[email protected]>\$" patch13
+	git format-patch --no-add-header --stdout master..side >patch13 &&
+	sed -e "/^\$/q" patch13 >hdrs13 &&
+	check_patch hdrs13 &&
+	! grep "^Header1: B E Cipient <[email protected]>\$" hdrs13
 '
 
 test_expect_success 'multiple files' '
@@ -808,20 +821,25 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
 	git format-patch --ignore-if-in-upstream HEAD
 '
 
-git_version="$(git --version | sed "s/.* //")"
+test_expect_success 'get git version' '
+	git_version=$(git --version) &&
+	git_version=${git_version##* }
+'
 
 signature() {
 	printf "%s\n%s\n\n" "-- " "${1:-$git_version}"
 }
 
 test_expect_success 'format-patch default signature' '
-	git format-patch --stdout -1 | tail -n 3 >output &&
+	git format-patch --stdout -1 >patch &&
+	tail -n 3 patch >output &&
 	signature >expect &&
 	test_cmp expect output
 '
 
 test_expect_success 'format-patch --signature' '
-	git format-patch --stdout --signature="my sig" -1 | tail -n 3 >output &&
+	git format-patch --stdout --signature="my sig" -1 >patch &&
+	tail -n 3 patch >output &&
 	signature "my sig" >expect &&
 	test_cmp expect output
 '
@@ -1606,19 +1624,40 @@ test_expect_success 'format-patch -o overrides format.outputDirectory' '
 
 test_expect_success 'format-patch --base' '
 	git checkout patchid &&
-	git format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual1 &&
-	git format-patch --stdout --base=HEAD~3 HEAD~.. | tail -n 7 >actual2 &&
+
+	git format-patch --stdout --base=HEAD~3 -1 >patch &&
+	tail -n 7 patch >actual1 &&
+
+	git format-patch --stdout --base=HEAD~3 HEAD~.. >patch &&
+	tail -n 7 patch >actual2 &&
+
 	echo >expect &&
-	echo "base-commit: $(git rev-parse HEAD~3)" >>expect &&
-	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expect &&
-	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expect &&
+	git rev-parse HEAD~3 >commit-id-base &&
+	echo "base-commit: $(cat commit-id-base)" >>expect &&
+
+	git show --patch HEAD~2 >patch &&
+	git patch-id --stable <patch >patch.id.raw &&
+	awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >>expect &&
+
+	git show --patch HEAD~1 >patch &&
+	git patch-id --stable <patch >patch.id.raw &&
+	awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >>expect &&
+
 	signature >>expect &&
 	test_cmp expect actual1 &&
 	test_cmp expect actual2 &&
+
 	echo >fail &&
-	echo "base-commit: $(git rev-parse HEAD~3)" >>fail &&
-	echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --unstable | awk "{print \$1}")" >>fail &&
-	echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --unstable | awk "{print \$1}")" >>fail &&
+	echo "base-commit: $(cat commit-id-base)" >>fail &&
+
+	git show --patch HEAD~2 >patch &&
+	git patch-id --unstable <patch >patch.id.raw &&
+	awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >>fail &&
+
+	git show --patch HEAD~1 >patch &&
+	git patch-id --unstable <patch >patch.id.raw &&
+	awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >>fail &&
+
 	signature >>fail &&
 	! test_cmp fail actual1 &&
 	! test_cmp fail actual2
@@ -1629,7 +1668,8 @@ test_expect_success 'format-patch --base errors out when base commit is in revis
 	test_must_fail git format-patch --base=HEAD~1 -2 &&
 	git format-patch --stdout --base=HEAD~2 -2 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse HEAD~2)" >expect &&
+	git rev-parse HEAD~2 >commit-id-base &&
+	echo "base-commit: $(cat commit-id-base)" >expect &&
 	test_cmp expect actual
 '
 
@@ -1668,7 +1708,8 @@ test_expect_success 'format-patch --base=auto' '
 	test_commit N2 &&
 	git format-patch --stdout --base=auto -2 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse upstream)" >expect &&
+	git rev-parse upstream >commit-id-base &&
+	echo "base-commit: $(cat commit-id-base)" >expect &&
 	test_cmp expect actual
 '
 
@@ -1705,7 +1746,8 @@ test_expect_success 'format-patch format.useAutoBaseoption' '
 	git config format.useAutoBase true &&
 	git format-patch --stdout -1 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse upstream)" >expect &&
+	git rev-parse upstream >commit-id-base &&
+	echo "base-commit: $(cat commit-id-base)" >expect &&
 	test_cmp expect actual
 '
 
@@ -1714,7 +1756,8 @@ test_expect_success 'format-patch --base overrides format.useAutoBase' '
 	git config format.useAutoBase true &&
 	git format-patch --stdout --base=HEAD~1 -1 >patch &&
 	grep "^base-commit:" patch >actual &&
-	echo "base-commit: $(git rev-parse HEAD~1)" >expect &&
+	git rev-parse HEAD~1 >commit-id-base &&
+	echo "base-commit: $(cat commit-id-base)" >expect &&
 	test_cmp expect actual
 '
 
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#71 lore raw

PATCH v2 12/13 Doc: add more detail for git-format-patch

In reply to Denton Liu

In git-format-patch.txt, we were missing some key user information. First of all, document the special value of --base=auto.

Next, while we're at it, surround option arguments with <> and change existing names such as "Message-Id" to "message id", which conforms with how existing documentation is written.

Finally, document the format.outputDirectory config and change format.coverletter to use camel case.

---
 Documentation/git-format-patch.txt | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)
Documentation/git-format-patch.txt +13 -10
index b9b97e63ae..0ac56f4b70 100644
@@ -17,9 +17,9 @@ SYNOPSIS
 		   [--signature-file=<file>]
 		   [-n | --numbered | -N | --no-numbered]
 		   [--start-number <n>] [--numbered-files]
-		   [--in-reply-to=Message-Id] [--suffix=.<sfx>]
+		   [--in-reply-to=<message id>] [--suffix=.<sfx>]
 		   [--ignore-if-in-upstream]
-		   [--rfc] [--subject-prefix=Subject-Prefix]
+		   [--rfc] [--subject-prefix=<subject prefix>]
 		   [(--reroll-count|-v) <n>]
 		   [--to=<email>] [--cc=<email>]
 		   [--[no-]cover-letter] [--quiet]
@@ -159,9 +159,9 @@ Beware that the default for 'git send-email' is to thread emails
 itself.  If you want `git format-patch` to take care of threading, you
 will want to ensure that threading is disabled for `git send-email`.
 
---in-reply-to=Message-Id::
+--in-reply-to=<message id>::
 	Make the first mail (or all the mails with `--no-thread`) appear as a
-	reply to the given Message-Id, which avoids breaking threads to
+	reply to the given <message id>, which avoids breaking threads to
 	provide a new patch series.
 
 --ignore-if-in-upstream::
@@ -171,9 +171,9 @@ will want to ensure that threading is disabled for `git send-email`.
 	patches being generated, and any patch that matches is
 	ignored.
 
---subject-prefix=<Subject-Prefix>::
+--subject-prefix=<subject prefix>::
 	Instead of the standard '[PATCH]' prefix in the subject
-	line, instead use '[<Subject-Prefix>]'. This
+	line, instead use '[<subject prefix>]'. This
 	allows for useful naming of a patch series, and can be
 	combined with the `--numbered` option.
 
@@ -314,7 +314,8 @@ you can use `--suffix=-patch` to get `0001-description-of-my-change-patch`.
 --base=<commit>::
 	Record the base tree information to identify the state the
 	patch series applies to.  See the BASE TREE INFORMATION section
-	below for details.
+	below for details. If <commit> is "auto", a base commit is
+	automatically chosen.
 
 --root::
 	Treat the revision argument as a <revision range>, even if it
@@ -330,8 +331,9 @@ CONFIGURATION
 -------------
 You can specify extra mail header lines to be added to each message,
 defaults for the subject prefix and file suffix, number patches when
-outputting more than one patch, add "To" or "Cc:" headers, configure
-attachments, and sign off patches with configuration variables.
+outputting more than one patch, add "To:" or "Cc:" headers, configure
+attachments, change the patch output directory, and sign off patches
+with configuration variables.
 
 ------------
 [format]
@@ -343,7 +345,8 @@ attachments, and sign off patches with configuration variables.
 	cc = <email>
 	attach [ = mime-boundary-string ]
 	signOff = true
-	coverletter = auto
+	outputDirectory = <directory>
+	coverLetter = auto
 ------------
 
 
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#72 lore raw

PATCH v2 13/13 config/format.txt: specify default value of format.coverLetter

In reply to Denton Liu
---
 Documentation/config/format.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/config/format.txt +1 -0
index 414a5a8a9d..cb629fa769 100644
@@ -77,6 +77,7 @@ format.coverLetter::
 	A boolean that controls whether to generate a cover-letter when
 	format-patch is invoked, but in addition can be set to "auto", to
 	generate a cover-letter only when there's more than one patch.
+	Default is false.
 
 format.outputDirectory::
 	Set a custom directory to store the resulting files instead of the
Signature · 1 line
2.23.0.248.g3a9dd8fb08
author
#73 lore raw

Re: [PATCH v2 00/13] format-patch: clean up tests and documentation

In reply to Denton Liu

Hi Junio,

I see that "dl/format-patch-doc-test-cleanup" currently has the comment "Expecting a reroll." This should be the reroll that you're expecting ;)

Also, since there haven't been any comments on the topic in a while, I propose that it should be ready for inclusion.

Thanks,

Denton

Quoted 131 lines · Denton Liu

In this reroll, I squashed Junio's suggestion into the correct patch. Also, I took Eric's suggestion and removed the weak justification (i.e. better error messages) from the sed patch since it doesn't really contribute.

As one of the older parts of the Git, the tests and documentation for format-patch have been needing cleanup for a while. Let's do that in this patchset!

This patchset is based on v3 of "format-patch: learn --infer-cover-subject option (also t4014 cleanup)"[1].

Changes since v1:

* Squash Junio's patch into the correct patch ;)

* Remove weak justification (better error messages) in 8/13

Changes since v3 of "format-patch: learn --infer-cover-subject option (also t4014 cleanup)":

* Squash in Junio's and Hannes' suggestions

* Add 't4014: let sed open its own files'

[1]: https://public-inbox.org/git/[email protected]/T/#m19570aff4828dfbd65d57cacf231c2938af1dc9f

Denton Liu (13):
t4014: drop unnecessary blank lines from test cases
t4014: s/expected/expect/
t4014: move closing sq onto its own line
t4014: use sq for test case names
t4014: remove spaces after redirect operators
t4014: use indentable here-docs
t4014: drop redirections to /dev/null
t4014: let sed open its own files
t4014: use test_line_count() where possible
t4014: remove confusing pipe in check_threading()
t4014: stop losing return codes of git commands
Doc: add more detail for git-format-patch config/format.txt: specify default value of format.coverLetter

 Documentation/config/format.txt    |   1 +
 Documentation/git-format-patch.txt |  23 +-
 t/t4014-format-patch.sh            | 814 ++++++++++++++---------------
 3 files changed, 421 insertions(+), 417 deletions(-)

Range-diff against v1:

 1:  fb000bfca2 =  1:  fb000bfca2 t4014: drop unnecessary blank lines from test cases
 2:  0a5ce9b95f =  2:  0a5ce9b95f t4014: s/expected/expect/
 3:  5c49703aa4 =  3:  5c49703aa4 t4014: move closing sq onto its own line
 4:  02a11147fd =  4:  02a11147fd t4014: use sq for test case names
 5:  8d9791c061 =  5:  8d9791c061 t4014: remove spaces after redirect operators
 6:  90ad0fcf70 =  6:  90ad0fcf70 t4014: use indentable here-docs
 7:  804b3163f8 =  7:  804b3163f8 t4014: drop redirections to /dev/null
 8:  7d9a24a979 !  8:  967e624bb4 t4014: let sed open its own files

@@ Commit message
t4014: let sed open its own files

In some cases, we were using a redirection operator to feed input into
- sed. However, since sed is capable of opening its own files and provides
- better error messages on IO failure, make sed open its own files instead
- of redirecting input into it.
+ sed. However, since sed is capable of opening its own files, make sed
+ open its own files instead of redirecting input into it.

 9:  d068d42098 =  9:  9a42ec2b7e t4014: use test_line_count() where possible
10:  6a9409cee0 = 10:  8acc90f74d t4014: remove confusing pipe in check_threading()
11:  c580ce447b = 11:  bc7355485f t4014: stop losing return codes of git commands
12:  a97f861e6a ! 12:  fd343b99c5 Doc: add more detail for git-format-patch

@@ Commit message
In git-format-patch.txt, we were missing some key user information. First of all, document the special value of --base=auto.

- Next, while we're at it, surround option arguments with <>.
+ Next, while we're at it, surround option arguments with <> and change
+ existing names such as "Message-Id" to "message id", which conforms with
+ how existing documentation is written.

Finally, document the format.outputDirectory config and change format.coverletter to use camel case.
@@ Documentation/git-format-patch.txt: SYNOPSIS
[-n | --numbered | -N | --no-numbered]
[--start-number <n>] [--numbered-files]
- [--in-reply-to=Message-Id] [--suffix=.<sfx>]
-+ [--in-reply-to=<Message-Id>] [--suffix=.<sfx>]
++ [--in-reply-to=<message id>] [--suffix=.<sfx>]
[--ignore-if-in-upstream]
- [--rfc] [--subject-prefix=Subject-Prefix]
-+ [--rfc] [--subject-prefix=<Subject-Prefix>]
++ [--rfc] [--subject-prefix=<subject prefix>]
[(--reroll-count|-v) <n>]
[--to=<email>] [--cc=<email>]
[--[no-]cover-letter] [--quiet]
@@ Documentation/git-format-patch.txt: Beware that the default for 'git send-email'
will want to ensure that threading is disabled for git send-email.

---in-reply-to=Message-Id::
-+--in-reply-to=<Message-Id>::
++--in-reply-to=<message id>::
Make the first mail (or all the mails with --no-thread) appear as a
- reply to the given Message-Id, which avoids breaking threads to
+- reply to the given Message-Id, which avoids breaking threads to
++ reply to the given <message id>, which avoids breaking threads to
provide a new patch series.
+
+ --ignore-if-in-upstream::
+@@ Documentation/git-format-patch.txt: will want to ensure that threading is disabled for git send-email.
+ patches being generated, and any patch that matches is
+ ignored.
+
+---subject-prefix=<Subject-Prefix>::
++--subject-prefix=<subject prefix>::
+ Instead of the standard '[PATCH]' prefix in the subject
+- line, instead use '[<Subject-Prefix>]'. This
++ line, instead use '[<subject prefix>]'. This
+ allows for useful naming of a patch series, and can be
+ combined with the --numbered option.
+
@@ Documentation/git-format-patch.txt: you can use --suffix=-patch to get 0001-description-of-my-change-patch.
--base=<commit>::
Record the base tree information to identify the state the

13:  7c8522abf2 <  -:  ---------- config/format.txt: specify default value of format.coverLetter
 -:  ---------- > 13:  4e429e1989 config/format.txt: specify default value of format.coverLetter
Signature · 1 line
2.23.0.248.g3a9dd8fb08
#74 lore raw

Re: [PATCH v2 00/13] format-patch: clean up tests and documentation

Quoted 7 lines · Denton Liu

Hi Junio,

I see that "dl/format-patch-doc-test-cleanup" currently has the comment "Expecting a reroll." This should be the reroll that you're expecting ;)

Also, since there haven't been any comments on the topic in a while, I propose that it should be ready for inclusion.

I may be the only person who had issues applying that series from the list, with mixtures of iso-8859-1 and utf-8 causing troubles, but if I am not alone, I suspect that the reason why nobody gave a comment is because the patches did not even apply so there is nothing to base their comments on.

I wiggled them and compared the result. The range diff against what has been queued seems a bit different from what you gave below (e.g. I see log message got modified on patch #2 and the dropping of the comma made it harder to read), but the endpoint diff looks not too bad (IOW, the alloted time for the topic ran out before I started looking at each individual patches in more depth).

author
#75 lore raw

Re: [PATCH v2 00/13] format-patch: clean up tests and documentation

Quoted 7 lines · Junio C Hamano
Quoted 5 lines · Denton Liu

Hi Junio,

I see that "dl/format-patch-doc-test-cleanup" currently has the comment "Expecting a reroll." This should be the reroll that you're expecting ;)

Quoted 8 lines
Quoted 2 lines

Also, since there haven't been any comments on the topic in a while, I propose that it should be ready for inclusion.

I may be the only person who had issues applying that series from the list, with mixtures of iso-8859-1 and utf-8 causing troubles, but if I am not alone, I suspect that the reason why nobody gave a comment is because the patches did not even apply so there is nothing to base their comments on.

Which patches weren't applying properly? I managed to apply both the patchset I had locally and a fresh one I downloaded from public-inbox and both applied cleanly.

Quoted 7 lines

I wiggled them and compared the result. The range diff against what has been queued seems a bit different from what you gave below (e.g. I see log message got modified on patch #2 and the dropping of the comma made it harder to read), but the endpoint diff looks not too bad (IOW, the alloted time for the topic ran out before I started looking at each individual patches in more depth).

Hmmm, I don't think my workflow uses your topic branches properly. I've been range-diffing against the previously submitted patchsets but it seems like you expect a range-diff against the actual topic branch.

What should the ideal workflow be? I've been avoiding working directly from the topic branch since that would require me to manually remove your SOB line whenever I generate new patchsets. I guess I could manually remove your SOB line from each patch manually. I dunno. Any ideas?

Thanks,

Denton

author
#76 lore raw

v4 cover format-patch: learn --cover-from-description option

In reply to Denton Liu

Hi all, since 'dl/format-patch-doc-test-cleanup' has calmed down and merged into 'master', I think now's a good time to revive this topic. I've incorporated Philip's --cover-letter-from-description idea (and shortened it so it's not so verbose) so now it should be a lot more general than the old --infer-cover-subject.

Currently, format-patch only puts "*** SUBJECT HERE ***" when a cover letter is generated. However, it is already smart enough to be able to populate the cover letter with the branch description so there's no reason why it cannot populate the subject as well.

Teach format-patch the --cover-from-description option and corresponding format.coverFromDescripion configuration option which will allow it to populate not only the body but the subject as well.

Changes since v3:

* Change --infer-cover-subject to --cover-from-description

* No more test cleanup patches (they were merged in 'dl/format-patch-doc-test-cleanup')

Changes since v2:

* Break 1/4 into many different patches (one per paragraph of the original patch)

* Incorporate Eric's documentation/commit message suggestions

Changes since v1:

* Incorporate Eric's suggestions for cleanup in all patches

* Add patch 3/4 to make it clear what is the default value for format.coverLetter (since format.inferCoverSubject was borrowed from this config but it also did not state what the default value was)

* In 1/4, rename all instances of "expected" to "expect"

Denton Liu (3):
format-patch: remove erroneous and condition
format-patch: use enum variables
format-patch: teach --cover-from-description option

 Documentation/config/format.txt    |   6 +
 Documentation/git-format-patch.txt |  22 ++++
 builtin/log.c                      | 114 +++++++++++++------
 t/t4014-format-patch.sh            | 172 +++++++++++++++++++++++++++++
 4 files changed, 280 insertions(+), 34 deletions(-)
Signature · 1 line
2.23.0.17.g7cce04acd6.dirty
author
#77 lore raw

PATCH v4 1/3 format-patch: remove erroneous and condition

Commit 30984ed2e9 (format-patch: support deep threading, 2009-02-19), introduced the following lines:

	#define THREAD_SHALLOW 1

	[...]

	thread = git_config_bool(var, value) && THREAD_SHALLOW;

Since git_config_bool() returns a bool, the trailing && THREAD_SHALLOW is a no-op. Remove this erroneous and condition.

---
 builtin/log.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
builtin/log.c +1 -1
index 44b10b3415..7d658cecef 100644
@@ -835,7 +835,7 @@ static int git_format_config(const char *var, const char *value, void *cb)
 			thread = THREAD_SHALLOW;
 			return 0;
 		}
-		thread = git_config_bool(var, value) && THREAD_SHALLOW;
+		thread = git_config_bool(var, value);
 		return 0;
 	}
 	if (!strcmp(var, "format.signoff")) {
Signature · 1 line
2.23.0.17.g7cce04acd6.dirty
author
#78 lore raw

PATCH v4 2/3 format-patch: use enum variables

In reply to Denton Liu

Before, thread and config_cover_letter were defined as ints even though they behaved as enums. Define actual enums and change these variables to use these new definitions.

---
 builtin/log.c | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)
builtin/log.c +17 -13
index 7d658cecef..f06f5d586b 100644
@@ -764,24 +764,28 @@ static void add_header(const char *value)
 	item->string[len] = '\0';
 }
 
-#define THREAD_SHALLOW 1
-#define THREAD_DEEP 2
-static int thread;
+enum cover_setting {
+	COVER_UNSET,
+	COVER_OFF,
+	COVER_ON,
+	COVER_AUTO
+};
+
+enum thread_level {
+	THREAD_UNSET,
+	THREAD_SHALLOW,
+	THREAD_DEEP
+};
+
+static enum thread_level thread;
 static int do_signoff;
 static int base_auto;
 static char *from;
 static const char *signature = git_version_string;
 static const char *signature_file;
-static int config_cover_letter;
+static enum cover_setting config_cover_letter;
 static const char *config_output_directory;
 
-enum {
-	COVER_UNSET,
-	COVER_OFF,
-	COVER_ON,
-	COVER_AUTO
-};
-
 static int git_format_config(const char *var, const char *value, void *cb)
 {
 	struct rev_info *rev = cb;
@@ -1248,9 +1252,9 @@ static int output_directory_callback(const struct option *opt, const char *arg,
 
 static int thread_callback(const struct option *opt, const char *arg, int unset)
 {
-	int *thread = (int *)opt->value;
+	enum thread_level *thread = (enum thread_level *)opt->value;
 	if (unset)
-		*thread = 0;
+		*thread = THREAD_UNSET;
 	else if (!arg || !strcmp(arg, "shallow"))
 		*thread = THREAD_SHALLOW;
 	else if (!strcmp(arg, "deep"))
Signature · 1 line
2.23.0.17.g7cce04acd6.dirty
#79 lore raw

Re: [PATCH v4 2/3] format-patch: use enum variables

builtin/log.c static void add_header(const char *value) · line 780

Quoted 9 lines · Denton Liu
builtin/log.c +6 -3
-#define THREAD_SHALLOW 1
-#define THREAD_DEEP 2
-static int thread;
+enum thread_level {
+	THREAD_UNSET,
+	THREAD_SHALLOW,
+	THREAD_DEEP
+};
+static enum thread_level thread;

As the assignment of values do not change, this is a safe conversion even if an existing code did things like

	if (!thread)
        	... do this ...;

Hopefully nobody did arithmetic on it; thread_level may now become unsigned depending on the compiler.

builtin/log.c static void add_header(const char *value) · line 786

Quoted 2 lines
builtin/log.c +1 -1
-static int config_cover_letter;
+static enum cover_setting config_cover_letter;

Likewise about the signedness.

author
#80 lore raw

PATCH v4 3/3 format-patch: teach --cover-from-description option

In reply to Denton Liu

Before, when format-patch generated a cover letter, only the body would be populated with a branch's description while the subject would be populated with placeholder text. However, users may want to have the subject of their cover letter automatically populated in the same way.

Teach format-patch to accept the --cover-from-description option and corresponding format.coverFromDescription config, allowing users to populate different parts of the cover letter (including the subject now).

---
 Documentation/config/format.txt    |   6 +
 Documentation/git-format-patch.txt |  22 ++++
 builtin/log.c                      |  84 ++++++++++----
 t/t4014-format-patch.sh            | 172 +++++++++++++++++++++++++++++
 4 files changed, 263 insertions(+), 21 deletions(-)
Documentation/config/format.txt +6 -0
index cb629fa769..735dfcf827 100644
@@ -36,6 +36,12 @@ format.subjectPrefix::
 	The default for format-patch is to output files with the '[PATCH]'
 	subject prefix. Use this variable to change that prefix.
 
+format.coverFromDescription::
+	The default mode for format-patch to determine which parts of
+	the cover letter will be populated using the branch's
+	description. See the `--cover-from-description` option in
+	linkgit:git-format-patch[1].
+
 format.signature::
 	The default for format-patch is to output a signature containing
 	the Git version number. Use this variable to change that default.
Documentation/git-format-patch.txt +22 -0
index 0ac56f4b70..86114e4c22 100644
@@ -19,6 +19,7 @@ SYNOPSIS
 		   [--start-number <n>] [--numbered-files]
 		   [--in-reply-to=<message id>] [--suffix=.<sfx>]
 		   [--ignore-if-in-upstream]
+		   [--cover-from-description=<mode>]
 		   [--rfc] [--subject-prefix=<subject prefix>]
 		   [(--reroll-count|-v) <n>]
 		   [--to=<email>] [--cc=<email>]
@@ -171,6 +172,26 @@ will want to ensure that threading is disabled for `git send-email`.
 	patches being generated, and any patch that matches is
 	ignored.
 
+--cover-from-description=<mode>::
+	Controls which parts of the cover letter will be automatically
+	populated using the branch's description.
++
+If `<mode>` is `message` or `default`, the cover letter subject will be
+populated with placeholder text. The body of the cover letter will be
+populated with the branch's description.
++
+If `<mode>` is `subject`, the beginning of the branch description (up to
+the first blank line) will populate the cover letter subject. The
+remainder of the description will populate the body of the cover
+letter.
++
+If `<mode>` is `auto`, if the beginning of the branch description (up to
+the first line) is greater than 100 characters then the mode will be
+`message`, otherwise `subject` will be used.
++
+If `<mode>` is `none`, both the cover letter subject and body will be
+populated with placeholder text.
+
 --subject-prefix=<subject prefix>::
 	Instead of the standard '[PATCH]' prefix in the subject
 	line, instead use '[<subject prefix>]'. This
@@ -347,6 +368,7 @@ with configuration variables.
 	signOff = true
 	outputDirectory = <directory>
 	coverLetter = auto
+	inferCoverSubject = true
 ------------
 
 
builtin/log.c +63 -21

162 lines not on this page · raw message

t/t4014-format-patch.sh +172 -0

178 lines not on this page · raw message

Signature · 1 line
2.23.0.17.g7cce04acd6.dirty
#81 lore raw

Re: [PATCH v4 3/3] format-patch: teach --cover-from-description option

Quoted 22 lines · Denton Liu
Documentation/config/format.txt +6 -0
+format.coverFromDescription::
+	The default mode for format-patch to determine which parts of
+	the cover letter will be populated using the branch's
+	description. See the `--cover-from-description` option in
+	linkgit:git-format-patch[1].
+
 format.signature::
 	The default for format-patch is to output a signature containing
 	the Git version number. Use this variable to change that default.
Documentation/git-format-patch.txt +1 -0
index 0ac56f4b70..86114e4c22 100644
@@ -19,6 +19,7 @@ SYNOPSIS
 		   [--start-number <n>] [--numbered-files]
 		   [--in-reply-to=<message id>] [--suffix=.<sfx>]
 		   [--ignore-if-in-upstream]
+		   [--cover-from-description=<mode>]
 		   [--rfc] [--subject-prefix=<subject prefix>]
 		   [(--reroll-count|-v) <n>]
 		   [--to=<email>] [--cc=<email>]

Documentation/git-format-patch.txt will want to ensure that threading is disabled for `git send-email`. · line 181

Quoted 10 lines
Documentation/git-format-patch.txt +7 -0
@@ -171,6 +172,26 @@ will want to ensure that threading is disabled for `git send-email`.
 	patches being generated, and any patch that matches is
 	ignored.
 
+--cover-from-description=<mode>::
+	Controls which parts of the cover letter will be automatically
+	populated using the branch's description.
++
+If `<mode>` is `message` or `default`, the cover letter subject will be
+populated with placeholder text. The body of the cover letter will be
+populated with the branch's description.

I understand that this is what we do now, so those who want to live in the past can set the configuration variable to 'message'.

Documentation/git-format-patch.txt will want to ensure that threading is disabled for `git send-email`. · line 186

Quoted 4 lines
Documentation/git-format-patch.txt +4 -0
+If `<mode>` is `subject`, the beginning of the branch description (up to
+the first blank line) will populate the cover letter subject. The
+remainder of the description will populate the body of the cover
+letter.

s/the beginning of .*blank line)/the first paragraph of the branch description/ may be shorter, but the above is OK, too.

When description is prepared appropriately, this mode would fill both subject and body, which sounds sensible.

Documentation/git-format-patch.txt will want to ensure that threading is disabled for `git send-email`. · line 190

Quoted 3 lines
Documentation/git-format-patch.txt +3 -0
+If `<mode>` is `auto`, if the beginning of the branch description (up to
+the first line) is greater than 100 characters then the mode will be
+`message`, otherwise `subject` will be used.

I understand that this is a more clever and safer variant of 'subject'. Do you want to say 100 characters or 100 bytes?

Documentation/git-format-patch.txt will want to ensure that threading is disabled for `git send-email`. · line 193

Quoted 2 lines
Documentation/git-format-patch.txt +2 -0
+If `<mode>` is `none`, both the cover letter subject and body will be
+populated with placeholder text.

OK, this is done for completeness? I wonder who finds it useful to set it to 'none' *AND* set the branch description. Not a rhetorical question that suggests removing this choice, but purely soliciting opinions from others.

It is unclear (other than the mode word being 'default' for one of the choices) what the new default mode of operation is after the patch is applied among the four presented mode. "This is the default when no configuration nor command line option specifies the desired mode" or something may want to be added to one of these paragraphs.

Quoted 20 lines
Documentation/git-format-patch.txt +5 -2
@@ -1061,13 +1076,16 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
 			      struct commit *origin,
 			      int nr, struct commit **list,
 			      const char *branch_name,
+			      enum cover_from_description cover_from_description_mode,
 			      int quiet)
 {
 	const char *committer;
-	const char *body = "*** SUBJECT HERE ***\n\n*** BLURB HERE ***\n";
-	const char *msg;
+	const char *subject = "*** SUBJECT HERE ***";
+	const char *body = "*** BLURB HERE ***";
 	struct shortlog log;
 	struct strbuf sb = STRBUF_INIT;
+	struct strbuf description_sb = STRBUF_INIT;
+	struct strbuf subject_sb = STRBUF_INIT;
 	int i;
 	const char *encoding = "UTF-8";
 	int need_8bit_cte = 0;

Documentation/git-format-patch.txt static void make_cover_letter(struct rev_info *rev, int use_stdout, · line 1117

Quoted 6 lines
Documentation/git-format-patch.txt +2 -1
@@ -1095,17 +1113,34 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
 	if (!branch_name)
 		branch_name = find_branch_name(rev);
 
-	msg = body;
+	if (branch_name && *branch_name)
+		read_branch_desc(&description_sb, branch_name);

It may not matter in practice but strictly speaking there is no need to read the description if we know that the mode is NONE. Removing the support for the NONE mode may be an easier fix than adding "&& mode != NONE" to the if () condition guarding this call---I dunno.

Documentation/git-format-patch.txt static void make_cover_letter(struct rev_info *rev, int use_stdout, · line 1129

Quoted 12 lines
Documentation/git-format-patch.txt +12 -0
+	if (cover_from_description_mode != COVER_FROM_NONE && description_sb.len) {
+		if (cover_from_description_mode == COVER_FROM_SUBJECT ||
+				cover_from_description_mode == COVER_FROM_AUTO)
+			body = format_subject(&subject_sb, description_sb.buf, " ");
+
+		if (cover_from_description_mode == COVER_FROM_MESSAGE ||
+				(cover_from_description_mode == COVER_FROM_AUTO &&
+				 subject_sb.len > COVER_FROM_AUTO_MAX_SUBJECT_LEN))
+			body = description_sb.buf;
+		else
+			subject = subject_sb.buf;
+	}

I wonder if it make the end result cleaner and easier to follow to replace all of the above with a single line:

	cover_from_desc(&subject, &body, branch_name, desc_mode);

in this caller, and move the logic (and a handful of strbuf used as its implementation detail) into the helper function, including the choice of the default "*** SOMETHING HERE ***", etc., and make the helper *always* return allocated piece of memory in subject and body so that this caller can unconditionally free them.

Thanks.

author
#82 lore raw

[PATCH v4 4/3] fixup! format-patch: teach --cover-from-description option

In reply to Denton Liu
---
 Documentation/git-format-patch.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/git-format-patch.txt +1 -1
index 86114e4c22..4c652c97f5 100644
@@ -368,7 +368,7 @@ with configuration variables.
 	signOff = true
 	outputDirectory = <directory>
 	coverLetter = auto
-	inferCoverSubject = true
+	coverFromDescription = auto
 ------------
 
 
Signature · 1 line
2.23.0.746.g72fc0fc0b9
#83 lore raw

Re: [PATCH v4 0/3] format-patch: learn --cover-from-description option

In reply to Denton Liu
Quoted 6 lines · Denton Liu

Changes since v3:

* Change --infer-cover-subject to --cover-from-description

* No more test cleanup patches (they were merged in 'dl/format-patch-doc-test-cleanup')

With these patches, t4013 and t9902 seem to break, when queued on top of dl/format-patch-doc-test-cleanup and also when merged to 'pu'.

Thanks.

author
#84 lore raw

v5 cover format-patch: learn --cover-from-description option

In reply to Denton Liu

Currently, format-patch only puts "*** SUBJECT HERE ***" when a cover letter is generated. However, it is already smart enough to be able to populate the cover letter with the branch description so there's no reason why it cannot populate the subject as well.

Teach format-patch the --cover-from-description option and corresponding format.coverFromDescription configuration option which will allow it to populate not only the body but the subject as well.

Changes since v4:

* Modify 1/3 to more closely reflect intent of the original author

* Incorporate Junio's suggestions into the documentation

* Extract branch desc logic into pp_from_desc()

* Fix broken tests

Changes since v3:

* Change --infer-cover-subject to --cover-from-description

* No more test cleanup patches (they were merged in 'dl/format-patch-doc-test-cleanup')

Changes since v2:

* Break 1/4 into many different patches (one per paragraph of the original patch)

* Incorporate Eric's documentation/commit message suggestions

Changes since v1:

* Incorporate Eric's suggestions for cleanup in all patches

* Add patch 3/4 to make it clear what is the default value for format.coverLetter (since format.inferCoverSubject was borrowed from this config but it also did not state what the default value was)

* In 1/4, rename all instances of "expected" to "expect"

Denton Liu (3):
format-patch: change erroneous and condition
format-patch: use enum variables
format-patch: teach --cover-from-description option

 Documentation/config/format.txt    |   6 +
 Documentation/git-format-patch.txt |  22 ++++
 builtin/log.c                      | 125 +++++++++++++++------
 t/t4014-format-patch.sh            | 172 +++++++++++++++++++++++++++++
 t/t9902-completion.sh              |   5 +-
 5 files changed, 296 insertions(+), 34 deletions(-)

Range-diff against v4:
1: 267bc00dc8 ! 1: 56fb230ad2 format-patch: remove erroneous and condition
@@ Metadata
Author: Denton Liu <[email protected]>

## Commit message ##
- format-patch: remove erroneous and condition
+ format-patch: change erroneous and condition

Commit 30984ed2e9 (format-patch: support deep threading, 2009-02-19), introduced the following lines:
@@ Commit message
thread = git_config_bool(var, value) && THREAD_SHALLOW;

Since git_config_bool() returns a bool, the trailing && THREAD_SHALLOW
- is a no-op. Remove this erroneous and condition.
+ is a no-op.
+
+ In Python, x and y is equivalent to y if x else x[1]. Since this
+ seems to be a Python-ism that's mistakenly leaked into our code, convert
+ this to the equivalent C expression.
+
+ [1]: https://docs.python.org/3/reference/expressions.html#boolean-operations

- Signed-off-by: Junio C Hamano <[email protected]>

## builtin/log.c ##
@@ builtin/log.c: static int git_format_config(const char *var, const char *value, void *cb)
@@ builtin/log.c: static int git_format_config(const char *var, const char *value,
return 0;
}
- thread = git_config_bool(var, value) && THREAD_SHALLOW;
-+ thread = git_config_bool(var, value);
++ thread = git_config_bool(var, value) ? THREAD_SHALLOW : THREAD_UNSET;
return 0;
}
if (!strcmp(var, "format.signoff")) {
2: 638a5b40d2 ! 2: e2769092fa format-patch: use enum variables
@@ Commit message
variables to use these new definitions.

- Signed-off-by: Junio C Hamano <[email protected]>

## builtin/log.c ##
@@ builtin/log.c: static void add_header(const char *value)
3: 3289ce62bb ! 3: 315c308950 format-patch: teach --cover-from-description option

    @@ Commit message
         populate different parts of the cover letter (including the subject
         now).
     
    -    Signed-off-by: Denton Liu <[email protected]>
    -    Signed-off-by: Junio C Hamano <[email protected]>
    -
      ## Documentation/config/format.txt ##
     @@ Documentation/config/format.txt: format.subjectPrefix::
      	The default for format-patch is to output files with the '[PATCH]'
    @@ Documentation/git-format-patch.txt: will want to ensure that threading is disabl
     ++
     +If `<mode>` is `message` or `default`, the cover letter subject will be
     +populated with placeholder text. The body of the cover letter will be
    -+populated with the branch's description.
    ++populated with the branch's description. This is the default mode when
    ++no configuration nor command line option is specified.
     ++
    -+If `<mode>` is `subject`, the beginning of the branch description (up to
    -+the first blank line) will populate the cover letter subject. The
    -+remainder of the description will populate the body of the cover
    -+letter.
    ++If `<mode>` is `subject`, the first paragraph of the branch description will
    ++populate the cover letter subject. The remainder of the description will
    ++populate the body of the cover letter.
     ++
    -+If `<mode>` is `auto`, if the beginning of the branch description (up to
    -+the first line) is greater than 100 characters then the mode will be
    -+`message`, otherwise `subject` will be used.
    ++If `<mode>` is `auto`, if the first paragraph of the branch description
    ++is greater than 100 bytes, then the mode will be `message`, otherwise
    ++`subject` will be used.
     ++
     +If `<mode>` is `none`, both the cover letter subject and body will be
     +populated with placeholder text.
    @@ builtin/log.c: static void print_signature(FILE *file)
      static char *find_branch_name(struct rev_info *rev)
      {
      	int i, positive = -1;
    -@@ builtin/log.c: static void make_cover_letter(struct rev_info *rev, int use_stdout,
    +@@ builtin/log.c: static void show_diffstat(struct rev_info *rev,
    + 	fprintf(rev->diffopt.file, "\n");
    + }
    + 
    ++static void pp_from_desc(struct pretty_print_context *pp,
    ++			 const char *branch_name,
    ++			 struct strbuf *sb,
    ++			 const char *encoding,
    ++			 int need_8bit_cte)
    ++{
    ++	const char *subject = "*** SUBJECT HERE ***";
    ++	const char *body = "*** BLURB HERE ***";
    ++	struct strbuf description_sb = STRBUF_INIT;
    ++	struct strbuf subject_sb = STRBUF_INIT;
    ++
    ++	if (cover_from_description_mode == COVER_FROM_NONE)
    ++		goto do_pp;
    ++
    ++	if (branch_name && *branch_name)
    ++		read_branch_desc(&description_sb, branch_name);
    ++	if (!description_sb.len)
    ++		goto do_pp;
    ++
    ++	if (cover_from_description_mode == COVER_FROM_SUBJECT ||
    ++			cover_from_description_mode == COVER_FROM_AUTO)
    ++		body = format_subject(&subject_sb, description_sb.buf, " ");
    ++
    ++	if (cover_from_description_mode == COVER_FROM_MESSAGE ||
    ++			(cover_from_description_mode == COVER_FROM_AUTO &&
    ++			 subject_sb.len > COVER_FROM_AUTO_MAX_SUBJECT_LEN))
    ++		body = description_sb.buf;
    ++	else
    ++		subject = subject_sb.buf;
    ++
    ++do_pp:
    ++	pp_title_line(pp, &subject, sb, encoding, need_8bit_cte);
    ++	pp_remainder(pp, &body, sb, 0);
    ++
    ++	strbuf_release(&description_sb);
    ++	strbuf_release(&subject_sb);
    ++}
    ++
    + static void make_cover_letter(struct rev_info *rev, int use_stdout,
      			      struct commit *origin,
      			      int nr, struct commit **list,
    - 			      const char *branch_name,
    -+			      enum cover_from_description cover_from_description_mode,
    +@@ builtin/log.c: static void make_cover_letter(struct rev_info *rev, int use_stdout,
      			      int quiet)
      {
      	const char *committer;
     -	const char *body = "*** SUBJECT HERE ***\n\n*** BLURB HERE ***\n";
     -	const char *msg;
    -+	const char *subject = "*** SUBJECT HERE ***";
    -+	const char *body = "*** BLURB HERE ***";
      	struct shortlog log;
      	struct strbuf sb = STRBUF_INIT;
    -+	struct strbuf description_sb = STRBUF_INIT;
    -+	struct strbuf subject_sb = STRBUF_INIT;
      	int i;
    - 	const char *encoding = "UTF-8";
    - 	int need_8bit_cte = 0;
     @@ builtin/log.c: static void make_cover_letter(struct rev_info *rev, int use_stdout,
      	if (!branch_name)
      		branch_name = find_branch_name(rev);
      
     -	msg = body;
    -+	if (branch_name && *branch_name)
    -+		read_branch_desc(&description_sb, branch_name);
    -+
    -+	if (cover_from_description_mode != COVER_FROM_NONE && description_sb.len) {
    -+		if (cover_from_description_mode == COVER_FROM_SUBJECT ||
    -+				cover_from_description_mode == COVER_FROM_AUTO)
    -+			body = format_subject(&subject_sb, description_sb.buf, " ");
    -+
    -+		if (cover_from_description_mode == COVER_FROM_MESSAGE ||
    -+				(cover_from_description_mode == COVER_FROM_AUTO &&
    -+				 subject_sb.len > COVER_FROM_AUTO_MAX_SUBJECT_LEN))
    -+			body = description_sb.buf;
    -+		else
    -+			subject = subject_sb.buf;
    -+	}
    -+
      	pp.fmt = CMIT_FMT_EMAIL;
      	pp.date_mode.type = DATE_RFC2822;
      	pp.rev = rev;
    @@ builtin/log.c: static void make_cover_letter(struct rev_info *rev, int use_stdou
     -	pp_title_line(&pp, &msg, &sb, encoding, need_8bit_cte);
     -	pp_remainder(&pp, &msg, &sb, 0);
     -	add_branch_description(&sb, branch_name);
    -+	pp_title_line(&pp, &subject, &sb, encoding, need_8bit_cte);
    -+	pp_remainder(&pp, &body, &sb, 0);
    -+	strbuf_addch(&sb, '\n');
    ++	pp_from_desc(&pp, branch_name, &sb, encoding, need_8bit_cte);
      	fprintf(rev->diffopt.file, "%s\n", sb.buf);
      
    -+	strbuf_release(&description_sb);
    -+	strbuf_release(&subject_sb);
      	strbuf_release(&sb);
    - 
    - 	shortlog_init(&log);
     @@ builtin/log.c: int cmd_format_patch(int argc, const char **argv, const char *prefix)
      	int use_patch_format = 0;
      	int quiet = 0;
    @@ builtin/log.c: int cmd_format_patch(int argc, const char **argv, const char *pre
      	if (0 < reroll_count) {
      		struct strbuf sprefix = STRBUF_INIT;
      		strbuf_addf(&sprefix, "%s v%d",
    -@@ builtin/log.c: int cmd_format_patch(int argc, const char **argv, const char *prefix)
    - 		if (thread)
    - 			gen_message_id(&rev, "cover");
    - 		make_cover_letter(&rev, use_stdout,
    --				  origin, nr, list, branch_name, quiet);
    -+				  origin, nr, list, branch_name, cover_from_description_mode, quiet);
    - 		print_bases(&bases, rev.diffopt.file);
    - 		print_signature(rev.diffopt.file);
    - 		total++;
     
      ## t/t4014-format-patch.sh ##
     @@ t/t4014-format-patch.sh: test_expect_success 'format patch ignores color.ui' '
    @@ t/t4014-format-patch.sh: test_expect_success 'format patch ignores color.ui' '
      test_expect_success 'cover letter using branch description (1)' '
      	git checkout rebuild-1 &&
      	test_config branch.rebuild-1.description hello &&
    +
    + ## t/t9902-completion.sh ##
    +@@ t/t9902-completion.sh: test_expect_success 'complete tree filename with metacharacters' '
    + '
    + 
    + test_expect_success PERL 'send-email' '
    +-	test_completion "git send-email --cov" "--cover-letter " &&
    ++	test_completion "git send-email --cov" <<-\EOF &&
    ++	--cover-from-description=Z
    ++	--cover-letter Z
    ++	EOF
    + 	test_completion "git send-email ma" "master "
    + '
    + 
Signature · 1 line
2.23.0.17.g315c308950
author
#85 lore raw

PATCH v5 1/3 format-patch: change erroneous and condition

Commit 30984ed2e9 (format-patch: support deep threading, 2009-02-19), introduced the following lines:

	#define THREAD_SHALLOW 1

	[...]

	thread = git_config_bool(var, value) && THREAD_SHALLOW;

Since git_config_bool() returns a bool, the trailing && THREAD_SHALLOW is a no-op.

In Python, x and y is equivalent to y if x else x[1]. Since this seems to be a Python-ism that's mistakenly leaked into our code, convert this to the equivalent C expression.

[1]: https://docs.python.org/3/reference/expressions.html#boolean-operations

---
 builtin/log.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
builtin/log.c +1 -1
index 44b10b3415..351f4ffcfd 100644
@@ -835,7 +835,7 @@ static int git_format_config(const char *var, const char *value, void *cb)
 			thread = THREAD_SHALLOW;
 			return 0;
 		}
-		thread = git_config_bool(var, value) && THREAD_SHALLOW;
+		thread = git_config_bool(var, value) ? THREAD_SHALLOW : THREAD_UNSET;
 		return 0;
 	}
 	if (!strcmp(var, "format.signoff")) {
Signature · 1 line
2.23.0.17.g315c308950
#86 lore raw

Re: [PATCH v5 1/3] format-patch: change erroneous and condition

Quoted 2 lines · Denton Liu

.... Since this
seems to be a Python-ism that's mistakenly leaked into our code, convert

The conclusion is OK, but as the inventor of format-patch and a non-pythonista, I do not think the above claim is correct, and even if Thomas thought it was a good idea to follow Python style in 30984ed2 ("format-patch: support deep threading", 2009-02-19), which I doubt he did, I do not think there is much point in speculating.

Both the log message and the patch text in the previous round were better than this round, I would have to say.

Thanks.

Quoted 13 lines
builtin/log.c +1 -1
index 44b10b3415..351f4ffcfd 100644
@@ -835,7 +835,7 @@ static int git_format_config(const char *var, const char *value, void *cb)
 			thread = THREAD_SHALLOW;
 			return 0;
 		}
-		thread = git_config_bool(var, value) && THREAD_SHALLOW;
+		thread = git_config_bool(var, value) ? THREAD_SHALLOW : THREAD_UNSET;
 		return 0;
 	}
 	if (!strcmp(var, "format.signoff")) {
author
#87 lore raw

Re: [PATCH v5 1/3] format-patch: change erroneous and condition

Hi Junio,

Thanks for the feedback.

Quoted 10 lines · Junio C Hamano
Quoted 2 lines · Denton Liu

.... Since this
seems to be a Python-ism that's mistakenly leaked into our code, convert

The conclusion is OK, but as the inventor of format-patch and a non-pythonista, I do not think the above claim is correct, and even if Thomas thought it was a good idea to follow Python style in 30984ed2 ("format-patch: support deep threading", 2009-02-19), which I doubt he did, I do not think there is much point in speculating.

I agree, I probably shouldn't be putting speculation in the log messages. I'll change this for the next reroll.

Quoted 3 lines

Both the log message and the patch text in the previous round were better than this round, I would have to say.

I'll probably keep the patch text, however. In the previous version, we were implicitly relying on the value of THREAD_SHALLOW to be 1. This seems a little bit flimsy to me since it's possible that the enum can be changed in the future and it may invalidate that assumption.

I'll keep it explicit so that it's a little bit more robust and also, so that it's more obvious to future readers what's going on.

Thanks,

Denton

Quoted 18 lines

Thanks.

Quoted 13 lines
builtin/log.c +1 -1
index 44b10b3415..351f4ffcfd 100644
@@ -835,7 +835,7 @@ static int git_format_config(const char *var, const char *value, void *cb)
 			thread = THREAD_SHALLOW;
 			return 0;
 		}
-		thread = git_config_bool(var, value) && THREAD_SHALLOW;
+		thread = git_config_bool(var, value) ? THREAD_SHALLOW : THREAD_UNSET;
 		return 0;
 	}
 	if (!strcmp(var, "format.signoff")) {
author
#88 lore raw

PATCH v5 2/3 format-patch: use enum variables

In reply to Denton Liu

Before, thread and config_cover_letter were defined as ints even though they behaved as enums. Define actual enums and change these variables to use these new definitions.

---
Hi Junio, I double-checked and made sure that there is no arithmetic done on the new enums.

 builtin/log.c | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)
builtin/log.c +17 -13
index 351f4ffcfd..d212a8305d 100644
@@ -764,24 +764,28 @@ static void add_header(const char *value)
 	item->string[len] = '\0';
 }
 
-#define THREAD_SHALLOW 1
-#define THREAD_DEEP 2
-static int thread;
+enum cover_setting {
+	COVER_UNSET,
+	COVER_OFF,
+	COVER_ON,
+	COVER_AUTO
+};
+
+enum thread_level {
+	THREAD_UNSET,
+	THREAD_SHALLOW,
+	THREAD_DEEP
+};
+
+static enum thread_level thread;
 static int do_signoff;
 static int base_auto;
 static char *from;
 static const char *signature = git_version_string;
 static const char *signature_file;
-static int config_cover_letter;
+static enum cover_setting config_cover_letter;
 static const char *config_output_directory;
 
-enum {
-	COVER_UNSET,
-	COVER_OFF,
-	COVER_ON,
-	COVER_AUTO
-};
-
 static int git_format_config(const char *var, const char *value, void *cb)
 {
 	struct rev_info *rev = cb;
@@ -1248,9 +1252,9 @@ static int output_directory_callback(const struct option *opt, const char *arg,
 
 static int thread_callback(const struct option *opt, const char *arg, int unset)
 {
-	int *thread = (int *)opt->value;
+	enum thread_level *thread = (enum thread_level *)opt->value;
 	if (unset)
-		*thread = 0;
+		*thread = THREAD_UNSET;
 	else if (!arg || !strcmp(arg, "shallow"))
 		*thread = THREAD_SHALLOW;
 	else if (!strcmp(arg, "deep"))
Signature · 1 line
2.23.0.17.g315c308950
author
#89 lore raw

PATCH v5 3/3 format-patch: teach --cover-from-description option

In reply to Denton Liu

Before, when format-patch generated a cover letter, only the body would be populated with a branch's description while the subject would be populated with placeholder text. However, users may want to have the subject of their cover letter automatically populated in the same way.

Teach format-patch to accept the --cover-from-description option and corresponding format.coverFromDescription config, allowing users to populate different parts of the cover letter (including the subject now).

---
 Documentation/config/format.txt    |   6 +
 Documentation/git-format-patch.txt |  22 ++++
 builtin/log.c                      |  95 ++++++++++++----
 t/t4014-format-patch.sh            | 172 +++++++++++++++++++++++++++++
 t/t9902-completion.sh              |   5 +-
 5 files changed, 279 insertions(+), 21 deletions(-)
Documentation/config/format.txt +6 -0
index cb629fa769..735dfcf827 100644
@@ -36,6 +36,12 @@ format.subjectPrefix::
 	The default for format-patch is to output files with the '[PATCH]'
 	subject prefix. Use this variable to change that prefix.
 
+format.coverFromDescription::
+	The default mode for format-patch to determine which parts of
+	the cover letter will be populated using the branch's
+	description. See the `--cover-from-description` option in
+	linkgit:git-format-patch[1].
+
 format.signature::
 	The default for format-patch is to output a signature containing
 	the Git version number. Use this variable to change that default.
Documentation/git-format-patch.txt +22 -0
index 0ac56f4b70..6800e1ab9a 100644
@@ -19,6 +19,7 @@ SYNOPSIS
 		   [--start-number <n>] [--numbered-files]
 		   [--in-reply-to=<message id>] [--suffix=.<sfx>]
 		   [--ignore-if-in-upstream]
+		   [--cover-from-description=<mode>]
 		   [--rfc] [--subject-prefix=<subject prefix>]
 		   [(--reroll-count|-v) <n>]
 		   [--to=<email>] [--cc=<email>]
@@ -171,6 +172,26 @@ will want to ensure that threading is disabled for `git send-email`.
 	patches being generated, and any patch that matches is
 	ignored.
 
+--cover-from-description=<mode>::
+	Controls which parts of the cover letter will be automatically
+	populated using the branch's description.
++
+If `<mode>` is `message` or `default`, the cover letter subject will be
+populated with placeholder text. The body of the cover letter will be
+populated with the branch's description. This is the default mode when
+no configuration nor command line option is specified.
++
+If `<mode>` is `subject`, the first paragraph of the branch description will
+populate the cover letter subject. The remainder of the description will
+populate the body of the cover letter.
++
+If `<mode>` is `auto`, if the first paragraph of the branch description
+is greater than 100 bytes, then the mode will be `message`, otherwise
+`subject` will be used.
++
+If `<mode>` is `none`, both the cover letter subject and body will be
+populated with placeholder text.
+
 --subject-prefix=<subject prefix>::
 	Instead of the standard '[PATCH]' prefix in the subject
 	line, instead use '[<subject prefix>]'. This
@@ -347,6 +368,7 @@ with configuration variables.
 	signOff = true
 	outputDirectory = <directory>
 	coverLetter = auto
+	coverFromDescription = auto
 ------------
 
 
builtin/log.c +75 -20

166 lines not on this page · raw message

t/t4014-format-patch.sh +172 -0

178 lines not on this page · raw message

t/t9902-completion.sh +4 -1
index 75512c3403..5187e2ede5 100755
@@ -1548,7 +1548,10 @@ test_expect_success 'complete tree filename with metacharacters' '
 '
 
 test_expect_success PERL 'send-email' '
-	test_completion "git send-email --cov" "--cover-letter " &&
+	test_completion "git send-email --cov" <<-\EOF &&
+	--cover-from-description=Z
+	--cover-letter Z
+	EOF
 	test_completion "git send-email ma" "master "
 '
 
Signature · 1 line
2.23.0.17.g315c308950
#90 lore raw

Re: [PATCH v5 3/3] format-patch: teach --cover-from-description option

Quoted 36 lines · Denton Liu
builtin/log.c +28 -0
index d212a8305d..af33fe9ffb 100644
@@ -1057,6 +1072,44 @@ static void show_diffstat(struct rev_info *rev,
 	fprintf(rev->diffopt.file, "\n");
 }
 
+static void pp_from_desc(struct pretty_print_context *pp,
+			 const char *branch_name,
+			 struct strbuf *sb,
+			 const char *encoding,
+			 int need_8bit_cte)
+{
+	const char *subject = "*** SUBJECT HERE ***";
+	const char *body = "*** BLURB HERE ***";
+	struct strbuf description_sb = STRBUF_INIT;
+	struct strbuf subject_sb = STRBUF_INIT;
+
+	if (cover_from_description_mode == COVER_FROM_NONE)
+		goto do_pp;
+
+	if (branch_name && *branch_name)
+		read_branch_desc(&description_sb, branch_name);
+	if (!description_sb.len)
+		goto do_pp;
+
+	if (cover_from_description_mode == COVER_FROM_SUBJECT ||
+			cover_from_description_mode == COVER_FROM_AUTO)
+		body = format_subject(&subject_sb, description_sb.buf, " ");
+
+	if (cover_from_description_mode == COVER_FROM_MESSAGE ||
+			(cover_from_description_mode == COVER_FROM_AUTO &&
+			 subject_sb.len > COVER_FROM_AUTO_MAX_SUBJECT_LEN))
+		body = description_sb.buf;
+	else

builtin/log.c static void show_diffstat(struct rev_info *rev, · line 1112

Quoted 10 lines
builtin/log.c +10 -0
+		subject = subject_sb.buf;
+
+do_pp:
+	pp_title_line(pp, &subject, sb, encoding, need_8bit_cte);
+	pp_remainder(pp, &body, sb, 0);
+
+	strbuf_release(&description_sb);
+	strbuf_release(&subject_sb);
+}
+

This implementation is very clear and easy to follow, and ...

Quoted 10 lines
builtin/log.c +0 -0
@@ -1064,8 +1117,6 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
 			      int quiet)
 {
 	const char *committer;
 	struct shortlog log;
 	struct strbuf sb = STRBUF_INIT;
 	int i;
@@ -1095,15 +1146,12 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
 	if (!branch_name)
 		branch_name = find_branch_name(rev);

builtin/log.c static void make_cover_letter(struct rev_info *rev, int use_stdout, · line 1157

Quoted 10 lines
builtin/log.c +1 -0
 
 	pp.fmt = CMIT_FMT_EMAIL;
 	pp.date_mode.type = DATE_RFC2822;
 	pp.rev = rev;
 	pp.print_email_subject = 1;
 	pp_user_info(&pp, NULL, &sb, committer, encoding);
+	pp_from_desc(&pp, branch_name, &sb, encoding, need_8bit_cte);
 	fprintf(rev->diffopt.file, "%s\n", sb.buf);
 
 	strbuf_release(&sb);

... made the caller much simpler.

One large nit is that pp_user_info() is about "pretty printing the user info", pp_title_line() is about "pretty printing the title line", but pp_from_desc() is not about "pretty printing the from desc". Naming matters.

How about calling it with more emphasis on what it does (i.e. the helper is about preparing the subject and body of the cover letter e-mail) and less emphasis on how it does or what it bases its decision on? prepare_cover_text() or soemthing, perhaps?

Other than that, this version is very much more preferrable than the previous one. Quite nicely done.

Thanks.