format-patch: teach --infer-cover-subject option
cover format-patch: teach --infer-cover-subject option
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].
[1]: https://public-inbox.org/git/[email protected]/
Denton Liu (3):
t4014: clean up style
Doc: add more detail for git-format-patch
format-patch: infer cover letter from branch description
Documentation/config/format.txt | 5 + Documentation/git-format-patch.txt | 35 +- builtin/log.c | 56 ++- t/t4014-format-patch.sh | 656 ++++++++++++++++------------- 4 files changed, 425 insertions(+), 327 deletions(-)
Signature · 1 line
2.23.0.248.g3a9dd8fb08
PATCH 1/3 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.
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.
--- t/t4014-format-patch.sh | 623 +++++++++++++++++++++------------------- 1 file changed, 326 insertions(+), 297 deletions(-)
t/t4014-format-patch.sh +326 -297
@@ -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" &&
@@ -96,7 +97,7 @@ 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 '
@@ -104,21 +105,22 @@ 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 +133,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 +144,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 +156,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 +166,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 +175,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 +263,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 +316,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 +370,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 '
@@ -372,12 +385,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 --- --- ---
@@ -388,7 +401,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 +418,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 +438,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 +459,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 +491,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 +509,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 +532,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 +556,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 +638,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 +651,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 +678,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 +694,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 +749,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,20 +840,20 @@ 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)' test_expect_success 'format-patch -- <path>' '
@@ -852,20 +865,22 @@ 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() { 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 '
@@ -1256,282 +1271,282 @@ 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 + 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 ' 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 + cat >expected <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 9:Signed-off-by: C O Mitter <[email protected]> + EOF test_cmp expected 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 + cat >expected <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 9:Signed-off-by: C O Mitter <[email protected]> + EOF test_cmp expected 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 + 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 ' 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 + cat >expected <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 10: + 11:Signed-off-by: C O Mitter <[email protected]> + EOF test_cmp expected 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 + 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 ' 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 + 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 ' 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 + 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 ' 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 + 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 ' 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 + 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 ' 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 + 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 ' 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 + 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 ' 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 + cat >expected <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 9:Signed-off-by: C O Mitter <[email protected]> + EOF test_cmp expected 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 + 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 ' 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 + 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 ' 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 + 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 && 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 + 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 ' 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 + 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 '
@@ -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,19 +1665,32 @@ 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 >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 && + 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 && + 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 && 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 "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 && ! test_cmp fail actual1 && ! test_cmp fail actual2
Signature · 1 line
2.23.0.248.g3a9dd8fb08
Re: [PATCH 1/3] t4014: clean up style
t/t4014-format-patch.sh test_expect_success "format-patch doesn't consider merge commits" ' · line 99
Quoted 6 lines · Denton Liu
t/t4014-format-patch.sh +1
-1@@ -96,7 +97,7 @@ test_expect_success "format-patch doesn't consider merge commits" ' 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
Just below here, you update tests to use test_line_count(). Why not do the same here?
Quoted 19 lines
t/t4014-format-patch.sh +3
-3@@ -104,21 +105,22 @@ 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 '@@ -357,7 +370,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 '
t/t4014-format-patch.sh check_threading () { · line 391
Quoted 8 lines
t/t4014-format-patch.sh +1
-1@@ -372,12 +385,12 @@ check_threading () { print; } print "---\n" if /^From /i; - ' > actual && + ' >actual && test 0 = "$(cat status.out)" && test_cmp "$expect" actual }
Not a new issue, but this is more difficult to reason about than it could be due to the manual squirreling away of the status code of the Git command which is upstream of the pipe. More straightforward would be:
...
shift &&
git format-patch --stdout "$@" >patch &&
perl -ne '...' <patch >actual &&
test_cmp "$expect" actualNo need for capturing or manually checking format-patch's exit code since the &&-chain handles it for you. And, you no longer have a Git command upstream of a pipe.
t/t4014-format-patch.sh test_expect_success 'format-patch --ignore-if-in-upstream HEAD' ' · line 865
Quoted 3 lines
t/t4014-format-patch.sh +1
-1@@ -852,20 +865,22 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' ' -git_version="$(git --version | sed "s/.* //")" +git_version="$(git --version >version && sed "s/.* //" version)"
Meh. The exit code is being ignored anyhow since this is not part of a &&-chain.
Quoted 6 lines
t/t4014-format-patch.sh +0
-1@@ -1649,19 +1665,32 @@ test_expect_success 'format-patch -o overrides format.outputDirectory' ' test_expect_success 'format-patch --base' ' 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 &&
t/t4014-format-patch.sh test_expect_success 'format-patch -o overrides format.outputDirectory' ' · line 1681
Quoted 10 lines
t/t4014-format-patch.sh +8
-2- echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expected && - signature >> expected && + 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 && + 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 &&
Not a big deal, but you could take advantage of the fact that you're already invoking 'awk', thus avoid the 'echo':
awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >patch.id &&Quoted 4 lines
t/t4014-format-patch.sh +1
-0+ signature >>expected && test_cmp expected actual1 && test_cmp expected actual2 && echo >fail &&
t/t4014-format-patch.sh test_expect_success 'format-patch -o overrides format.outputDirectory' ' · line 1693
Quoted 10 lines
t/t4014-format-patch.sh +7
-2echo "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 &&
Hmph, why is this case transformed in a different way than the case immediately above.
PATCH 2/3 Doc: add more detail for git-format-patch
In reply to Denton LiuIn 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 camelcase.
--- Documentation/git-format-patch.txt | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)
Documentation/git-format-patch.txt +16 -9
@@ -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.
@@ -193,13 +193,17 @@ 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).
@@ -314,7 +318,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 equal to "auto", a base commit + is automatically chosen. --root:: Treat the revision argument as a <revision range>, even if it
@@ -330,8 +335,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 +349,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
Re: [PATCH 2/3] Doc: add more detail for git-format-patch
Quoted 11 lines · Denton Liu
In git-format-patch.txt, we were missing some key user information. First of all, using the
--toand--ccoptions don't overrideformat.toandformat.ccvariables, 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.outputDirectoryconfig and changeformat.coverletterto use camelcase.
I can't figure out if you typeset "camelcase" like that intentionally, as opposed to "camelCase" or "camel case" or "camel-case".
Documentation/git-format-patch.txt will want to ensure that threading is disabled for `git send-email`. · line 198
Quoted 9 lines
Signed-off-by Denton Liu <[email protected]>---
Documentation/git-format-patch.txt +3
-1--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.
Hmph. This seems redundant. The description already says "This is in addition to...", so a new sentence saying "...used along with..." is just parroting what was already stated.
Documentation/git-format-patch.txt you can use `--suffix=-patch` to get `0001-description-of-my-change-patch`. · line 322
Quoted 9 lines
The negated form
--no-todiscards allTo:headers added so far (from config or command line).Documentation/git-format-patch.txt +2
-1@@ -314,7 +318,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 equal to "auto", a base commit + is automatically chosen.
"is equal to" is unnecessarily technical-sounding. How about:
If <commit> is "auto", ...
Re: [PATCH 2/3] Doc: add more detail for git-format-patch
Quoted 8 lines · Eric Sunshine
Quoted 7 lines · Denton Liu
In git-format-patch.txt, we were missing some key user information. First of all, using the
--toand--ccoptions don't overrideformat.toandformat.ccvariables, respectively. They add on to each other. Document this.In addition, document the special value of
--base=auto.
Quoted 7 lines
Quoted 4 lines
Next, while we're at it, surround option arguments with <>.
Finally, document the
format.outputDirectoryconfig and changeformat.coverletterto use camelcase.I can't figure out if you typeset "camelcase" like that intentionally, as opposed to "camelCase" or "camel case" or "camel-case".
I thought that was how it's spelled but a quick Google search proves me wrong.
Quoted 28 lines
Documentation/git-format-patch.txt will want to ensure that threading is disabled for `git send-email`. · line 198
Quoted 10 lines
Signed-off-by Denton Liu <[email protected]>---
Documentation/git-format-patch.txt +3
-1--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.Hmph. This seems redundant. The description already says "This is in addition to...", so a new sentence saying "...used along with..." is just parroting what was already stated.
Documentation/git-format-patch.txt you can use `--suffix=-patch` to get `0001-description-of-my-change-patch`. · line 322
Quoted 9 lines
The negated form
--no-todiscards allTo:headers added so far (from config or command line).Documentation/git-format-patch.txt +2
-1@@ -314,7 +318,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 equal to "auto", a base commit + is automatically chosen."is equal to" is unnecessarily technical-sounding. How about:
If <commit> is "auto", ...
Re: [PATCH 2/3] Doc: add more detail for git-format-patch
In reply to Denton LiuDocumentation/git-format-patch.txt SYNOPSIS
Quoted 11 lines · Denton Liu
Next, while we're at it, surround option arguments with <>.
...Documentation/git-format-patch.txt +3
-3[--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>] ---in-reply-to=Message-Id:: +--in-reply-to=<Message-Id>::
That is a good change, but if we are making this change while are at it, I think we should fix it to read <message id>. "Message-Id" is a good spelling iff we are talking about the label on the left hand side of colon in e-mail header, but in this context, we are talking about the value to be placed on that header.
All the other multi-word placeholders in the SYNOPSIS section spell the words as normal multiple words separated with whitespace in lower case. You'd also want to fix the spelling of Subject-Prefix to <subject prefix> for consistency.
Thanks.
PATCH 3/3 format-patch: infer cover letter from branch description
In reply to Denton LiuWe 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 | 5 +++ Documentation/git-format-patch.txt | 10 ++++++ builtin/log.c | 56 +++++++++++++++++++----------- t/t4014-format-patch.sh | 33 ++++++++++++++++++ 4 files changed, 83 insertions(+), 21 deletions(-)
Documentation/config/format.txt +5 -0
@@ -36,6 +36,11 @@ 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 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]. + 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
@@ -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
@@ -351,6 +360,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
@@ -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
Re: [PATCH 3/3] format-patch: infer cover letter from branch description
Quoted 14 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-letterorformat.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.Signed-off-by Denton Liu <[email protected]>---
Documentation/config/format.txt format.subjectPrefix:: · line 39
Quoted 4 lines
Documentation/config/format.txt +4
-0@@ -36,6 +36,11 @@ format.subjectPrefix:: +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].
What is the default value?