From: Denton Liu <hidden> Date: 2019-08-19 23:52:52
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.
Signed-off-by: Denton Liu <redacted>
---
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(-)
@@ -34,7 +34,8 @@ test_expect_success setup 'gitcommit-m"Side changes #3 with \\n backslash-n in it."&&gitcheckoutmaster&&-gitdiff-tree-pC2|gitapply--index&&+gitdiff-tree-pC2>patch&&+gitapply--index<patch&&test_tick&&gitcommit-m"Master accepts moral equivalent of #2"&&
@@ -96,29 +95,31 @@ test_expect_success "format-patch doesn't consider merge commits" 'gitcheckout-bmergermaster&&test_tick&&gitmerge--no-ffslave&&-cnt=$(gitformat-patch-3--stdout|grep"^From "|wc-l)&&-test$cnt=3+gitformat-patch-3--stdout>patch&&+grep"^From "patch>from&&+test_line_count=3from' test_expect_success"format-patch result applies"'gitcheckout-brebuild-0master&&gitam-3patch0&&-cnt=$(gitrev-listmaster..|wc-l)&&-test$cnt=2+gitrev-listmaster..>list&&+test_line_count=2list' test_expect_success"format-patch --ignore-if-in-upstream result applies"'gitcheckout-brebuild-1master&&gitam-3patch1&&-cnt=$(gitrev-listmaster..|wc-l)&&-test$cnt=2+gitrev-listmaster..>list&&+test_line_count=2list' test_expect_success'commit did not screw up the log message''-gitcat-filecommitside|grep"^Side .* with .* backslash-n"+gitcat-filecommitside>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''-gitcat-filecommitrebuild-1|grep"^Side .* with .* backslash-n"+gitcat-filecommitrebuild-1>actual&&+grep"^Side .* with .* backslash-n"actual'
@@ -141,8 +143,8 @@ test_expect_success 'extra headers' '" &&gitconfig--addformat.headers"Cc: S E Cipient <scipient@example.com>" &&-gitformat-patch--stdoutmaster..side>patch2&&-sed-e"/^\$/q"patch2>hdrs2&&+gitformat-patch--stdoutmaster..side>patch2&&+sed-e"/^\$/q"patch2>hdrs2&&grep"^To: R E Cipient <rcipient@example.com>\$"hdrs2&&grep"^Cc: S E Cipient <scipient@example.com>\$"hdrs2
@@ -153,7 +155,7 @@ test_expect_success 'extra headers without newlines' 'gitconfig--replace-allformat.headers"To: R E Cipient <rcipient@example.com>"&&gitconfig--addformat.headers"Cc: S E Cipient <scipient@example.com>"&&gitformat-patch--stdoutmaster..side>patch3&&-sed-e"/^\$/q"patch3>hdrs3&&+sed-e"/^\$/q"patch3>hdrs3&&grep"^To: R E Cipient <rcipient@example.com>\$"hdrs3&&grep"^Cc: S E Cipient <scipient@example.com>\$"hdrs3
@@ -163,8 +165,8 @@ test_expect_success 'extra headers with multiple To:s' 'gitconfig--replace-allformat.headers"To: R E Cipient <rcipient@example.com>"&&gitconfig--addformat.headers"To: S E Cipient <scipient@example.com>"&&-gitformat-patch--stdoutmaster..side>patch4&&-sed-e"/^\$/q"patch4>hdrs4&&+gitformat-patch--stdoutmaster..side>patch4&&+sed-e"/^\$/q"patch4>hdrs4&&grep"^To: R E Cipient <rcipient@example.com>,\$"hdrs4&&grep"^ *S E Cipient <scipient@example.com>\$"hdrs4'
@@ -172,72 +174,82 @@ test_expect_success 'extra headers with multiple To:s' ' test_expect_success'additional command line cc (ascii)''gitconfig--replace-allformat.headers"Cc: R E Cipient <rcipient@example.com>"&&-gitformat-patch--cc="S E Cipient <scipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch5&&-grep"^Cc: R E Cipient <rcipient@example.com>,\$"patch5&&-grep"^ *S E Cipient <scipient@example.com>\$"patch5+gitformat-patch--cc="S E Cipient <scipient@example.com>"--stdoutmaster..side>patch5&&+sed-e"/^\$/q"patch5>hdrs5&&+grep"^Cc: R E Cipient <rcipient@example.com>,\$"hdrs5&&+grep"^ *S E Cipient <scipient@example.com>\$"hdrs5' test_expect_failure'additional command line cc (rfc822)''gitconfig--replace-allformat.headers"Cc: R E Cipient <rcipient@example.com>"&&-gitformat-patch--cc="S. E. Cipient <scipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch5&&-grep"^Cc: R E Cipient <rcipient@example.com>,\$"patch5&&-grep"^ *\"S. E. Cipient\" <scipient@example.com>\$"patch5+gitformat-patch--cc="S. E. Cipient <scipient@example.com>"--stdoutmaster..side>patch5&&+sed-e"/^\$/q"patch5>hdrs5&&+grep"^Cc: R E Cipient <rcipient@example.com>,\$"hdrs5&&+grep"^ *\"S. E. Cipient\" <scipient@example.com>\$"hdrs5' test_expect_success'command line headers''gitconfig--unset-allformat.headers&&-gitformat-patch--add-header="Cc: R E Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch6&&-grep"^Cc: R E Cipient <rcipient@example.com>\$"patch6+gitformat-patch--add-header="Cc: R E Cipient <rcipient@example.com>"--stdoutmaster..side>patch6&&+sed-e"/^\$/q"patch6>hdrs6&&+grep"^Cc: R E Cipient <rcipient@example.com>\$"hdrs6' test_expect_success'configuration headers and command line headers''gitconfig--replace-allformat.headers"Cc: R E Cipient <rcipient@example.com>"&&-gitformat-patch--add-header="Cc: S E Cipient <scipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch7&&-grep"^Cc: R E Cipient <rcipient@example.com>,\$"patch7&&-grep"^ *S E Cipient <scipient@example.com>\$"patch7+gitformat-patch--add-header="Cc: S E Cipient <scipient@example.com>"--stdoutmaster..side>patch7&&+sed-e"/^\$/q"patch7>hdrs7&&+grep"^Cc: R E Cipient <rcipient@example.com>,\$"hdrs7&&+grep"^ *S E Cipient <scipient@example.com>\$"hdrs7' test_expect_success'command line To: header (ascii)''gitconfig--unset-allformat.headers&&-gitformat-patch--to="R E Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch8&&-grep"^To: R E Cipient <rcipient@example.com>\$"patch8+gitformat-patch--to="R E Cipient <rcipient@example.com>"--stdoutmaster..side>patch8&&+sed-e"/^\$/q"patch8>hdrs8&&+grep"^To: R E Cipient <rcipient@example.com>\$"hdrs8' test_expect_failure'command line To: header (rfc822)''-gitformat-patch--to="R. E. Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch8&&-grep"^To: \"R. E. Cipient\" <rcipient@example.com>\$"patch8+gitformat-patch--to="R. E. Cipient <rcipient@example.com>"--stdoutmaster..side>patch8&&+sed-e"/^\$/q"patch8>hdrs8&&+grep"^To: \"R. E. Cipient\" <rcipient@example.com>\$"hdrs8' test_expect_failure'command line To: header (rfc2047)''-gitformat-patch--to="R Ä Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch8&&-grep"^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$"patch8+gitformat-patch--to="R Ä Cipient <rcipient@example.com>"--stdoutmaster..side>patch8&&+sed-e"/^\$/q"patch8>hdrs8&&+grep"^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$"hdrs8' test_expect_success'configuration To: header (ascii)''gitconfigformat.to"R E Cipient <rcipient@example.com>"&&-gitformat-patch--stdoutmaster..side|sed-e"/^\$/q">patch9&&-grep"^To: R E Cipient <rcipient@example.com>\$"patch9+gitformat-patch--stdoutmaster..side>patch9&&+sed-e"/^\$/q"patch9>hdrs9&&+grep"^To: R E Cipient <rcipient@example.com>\$"hdrs9' test_expect_failure'configuration To: header (rfc822)''gitconfigformat.to"R. E. Cipient <rcipient@example.com>"&&-gitformat-patch--stdoutmaster..side|sed-e"/^\$/q">patch9&&-grep"^To: \"R. E. Cipient\" <rcipient@example.com>\$"patch9+gitformat-patch--stdoutmaster..side>patch9&&+sed-e"/^\$/q"patch9>hdrs9&&+grep"^To: \"R. E. Cipient\" <rcipient@example.com>\$"hdrs9' test_expect_failure'configuration To: header (rfc2047)''gitconfigformat.to"R Ä Cipient <rcipient@example.com>"&&-gitformat-patch--stdoutmaster..side|sed-e"/^\$/q">patch9&&-grep"^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$"patch9+gitformat-patch--stdoutmaster..side>patch9&&+sed-e"/^\$/q"patch9>hdrs9&&+grep"^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$"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-cformat.from=falseformat-patch--stdoutmaster..side|-sed-e"/^\$/q">patch&&+git-cformat.from=falseformat-patch--stdoutmaster..side>patch&&+sed-e"/^\$/q"patch>hdrs&&check_patchpatch&&-!grep"^From: C O Mitter <committer@example.com>\$"patch+!grep"^From: C O Mitter <committer@example.com>\$"hdrs' test_expect_success'format.from=true''-git-cformat.from=trueformat-patch--stdoutmaster..side|-sed-e"/^\$/q">patch&&-check_patchpatch&&-grep"^From: C O Mitter <committer@example.com>\$"patch+git-cformat.from=trueformat-patch--stdoutmaster..side>patch&&+sed-e"/^\$/q"patch>hdrs&&+check_patchhdrs&&+grep"^From: C O Mitter <committer@example.com>\$"hdrs' test_expect_success'format.from with address''-git-cformat.from="F R Om <from@example.com>"format-patch--stdoutmaster..side|-sed-e"/^\$/q">patch&&-check_patchpatch&&-grep"^From: F R Om <from@example.com>\$"patch+git-cformat.from="F R Om <from@example.com>"format-patch--stdoutmaster..side>patch&&+sed-e"/^\$/q"patch>hdrs&&+check_patchhdrs&&+grep"^From: F R Om <from@example.com>\$"hdrs' test_expect_success'--no-from overrides format.from''-git-cformat.from="F R Om <from@example.com>"format-patch--no-from--stdoutmaster..side|-sed-e"/^\$/q">patch&&-check_patchpatch&&-!grep"^From: F R Om <from@example.com>\$"patch+git-cformat.from="F R Om <from@example.com>"format-patch--no-from--stdoutmaster..side>patch&&+sed-e"/^\$/q"patch>hdrs&&+check_patchhdrs&&+!grep"^From: F R Om <from@example.com>\$"hdrs' test_expect_success'--from overrides format.from''-git-cformat.from="F R Om <from@example.com>"format-patch--from--stdoutmaster..side|-sed-e"/^\$/q">patch&&-check_patchpatch&&-!grep"^From: F R Om <from@example.com>\$"patch+git-cformat.from="F R Om <from@example.com>"format-patch--from--stdoutmaster..side>patch&&+sed-e"/^\$/q"patch>hdrs&&+check_patchhdrs&&+!grep"^From: F R Om <from@example.com>\$"hdrs' test_expect_success'--no-to overrides config.to''gitconfig--replace-allformat.to\"R E Cipient <rcipient@example.com>"&&-gitformat-patch--no-to--stdoutmaster..side|-sed-e"/^\$/q">patch10&&-check_patchpatch10&&-!grep"^To: R E Cipient <rcipient@example.com>\$"patch10+gitformat-patch--no-to--stdoutmaster..side>patch10&&+sed-e"/^\$/q"patch10>hdrs10&&+check_patchhdrs10&&+!grep"^To: R E Cipient <rcipient@example.com>\$"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' 'gitconfig--replace-allformat.to\"Someone <someone@out.there>"&&gitformat-patch--no-to--to="Someone Else <else@out.there>"\---stdoutmaster..side|-sed-e"/^\$/q">patch11&&-check_patchpatch11&&-!grep"^To: Someone <someone@out.there>\$"patch11&&-grep"^To: Someone Else <else@out.there>\$"patch11+--stdoutmaster..side>patch11&&+sed-e"/^\$/q"patch11>hdrs11&&+check_patchhdrs11&&+!grep"^To: Someone <someone@out.there>\$"hdrs11&&+grep"^To: Someone Else <else@out.there>\$"hdrs11' test_expect_success'--no-cc overrides config.cc''gitconfig--replace-allformat.cc\"C E Cipient <rcipient@example.com>"&&-gitformat-patch--no-cc--stdoutmaster..side|-sed-e"/^\$/q">patch12&&-check_patchpatch12&&-!grep"^Cc: C E Cipient <rcipient@example.com>\$"patch12+gitformat-patch--no-cc--stdoutmaster..side>patch12&&+sed-e"/^\$/q"patch12>hdrs12&&+check_patchhdrs12&&+!grep"^Cc: C E Cipient <rcipient@example.com>\$"hdrs12' test_expect_success'--no-add-header overrides config.headers''gitconfig--replace-allformat.headers\"Header1: B E Cipient <rcipient@example.com>"&&-gitformat-patch--no-add-header--stdoutmaster..side|-sed-e"/^\$/q">patch13&&-check_patchpatch13&&-!grep"^Header1: B E Cipient <rcipient@example.com>\$"patch13+gitformat-patch--no-add-header--stdoutmaster..side>patch13&&+sed-e"/^\$/q"patch13>hdrs13&&+check_patchhdrs13&&+!grep"^Header1: B E Cipient <rcipient@example.com>\$"hdrs13' test_expect_success'multiple files''
@@ -357,7 +369,7 @@ test_expect_success 'reroll count (-v)' ' check_threading(){expect="$1"&&shift&&-(gitformat-patch--stdout"$@";echo$?>status.out)|+gitformat-patch--stdout"$@">patch&&# Prints everything between the Message-ID and In-Reply-To,# and replaces all Message-ID-lookalikes by a sequence numberperl-ne'
@@ -736,7 +747,7 @@ test_expect_success 'format-patch from a subdirectory (3)' '' test_expect_success'format-patch --in-reply-to''-gitformat-patch-1--stdout--in-reply-to"baz@foo.bar">patch8&&+gitformat-patch-1--stdout--in-reply-to"baz@foo.bar">patch8&&grep"^In-Reply-To: <baz@foo.bar>"patch8&&grep"^References: <baz@foo.bar>"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_failgitformat-patch--name-only2>output&&+test_must_failgitformat-patch--name-only2>output&&test_i18ncmpexpect.name-onlyoutput&&-test_must_failgitformat-patch--name-status2>output&&+test_must_failgitformat-patch--name-status2>output&&test_i18ncmpexpect.name-statusoutput&&-test_must_failgitformat-patch--check2>output&&-test_i18ncmpexpect.checkoutput'+test_must_failgitformat-patch--check2>output&&+test_i18ncmpexpect.checkoutput+' test_expect_success'format-patch --numstat should produce a patch''-gitformat-patch--numstat--stdoutmaster..side>output&&-test5=$(grep"^diff --git a/"output|wc-l)'+gitformat-patch--numstat--stdoutmaster..side>output&&+grep"^diff --git a/"output>diff&&+test_line_count=5diff+' test_expect_success'format-patch -- <path>''gitformat-patchmaster..side--file2>error&&
@@ -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:COMitter<committer@example.com>-EOF-test_cmpexpectedactual+cat<<-\EOF | sed "s/EOL$//" >expect &&+4:Subject:[PATCH]EOL+8:+9:Signed-off-by:COMitter<committer@example.com>+EOF+test_cmpexpectactual' test_expect_success'signoff: commit with only subject''echosubject|append_signoff>actual&&-cat>expected<<\EOF&&-4:Subject:[PATCH]subject-8:-9:Signed-off-by:COMitter<committer@example.com>-EOF-test_cmpexpectedactual+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+9:Signed-off-by:COMitter<committer@example.com>+EOF+test_cmpexpectactual' test_expect_success'signoff: commit with only subject that does not end with NL''printfsubject|append_signoff>actual&&-cat>expected<<\EOF&&-4:Subject:[PATCH]subject-8:-9:Signed-off-by:COMitter<committer@example.com>-EOF-test_cmpexpectedactual+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+9:Signed-off-by:COMitter<committer@example.com>+EOF+test_cmpexpectactual' 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:COMitter<committer@example.com>-EOF-test_cmpexpectedactual+body+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+11:Signed-off-by:COMitter<committer@example.com>+EOF+test_cmpexpectactual' 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:COMitter<committer@example.com>-EOF-test_cmpexpectedactual+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+11:Signed-off-by:COMitter<committer@example.com>+EOF+test_cmpexpectactual' 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:COMitter<committer@example.com>-EOF-test_cmpexpectedactual+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:COMitter<committer@example.com>+EOF+test_cmpexpectactual' 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-(cherrypickedfromcommitda39a3ee5e6b4b0d3255bfef95601890afd80709)-Tested-by:SomeOne<someone@example.com>-Bug:1234-EOF-cat>expected<<\EOF&&-4:Subject:[PATCH]subject-8:-10:-11:Signed-off-by:my@house-15:Signed-off-by:COMitter<committer@example.com>-EOF-test_cmpexpectedactual+Signed-off-by:my@house+(cherrypickedfromcommitda39a3ee5e6b4b0d3255bfef95601890afd80709)+Tested-by:SomeOne<someone@example.com>+Bug:1234+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+11:Signed-off-by:my@house+15:Signed-off-by:COMitter<committer@example.com>+EOF+test_cmpexpectactual' 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:COMitter<committer@example.com>-EOF-test_cmpexpectedactual+body+Fooled-by-me:my@house+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+11:+12:Signed-off-by:COMitter<committer@example.com>+EOF+test_cmpexpectactual' test_expect_success'signoff: not really a signoff''-append_signoff<<\EOF>actual&&-subject+append_signoff<<-\EOF>actual&&+subject-IwanttomentionaboutSigned-off-by:here.-EOF-cat>expected<<\EOF&&-4:Subject:[PATCH]subject-8:-9:IwanttomentionaboutSigned-off-by:here.-10:-11:Signed-off-by:COMitter<committer@example.com>-EOF-test_cmpexpectedactual+IwanttomentionaboutSigned-off-by:here.+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+9:IwanttomentionaboutSigned-off-by:here.+10:+11:Signed-off-by:COMitter<committer@example.com>+EOF+test_cmpexpectactual' test_expect_success'signoff: not really a signoff (2)''-append_signoff<<\EOF>actual&&-subject+append_signoff<<-\EOF>actual&&+subject-Myunfortunate-Signed-off-by:examplehappenstobewrappedhere.-EOF-cat>expected<<\EOF&&-4:Subject:[PATCH]subject-8:-10:Signed-off-by:examplehappenstobewrappedhere.-11:Signed-off-by:COMitter<committer@example.com>-EOF-test_cmpexpectedactual+Myunfortunate+Signed-off-by:examplehappenstobewrappedhere.+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:Signed-off-by:examplehappenstobewrappedhere.+11:Signed-off-by:COMitter<committer@example.com>+EOF+test_cmpexpectactual' 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-Alotofhouses.-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:COMitter<committer@example.com>-EOF-test_cmpexpectedactual+Alotofhouses.+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:COMitter<committer@example.com>+EOF+test_cmpexpectactual' 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:COMitter<committer@example.com>-EOF-cat>expected<<\EOF&&-4:Subject:[PATCH]subject-8:-10:-11:Signed-off-by:COMitter<committer@example.com>-EOF-test_cmpexpectedactual+Signed-off-by:COMitter<committer@example.com>+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+11:Signed-off-by:COMitter<committer@example.com>+EOF+test_cmpexpectactual' test_expect_success'signoff: the same signoff at the end, no trailing NL''printf"subject\n\nSigned-off-by: C O Mitter <committer@example.com>"|append_signoff>actual&&-cat>expected<<\EOF&&-4:Subject:[PATCH]subject-8:-9:Signed-off-by:COMitter<committer@example.com>-EOF-test_cmpexpectedactual+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+9:Signed-off-by:COMitter<committer@example.com>+EOF+test_cmpexpectactual' 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:COMitter<committer@example.com>-Signed-off-by:my@house-EOF-cat>expected<<\EOF&&-4:Subject:[PATCH]subject-8:-10:-11:Signed-off-by:COMitter<committer@example.com>-12:Signed-off-by:my@house-EOF-test_cmpexpectedactual+Signed-off-by:COMitter<committer@example.com>+Signed-off-by:my@house+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+11:Signed-off-by:COMitter<committer@example.com>+12:Signed-off-by:my@house+EOF+test_cmpexpectactual' 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-SomeTrash-Signed-off-by:COMitter<committer@example.com>-EOF-cat>expected<<\EOF&&-4:Subject:[PATCH]subject-8:-10:-13:Signed-off-by:COMitter<committer@example.com>-EOF-test_cmpexpectedactual+Tested-by:my@house+SomeTrash+Signed-off-by:COMitter<committer@example.com>+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+13:Signed-off-by:COMitter<committer@example.com>+EOF+test_cmpexpectactual' test_expect_success'signoff: respect trailer config''-append_signoff<<\EOF>actual&&-subject+append_signoff<<-\EOF>actual&&+subject-Myfooter:x-SomeTrash-EOF-cat>expected<<\EOF&&-4:Subject:[PATCH]subject-8:-11:-12:Signed-off-by:COMitter<committer@example.com>-EOF-test_cmpexpectedactual&&+Myfooter:x+SomeTrash+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+11:+12:Signed-off-by:COMitter<committer@example.com>+EOF+test_cmpexpectactual&&test_configtrailer.Myfooter.ifexistsadd&&-append_signoff<<\EOF>actual&&-subject+append_signoff<<-\EOF>actual&&+subject-Myfooter:x-SomeTrash-EOF-cat>expected<<\EOF&&-4:Subject:[PATCH]subject-8:-11:Signed-off-by:COMitter<committer@example.com>-EOF-test_cmpexpectedactual+Myfooter:x+SomeTrash+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+11:Signed-off-by:COMitter<committer@example.com>+EOF+test_cmpexpectactual' 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:COMitter<committer@example.com>-Bug:1234-EOF-cat>expected<<\EOF&&-4:Subject:[PATCH]subject-8:-10:-14:Signed-off-by:COMitter<committer@example.com>-EOF-test_cmpexpectedactual+Reviewed-id:Noone+Tested-by:my@house+Change-id:Ideadbeef+Signed-off-by:COMitter<committer@example.com>+Bug:1234+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+14:Signed-off-by:COMitter<committer@example.com>+EOF+test_cmpexpectactual' test_expect_success'format patch ignores color.ui''
@@ -1547,42 +1562,42 @@ test_expect_success 'cover letter using branch description (1)' 'gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&gitformat-patch--stdout--cover-lettermaster>actual&&-grephelloactual>/dev/null+grephelloactual' test_expect_success'cover letter using branch description (2)''gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&gitformat-patch--stdout--cover-letterrebuild-1~2..rebuild-1>actual&&-grephelloactual>/dev/null+grephelloactual' test_expect_success'cover letter using branch description (3)''gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&gitformat-patch--stdout--cover-letter^masterrebuild-1>actual&&-grephelloactual>/dev/null+grephelloactual' test_expect_success'cover letter using branch description (4)''gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&gitformat-patch--stdout--cover-lettermaster..>actual&&-grephelloactual>/dev/null+grephelloactual' test_expect_success'cover letter using branch description (5)''gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&gitformat-patch--stdout--cover-letter-2HEAD>actual&&-grephelloactual>/dev/null+grephelloactual' test_expect_success'cover letter using branch description (6)''gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&gitformat-patch--stdout--cover-letter-2>actual&&-grephelloactual>/dev/null+grephelloactual' test_expect_success'cover letter with nothing''
@@ -1672,8 +1709,9 @@ test_expect_success 'format-patch --base errors out when base commit is in revistest_must_failgitformat-patch--base=HEAD~1-2&&gitformat-patch--stdout--base=HEAD~2-2>patch&&grep"^base-commit:"patch>actual&&-echo"base-commit: $(gitrev-parseHEAD~2)">expected&&-test_cmpexpectedactual+gitrev-parseHEAD~2>commit-id-base&&+echo"base-commit: $(catcommit-id-base)">expect&&+test_cmpexpectactual' 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 ancetest_must_failgitformat-patch--base=$(catcommit-id-Z)-3&&gitformat-patch--stdout--base=$(catcommit-id-base)-3>patch&&grep"^base-commit:"patch>actual&&-echo"base-commit: $(catcommit-id-base)">expected&&-test_cmpexpectedactual+echo"base-commit: $(catcommit-id-base)">expect&&+test_cmpexpectactual' test_expect_success'format-patch --base=auto''
@@ -1711,8 +1749,9 @@ test_expect_success 'format-patch --base=auto' 'test_commitN2&&gitformat-patch--stdout--base=auto-2>patch&&grep"^base-commit:"patch>actual&&-echo"base-commit: $(gitrev-parseupstream)">expected&&-test_cmpexpectedactual+gitrev-parseupstream>commit-id-base&&+echo"base-commit: $(catcommit-id-base)">expect&&+test_cmpexpectactual' test_expect_success'format-patch errors out when history involves criss-cross''
From: Denton Liu <hidden> Date: 2019-08-19 23:52:55
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.
Signed-off-by: Denton Liu <redacted>
---
Documentation/git-format-patch.txt | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
@@ -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 ------------
@@ -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.
From: Denton Liu <hidden> Date: 2019-08-19 23:52:59
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.
Signed-off-by: Denton Liu <redacted>
---
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(-)
@@ -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.
@@ -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
@@ -1057,13 +1048,17 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,structcommit*origin,intnr,structcommit**list,constchar*branch_name,+intinfer_subject,intquiet){constchar*committer;-constchar*body="*** SUBJECT HERE ***\n\n*** BLURB HERE ***\n";-constchar*msg;+constchar*subject="*** SUBJECT HERE ***";+constchar*body="*** BLURB HERE ***";+constchar*description=NULL;structshortloglog;structstrbufsb=STRBUF_INIT;+structstrbufdescription_sb=STRBUF_INIT;+structstrbufsubject_sb=STRBUF_INIT;inti;constchar*encoding="UTF-8";intneed_8bit_cte=0;
@@ -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 the branch description")),{OPTION_CALLBACK,0,"subject-prefix",&rev,N_("prefix"),N_("Use [<prefix>] instead of [PATCH]"),PARSE_OPT_NONEG,subject_prefix_callback},
From: Eric Sunshine <hidden> Date: 2019-08-20 02:41:37
On Mon, Aug 19, 2019 at 7:53 PM Denton Liu [off-list ref] wrote:
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.
Signed-off-by: Denton Liu <redacted>
---
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).
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 hunk
@@ -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 }
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.
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.
From: Eric Sunshine <hidden> Date: 2019-08-20 02:44:17
On Mon, Aug 19, 2019 at 7:53 PM Denton Liu [off-list ref] wrote:
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 hunk
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.
Signed-off-by: Denton Liu <redacted>
---
@@ -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?
@@ -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.
From: Eric Sunshine <hidden> Date: 2019-08-20 03:47:01
On Mon, Aug 19, 2019 at 7:53 PM Denton Liu [off-list ref] wrote:
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/
`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.
@@ -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.
@@ -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.
quoted hunk
diff --git a/builtin/log.c b/builtin/log.c
@@ -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"
From: Denton Liu <hidden> Date: 2019-08-20 07:07:46
On Mon, Aug 19, 2019 at 10:44:03PM -0400, Eric Sunshine wrote:
On Mon, Aug 19, 2019 at 7:53 PM Denton Liu [off-list ref] wrote:
quoted
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
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.
Signed-off-by: Denton Liu <redacted>
---
@@ -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.
From: Denton Liu <hidden> Date: 2019-08-20 07:18:48
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/cover.1558492582.git.liu.denton@gmail.com/
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 [off-list ref]
## 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.
Signed-off-by: Denton Liu [off-list ref]
@@ 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
'
--
2.23.0.248.g3a9dd8fb08
@@ -109,7 +102,6 @@ test_expect_success "format-patch result applies" '' test_expect_success"format-patch --ignore-if-in-upstream result applies"'-gitcheckout-brebuild-1master&&gitam-3patch1&&cnt=$(gitrev-listmaster..|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''-gitcat-filecommitside|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''-gitcat-filecommitrebuild-1|grep"^Side .* with .* backslash-n"-' test_expect_success'extra headers''-gitconfigformat.headers"To: R E Cipient <rcipient@example.com>" &&gitconfig--addformat.headers"Cc: S E Cipient <scipient@example.com>
@@ -145,22 +130,18 @@ test_expect_success 'extra headers' 'sed-e"/^\$/q"patch2>hdrs2&&grep"^To: R E Cipient <rcipient@example.com>\$"hdrs2&&grep"^Cc: S E Cipient <scipient@example.com>\$"hdrs2-' test_expect_success'extra headers without newlines''-gitconfig--replace-allformat.headers"To: R E Cipient <rcipient@example.com>"&&gitconfig--addformat.headers"Cc: S E Cipient <scipient@example.com>"&&gitformat-patch--stdoutmaster..side>patch3&&sed-e"/^\$/q"patch3>hdrs3&&grep"^To: R E Cipient <rcipient@example.com>\$"hdrs3&&grep"^Cc: S E Cipient <scipient@example.com>\$"hdrs3-' test_expect_success'extra headers with multiple To:s''-gitconfig--replace-allformat.headers"To: R E Cipient <rcipient@example.com>"&&gitconfig--addformat.headers"To: S E Cipient <scipient@example.com>"&&gitformat-patch--stdoutmaster..side>patch4&&
@@ -170,7 +151,6 @@ test_expect_success 'extra headers with multiple To:s' '' test_expect_success'additional command line cc (ascii)''-gitconfig--replace-allformat.headers"Cc: R E Cipient <rcipient@example.com>"&&gitformat-patch--cc="S E Cipient <scipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch5&&grep"^Cc: R E Cipient <rcipient@example.com>,\$"patch5&&
@@ -178,7 +158,6 @@ test_expect_success 'additional command line cc (ascii)' '' test_expect_failure'additional command line cc (rfc822)''-gitconfig--replace-allformat.headers"Cc: R E Cipient <rcipient@example.com>"&&gitformat-patch--cc="S. E. Cipient <scipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch5&&grep"^Cc: R E Cipient <rcipient@example.com>,\$"patch5&&
@@ -186,14 +165,12 @@ test_expect_failure 'additional command line cc (rfc822)' '' test_expect_success'command line headers''-gitconfig--unset-allformat.headers&&gitformat-patch--add-header="Cc: R E Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch6&&grep"^Cc: R E Cipient <rcipient@example.com>\$"patch6' test_expect_success'configuration headers and command line headers''-gitconfig--replace-allformat.headers"Cc: R E Cipient <rcipient@example.com>"&&gitformat-patch--add-header="Cc: S E Cipient <scipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch7&&grep"^Cc: R E Cipient <rcipient@example.com>,\$"patch7&&
@@ -201,40 +178,34 @@ test_expect_success 'configuration headers and command line headers' '' test_expect_success'command line To: header (ascii)''-gitconfig--unset-allformat.headers&&gitformat-patch--to="R E Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch8&&grep"^To: R E Cipient <rcipient@example.com>\$"patch8' test_expect_failure'command line To: header (rfc822)''-gitformat-patch--to="R. E. Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch8&&grep"^To: \"R. E. Cipient\" <rcipient@example.com>\$"patch8' test_expect_failure'command line To: header (rfc2047)''-gitformat-patch--to="R Ä Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch8&&grep"^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$"patch8' test_expect_success'configuration To: header (ascii)''-gitconfigformat.to"R E Cipient <rcipient@example.com>"&&gitformat-patch--stdoutmaster..side|sed-e"/^\$/q">patch9&&grep"^To: R E Cipient <rcipient@example.com>\$"patch9' test_expect_failure'configuration To: header (rfc822)''-gitconfigformat.to"R. E. Cipient <rcipient@example.com>"&&gitformat-patch--stdoutmaster..side|sed-e"/^\$/q">patch9&&grep"^To: \"R. E. Cipient\" <rcipient@example.com>\$"patch9' test_expect_failure'configuration To: header (rfc2047)''-gitconfigformat.to"R Ä Cipient <rcipient@example.com>"&&gitformat-patch--stdoutmaster..side|sed-e"/^\$/q">patch9&&grep"^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$"patch9
@@ -265,7 +234,6 @@ test_expect_success 'format.from=true' '' test_expect_success'format.from with address''-git-cformat.from="F R Om <from@example.com>"format-patch--stdoutmaster..side|sed-e"/^\$/q">patch&&check_patchpatch&&
@@ -273,7 +241,6 @@ test_expect_success 'format.from with address' '' test_expect_success'--no-from overrides format.from''-git-cformat.from="F R Om <from@example.com>"format-patch--no-from--stdoutmaster..side|sed-e"/^\$/q">patch&&check_patchpatch&&
@@ -281,7 +248,6 @@ test_expect_success '--no-from overrides format.from' '' test_expect_success'--from overrides format.from''-git-cformat.from="F R Om <from@example.com>"format-patch--from--stdoutmaster..side|sed-e"/^\$/q">patch&&check_patchpatch&&
From: Denton Liu <hidden> Date: 2019-08-20 07:18:54
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 106 ++++++++++++++++++++--------------------
1 file changed, 53 insertions(+), 53 deletions(-)
@@ -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]EOL8:9:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: commit with only subject''echosubject|append_signoff>actual&&-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:9:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: commit with only subject that does not end with NL''printfsubject|append_signoff>actual&&-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:9:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: no existing signoffs''
@@ -1243,24 +1243,24 @@ subject body EOF-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:10:11:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' 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]subject8:10:11:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: some random signoff''
@@ -1292,14 +1292,14 @@ Signed-off-by: my@house Tested-by:SomeOne<someone@example.com> Bug:1234 EOF-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:10:11:Signed-off-by:my@house15:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' 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]subject8:11:12:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: not really a signoff''
@@ -1324,14 +1324,14 @@ subject IwanttomentionaboutSigned-off-by:here. EOF-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:9:IwanttomentionaboutSigned-off-by:here.10:11:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: not really a signoff (2)''
@@ -1341,13 +1341,13 @@ subject Myunfortunate Signed-off-by:examplehappenstobewrappedhere. EOF-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:10:Signed-off-by:examplehappenstobewrappedhere.11:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: valid S-o-b paragraph in the middle''
@@ -1368,7 +1368,7 @@ EOF13:14:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: the same signoff at the end''
@@ -1379,24 +1379,24 @@ body Signed-off-by:COMitter<committer@example.com> EOF-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:10:11:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: the same signoff at the end, no trailing NL''printf"subject\n\nSigned-off-by: C O Mitter <committer@example.com>"|append_signoff>actual&&-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:9:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: the same signoff NOT at the end''
@@ -1408,14 +1408,14 @@ body Signed-off-by:COMitter<committer@example.com> Signed-off-by:my@house EOF-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:10:11:Signed-off-by:COMitter<committer@example.com>12:Signed-off-by:my@house EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: tolerate garbage in conforming footer''
@@ -1625,8 +1625,8 @@ test_expect_success 'format-patch --base errors out when base commit is in revistest_must_failgitformat-patch--base=HEAD~1-2&&gitformat-patch--stdout--base=HEAD~2-2>patch&&grep"^base-commit:"patch>actual&&-echo"base-commit: $(gitrev-parseHEAD~2)">expected&&-test_cmpexpectedactual+echo"base-commit: $(gitrev-parseHEAD~2)">expect&&+test_cmpexpectactual' 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 ancetest_must_failgitformat-patch--base=$(catcommit-id-Z)-3&&gitformat-patch--stdout--base=$(catcommit-id-base)-3>patch&&grep"^base-commit:"patch>actual&&-echo"base-commit: $(catcommit-id-base)">expected&&-test_cmpexpectedactual+echo"base-commit: $(catcommit-id-base)">expect&&+test_cmpexpectactual' test_expect_success'format-patch --base=auto''
@@ -1664,8 +1664,8 @@ test_expect_success 'format-patch --base=auto' 'test_commitN2&&gitformat-patch--stdout--base=auto-2>patch&&grep"^base-commit:"patch>actual&&-echo"base-commit: $(gitrev-parseupstream)">expected&&-test_cmpexpectedactual+echo"base-commit: $(gitrev-parseupstream)">expect&&+test_cmpexpectactual' test_expect_success'format-patch errors out when history involves criss-cross''
From: Denton Liu <hidden> Date: 2019-08-20 07:18:56
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
@@ -790,11 +790,13 @@ test_expect_success 'options no longer allowed for format-patch' 'test_must_failgitformat-patch--name-status2>output&&test_i18ncmpexpect.name-statusoutput&&test_must_failgitformat-patch--check2>output&&-test_i18ncmpexpect.checkoutput'+test_i18ncmpexpect.checkoutput+' test_expect_success'format-patch --numstat should produce a patch''gitformat-patch--numstat--stdoutmaster..side>output&&-test5=$(grep"^diff --git a/"output|wc-l)'+test5=$(grep"^diff --git a/"output|wc-l)+' test_expect_success'format-patch -- <path>''gitformat-patchmaster..side--file2>error&&
From: Denton Liu <hidden> Date: 2019-08-20 07:18:58
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
From: Denton Liu <hidden> Date: 2019-08-20 07:19:01
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 62 ++++++++++++++++++++---------------------
1 file changed, 31 insertions(+), 31 deletions(-)
@@ -126,8 +126,8 @@ test_expect_success 'extra headers' '" &&gitconfig--addformat.headers"Cc: S E Cipient <scipient@example.com>" &&-gitformat-patch--stdoutmaster..side>patch2&&-sed-e"/^\$/q"patch2>hdrs2&&+gitformat-patch--stdoutmaster..side>patch2&&+sed-e"/^\$/q"patch2>hdrs2&&grep"^To: R E Cipient <rcipient@example.com>\$"hdrs2&&grep"^Cc: S E Cipient <scipient@example.com>\$"hdrs2'
@@ -136,7 +136,7 @@ test_expect_success 'extra headers without newlines' 'gitconfig--replace-allformat.headers"To: R E Cipient <rcipient@example.com>"&&gitconfig--addformat.headers"Cc: S E Cipient <scipient@example.com>"&&gitformat-patch--stdoutmaster..side>patch3&&-sed-e"/^\$/q"patch3>hdrs3&&+sed-e"/^\$/q"patch3>hdrs3&&grep"^To: R E Cipient <rcipient@example.com>\$"hdrs3&&grep"^Cc: S E Cipient <scipient@example.com>\$"hdrs3'
@@ -144,8 +144,8 @@ test_expect_success 'extra headers without newlines' ' test_expect_success'extra headers with multiple To:s''gitconfig--replace-allformat.headers"To: R E Cipient <rcipient@example.com>"&&gitconfig--addformat.headers"To: S E Cipient <scipient@example.com>"&&-gitformat-patch--stdoutmaster..side>patch4&&-sed-e"/^\$/q"patch4>hdrs4&&+gitformat-patch--stdoutmaster..side>patch4&&+sed-e"/^\$/q"patch4>hdrs4&&grep"^To: R E Cipient <rcipient@example.com>,\$"hdrs4&&grep"^ *S E Cipient <scipient@example.com>\$"hdrs4'
@@ -318,7 +318,7 @@ test_expect_success 'reroll count (-v)' ' check_threading(){expect="$1"&&shift&&-(gitformat-patch--stdout"$@";echo$?>status.out)|+(gitformat-patch--stdout"$@";echo$?>status.out)|# Prints everything between the Message-ID and In-Reply-To,# and replaces all Message-ID-lookalikes by a sequence numberperl-ne'
@@ -689,7 +689,7 @@ test_expect_success 'format-patch from a subdirectory (3)' '' test_expect_success'format-patch --in-reply-to''-gitformat-patch-1--stdout--in-reply-to"baz@foo.bar">patch8&&+gitformat-patch-1--stdout--in-reply-to"baz@foo.bar">patch8&&grep"^In-Reply-To: <baz@foo.bar>"patch8&&grep"^References: <baz@foo.bar>"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_failgitformat-patch--name-only2>output&&+test_must_failgitformat-patch--name-only2>output&&test_i18ncmpexpect.name-onlyoutput&&-test_must_failgitformat-patch--name-status2>output&&+test_must_failgitformat-patch--name-status2>output&&test_i18ncmpexpect.name-statusoutput&&-test_must_failgitformat-patch--check2>output&&+test_must_failgitformat-patch--check2>output&&test_i18ncmpexpect.checkoutput' test_expect_success'format-patch --numstat should produce a patch''-gitformat-patch--numstat--stdoutmaster..side>output&&+gitformat-patch--numstat--stdoutmaster..side>output&&test5=$(grep"^diff --git a/"output|wc-l)'
From: Denton Liu <hidden> Date: 2019-08-20 07:19:03
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 368 ++++++++++++++++++++--------------------
1 file changed, 184 insertions(+), 184 deletions(-)
@@ -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:COMitter<committer@example.com>-EOF+cat<<-\EOF | sed "s/EOL$//" >expect &&+4:Subject:[PATCH]EOL+8:+9:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' test_expect_success'signoff: commit with only subject''echosubject|append_signoff>actual&&-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-9:Signed-off-by:COMitter<committer@example.com>-EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+9:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' test_expect_success'signoff: commit with only subject that does not end with NL''printfsubject|append_signoff>actual&&-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-9:Signed-off-by:COMitter<committer@example.com>-EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+9:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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:COMitter<committer@example.com>-EOF+body+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+11:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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:COMitter<committer@example.com>-EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+11:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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:COMitter<committer@example.com>-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:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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-(cherrypickedfromcommitda39a3ee5e6b4b0d3255bfef95601890afd80709)-Tested-by:SomeOne<someone@example.com>-Bug:1234-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-10:-11:Signed-off-by:my@house-15:Signed-off-by:COMitter<committer@example.com>-EOF+Signed-off-by:my@house+(cherrypickedfromcommitda39a3ee5e6b4b0d3255bfef95601890afd80709)+Tested-by:SomeOne<someone@example.com>+Bug:1234+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+11:Signed-off-by:my@house+15:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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:COMitter<committer@example.com>-EOF+body+Fooled-by-me:my@house+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+11:+12:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' test_expect_success'signoff: not really a signoff''-append_signoff<<\EOF>actual&&-subject+append_signoff<<-\EOF>actual&&+subject-IwanttomentionaboutSigned-off-by:here.-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-9:IwanttomentionaboutSigned-off-by:here.-10:-11:Signed-off-by:COMitter<committer@example.com>-EOF+IwanttomentionaboutSigned-off-by:here.+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+9:IwanttomentionaboutSigned-off-by:here.+10:+11:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' test_expect_success'signoff: not really a signoff (2)''-append_signoff<<\EOF>actual&&-subject+append_signoff<<-\EOF>actual&&+subject-Myunfortunate-Signed-off-by:examplehappenstobewrappedhere.-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-10:Signed-off-by:examplehappenstobewrappedhere.-11:Signed-off-by:COMitter<committer@example.com>-EOF+Myunfortunate+Signed-off-by:examplehappenstobewrappedhere.+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:Signed-off-by:examplehappenstobewrappedhere.+11:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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-Alotofhouses.-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:COMitter<committer@example.com>-EOF+Alotofhouses.+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:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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:COMitter<committer@example.com>-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-10:-11:Signed-off-by:COMitter<committer@example.com>-EOF+Signed-off-by:COMitter<committer@example.com>+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+11:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' test_expect_success'signoff: the same signoff at the end, no trailing NL''printf"subject\n\nSigned-off-by: C O Mitter <committer@example.com>"|append_signoff>actual&&-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-9:Signed-off-by:COMitter<committer@example.com>-EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+9:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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:COMitter<committer@example.com>-Signed-off-by:my@house-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-10:-11:Signed-off-by:COMitter<committer@example.com>-12:Signed-off-by:my@house-EOF+Signed-off-by:COMitter<committer@example.com>+Signed-off-by:my@house+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+11:Signed-off-by:COMitter<committer@example.com>+12:Signed-off-by:my@house+EOFtest_cmpexpectactual' 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-SomeTrash-Signed-off-by:COMitter<committer@example.com>-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-10:-13:Signed-off-by:COMitter<committer@example.com>-EOF+Tested-by:my@house+SomeTrash+Signed-off-by:COMitter<committer@example.com>+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+13:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' test_expect_success'signoff: respect trailer config''-append_signoff<<\EOF>actual&&-subject+append_signoff<<-\EOF>actual&&+subject-Myfooter:x-SomeTrash-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-11:-12:Signed-off-by:COMitter<committer@example.com>-EOF+Myfooter:x+SomeTrash+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+11:+12:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual&&test_configtrailer.Myfooter.ifexistsadd&&-append_signoff<<\EOF>actual&&-subject+append_signoff<<-\EOF>actual&&+subject-Myfooter:x-SomeTrash-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-11:Signed-off-by:COMitter<committer@example.com>-EOF+Myfooter:x+SomeTrash+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+11:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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:COMitter<committer@example.com>-Bug:1234-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-10:-14:Signed-off-by:COMitter<committer@example.com>-EOF+Reviewed-id:Noone+Tested-by:my@house+Change-id:Ideadbeef+Signed-off-by:COMitter<committer@example.com>+Bug:1234+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+14:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual'
From: Denton Liu <hidden> Date: 2019-08-20 07:19:05
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
@@ -1502,42 +1502,42 @@ test_expect_success 'cover letter using branch description (1)' 'gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&gitformat-patch--stdout--cover-lettermaster>actual&&-grephelloactual>/dev/null+grephelloactual' test_expect_success'cover letter using branch description (2)''gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&gitformat-patch--stdout--cover-letterrebuild-1~2..rebuild-1>actual&&-grephelloactual>/dev/null+grephelloactual' test_expect_success'cover letter using branch description (3)''gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&gitformat-patch--stdout--cover-letter^masterrebuild-1>actual&&-grephelloactual>/dev/null+grephelloactual' test_expect_success'cover letter using branch description (4)''gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&gitformat-patch--stdout--cover-lettermaster..>actual&&-grephelloactual>/dev/null+grephelloactual' test_expect_success'cover letter using branch description (5)''gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&gitformat-patch--stdout--cover-letter-2HEAD>actual&&-grephelloactual>/dev/null+grephelloactual' test_expect_success'cover letter using branch description (6)''gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&gitformat-patch--stdout--cover-letter-2>actual&&-grephelloactual>/dev/null+grephelloactual' test_expect_success'cover letter with nothing''
From: Denton Liu <hidden> Date: 2019-08-20 07:19:08
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 35 +++++++++++++++++++----------------
1 file changed, 19 insertions(+), 16 deletions(-)
@@ -90,22 +90,23 @@ test_expect_success "format-patch doesn't consider merge commits" 'gitcheckout-bmergermaster&&test_tick&&gitmerge--no-ffslave&&-cnt=$(gitformat-patch-3--stdout|grep"^From "|wc-l)&&-test$cnt=3+gitformat-patch-3--stdout>patch&&+grep"^From "patch>from&&+test_line_count=3from' test_expect_success'format-patch result applies''gitcheckout-brebuild-0master&&gitam-3patch0&&-cnt=$(gitrev-listmaster..|wc-l)&&-test$cnt=2+gitrev-listmaster..>list&&+test_line_count=2list' test_expect_success'format-patch --ignore-if-in-upstream result applies''gitcheckout-brebuild-1master&&gitam-3patch1&&-cnt=$(gitrev-listmaster..|wc-l)&&-test$cnt=2+gitrev-listmaster..>list&&+test_line_count=2list' 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''gitformat-patch--numstat--stdoutmaster..side>output&&-test5=$(grep"^diff --git a/"output|wc-l)+grep"^diff --git a/"output>diff&&+test_line_count=5diff' test_expect_success'format-patch -- <path>''
From: Denton Liu <hidden> Date: 2019-08-20 07:19:10
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
@@ -319,7 +319,7 @@ test_expect_success 'reroll count (-v)' ' check_threading(){expect="$1"&&shift&&-(gitformat-patch--stdout"$@";echo$?>status.out)|+gitformat-patch--stdout"$@">patch&&# Prints everything between the Message-ID and In-Reply-To,# and replaces all Message-ID-lookalikes by a sequence numberperl-ne'
From: Denton Liu <hidden> Date: 2019-08-20 07:19:13
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 196 ++++++++++++++++++++++++----------------
1 file changed, 119 insertions(+), 77 deletions(-)
@@ -33,7 +33,8 @@ test_expect_success setup 'gitcommit-m"Side changes #3 with \\n backslash-n in it."&&gitcheckoutmaster&&-gitdiff-tree-pC2|gitapply--index&&+gitdiff-tree-pC2>patch&&+gitapply--index<patch&&test_tick&&gitcommit-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''-gitcat-filecommitside|grep"^Side .* with .* backslash-n"+gitcat-filecommitside>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''-gitcat-filecommitrebuild-1|grep"^Side .* with .* backslash-n"+gitcat-filecommitrebuild-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)''gitconfig--replace-allformat.headers"Cc: R E Cipient <rcipient@example.com>"&&-gitformat-patch--cc="S E Cipient <scipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch5&&-grep"^Cc: R E Cipient <rcipient@example.com>,\$"patch5&&-grep"^ *S E Cipient <scipient@example.com>\$"patch5+gitformat-patch--cc="S E Cipient <scipient@example.com>"--stdoutmaster..side>patch5&&+sed-e"/^\$/q"patch5>hdrs5&&+grep"^Cc: R E Cipient <rcipient@example.com>,\$"hdrs5&&+grep"^ *S E Cipient <scipient@example.com>\$"hdrs5' test_expect_failure'additional command line cc (rfc822)''gitconfig--replace-allformat.headers"Cc: R E Cipient <rcipient@example.com>"&&-gitformat-patch--cc="S. E. Cipient <scipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch5&&-grep"^Cc: R E Cipient <rcipient@example.com>,\$"patch5&&-grep"^ *\"S. E. Cipient\" <scipient@example.com>\$"patch5+gitformat-patch--cc="S. E. Cipient <scipient@example.com>"--stdoutmaster..side>patch5&&+sed-e"/^\$/q"patch5>hdrs5&&+grep"^Cc: R E Cipient <rcipient@example.com>,\$"hdrs5&&+grep"^ *\"S. E. Cipient\" <scipient@example.com>\$"hdrs5' test_expect_success'command line headers''gitconfig--unset-allformat.headers&&-gitformat-patch--add-header="Cc: R E Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch6&&-grep"^Cc: R E Cipient <rcipient@example.com>\$"patch6+gitformat-patch--add-header="Cc: R E Cipient <rcipient@example.com>"--stdoutmaster..side>patch6&&+sed-e"/^\$/q"patch6>hdrs6&&+grep"^Cc: R E Cipient <rcipient@example.com>\$"hdrs6' test_expect_success'configuration headers and command line headers''gitconfig--replace-allformat.headers"Cc: R E Cipient <rcipient@example.com>"&&-gitformat-patch--add-header="Cc: S E Cipient <scipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch7&&-grep"^Cc: R E Cipient <rcipient@example.com>,\$"patch7&&-grep"^ *S E Cipient <scipient@example.com>\$"patch7+gitformat-patch--add-header="Cc: S E Cipient <scipient@example.com>"--stdoutmaster..side>patch7&&+sed-e"/^\$/q"patch7>hdrs7&&+grep"^Cc: R E Cipient <rcipient@example.com>,\$"hdrs7&&+grep"^ *S E Cipient <scipient@example.com>\$"hdrs7' test_expect_success'command line To: header (ascii)''gitconfig--unset-allformat.headers&&-gitformat-patch--to="R E Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch8&&-grep"^To: R E Cipient <rcipient@example.com>\$"patch8+gitformat-patch--to="R E Cipient <rcipient@example.com>"--stdoutmaster..side>patch8&&+sed-e"/^\$/q"patch8>hdrs8&&+grep"^To: R E Cipient <rcipient@example.com>\$"hdrs8' test_expect_failure'command line To: header (rfc822)''-gitformat-patch--to="R. E. Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch8&&-grep"^To: \"R. E. Cipient\" <rcipient@example.com>\$"patch8+gitformat-patch--to="R. E. Cipient <rcipient@example.com>"--stdoutmaster..side>patch8&&+sed-e"/^\$/q"patch8>hdrs8&&+grep"^To: \"R. E. Cipient\" <rcipient@example.com>\$"hdrs8' test_expect_failure'command line To: header (rfc2047)''-gitformat-patch--to="R Ä Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch8&&-grep"^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$"patch8+gitformat-patch--to="R Ä Cipient <rcipient@example.com>"--stdoutmaster..side>patch8&&+sed-e"/^\$/q"patch8>hdrs8&&+grep"^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$"hdrs8' test_expect_success'configuration To: header (ascii)''gitconfigformat.to"R E Cipient <rcipient@example.com>"&&-gitformat-patch--stdoutmaster..side|sed-e"/^\$/q">patch9&&-grep"^To: R E Cipient <rcipient@example.com>\$"patch9+gitformat-patch--stdoutmaster..side>patch9&&+sed-e"/^\$/q"patch9>hdrs9&&+grep"^To: R E Cipient <rcipient@example.com>\$"hdrs9' test_expect_failure'configuration To: header (rfc822)''gitconfigformat.to"R. E. Cipient <rcipient@example.com>"&&-gitformat-patch--stdoutmaster..side|sed-e"/^\$/q">patch9&&-grep"^To: \"R. E. Cipient\" <rcipient@example.com>\$"patch9+gitformat-patch--stdoutmaster..side>patch9&&+sed-e"/^\$/q"patch9>hdrs9&&+grep"^To: \"R. E. Cipient\" <rcipient@example.com>\$"hdrs9' test_expect_failure'configuration To: header (rfc2047)''gitconfigformat.to"R Ä Cipient <rcipient@example.com>"&&-gitformat-patch--stdoutmaster..side|sed-e"/^\$/q">patch9&&-grep"^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$"patch9+gitformat-patch--stdoutmaster..side>patch9&&+sed-e"/^\$/q"patch9>hdrs9&&+grep"^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$"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-cformat.from=falseformat-patch--stdoutmaster..side|-sed-e"/^\$/q">patch&&+git-cformat.from=falseformat-patch--stdoutmaster..side>patch&&+sed-e"/^\$/q"patch>hdrs&&check_patchpatch&&-!grep"^From: C O Mitter <committer@example.com>\$"patch+!grep"^From: C O Mitter <committer@example.com>\$"hdrs' test_expect_success'format.from=true''-git-cformat.from=trueformat-patch--stdoutmaster..side|-sed-e"/^\$/q">patch&&-check_patchpatch&&-grep"^From: C O Mitter <committer@example.com>\$"patch+git-cformat.from=trueformat-patch--stdoutmaster..side>patch&&+sed-e"/^\$/q"patch>hdrs&&+check_patchhdrs&&+grep"^From: C O Mitter <committer@example.com>\$"hdrs' test_expect_success'format.from with address''-git-cformat.from="F R Om <from@example.com>"format-patch--stdoutmaster..side|-sed-e"/^\$/q">patch&&-check_patchpatch&&-grep"^From: F R Om <from@example.com>\$"patch+git-cformat.from="F R Om <from@example.com>"format-patch--stdoutmaster..side>patch&&+sed-e"/^\$/q"patch>hdrs&&+check_patchhdrs&&+grep"^From: F R Om <from@example.com>\$"hdrs' test_expect_success'--no-from overrides format.from''-git-cformat.from="F R Om <from@example.com>"format-patch--no-from--stdoutmaster..side|-sed-e"/^\$/q">patch&&-check_patchpatch&&-!grep"^From: F R Om <from@example.com>\$"patch+git-cformat.from="F R Om <from@example.com>"format-patch--no-from--stdoutmaster..side>patch&&+sed-e"/^\$/q"patch>hdrs&&+check_patchhdrs&&+!grep"^From: F R Om <from@example.com>\$"hdrs' test_expect_success'--from overrides format.from''-git-cformat.from="F R Om <from@example.com>"format-patch--from--stdoutmaster..side|-sed-e"/^\$/q">patch&&-check_patchpatch&&-!grep"^From: F R Om <from@example.com>\$"patch+git-cformat.from="F R Om <from@example.com>"format-patch--from--stdoutmaster..side>patch&&+sed-e"/^\$/q"patch>hdrs&&+check_patchhdrs&&+!grep"^From: F R Om <from@example.com>\$"hdrs' test_expect_success'--no-to overrides config.to''gitconfig--replace-allformat.to\"R E Cipient <rcipient@example.com>"&&-gitformat-patch--no-to--stdoutmaster..side|-sed-e"/^\$/q">patch10&&-check_patchpatch10&&-!grep"^To: R E Cipient <rcipient@example.com>\$"patch10+gitformat-patch--no-to--stdoutmaster..side>patch10&&+sed-e"/^\$/q"patch10>hdrs10&&+check_patchhdrs10&&+!grep"^To: R E Cipient <rcipient@example.com>\$"hdrs10' test_expect_success'--no-to and --to replaces config.to''gitconfig--replace-allformat.to\"Someone <someone@out.there>"&&gitformat-patch--no-to--to="Someone Else <else@out.there>"\---stdoutmaster..side|-sed-e"/^\$/q">patch11&&-check_patchpatch11&&-!grep"^To: Someone <someone@out.there>\$"patch11&&-grep"^To: Someone Else <else@out.there>\$"patch11+--stdoutmaster..side>patch11&&+sed-e"/^\$/q"patch11>hdrs11&&+check_patchhdrs11&&+!grep"^To: Someone <someone@out.there>\$"hdrs11&&+grep"^To: Someone Else <else@out.there>\$"hdrs11' test_expect_success'--no-cc overrides config.cc''gitconfig--replace-allformat.cc\"C E Cipient <rcipient@example.com>"&&-gitformat-patch--no-cc--stdoutmaster..side|-sed-e"/^\$/q">patch12&&-check_patchpatch12&&-!grep"^Cc: C E Cipient <rcipient@example.com>\$"patch12+gitformat-patch--no-cc--stdoutmaster..side>patch12&&+sed-e"/^\$/q"patch12>hdrs12&&+check_patchhdrs12&&+!grep"^Cc: C E Cipient <rcipient@example.com>\$"hdrs12' test_expect_success'--no-add-header overrides config.headers''gitconfig--replace-allformat.headers\"Header1: B E Cipient <rcipient@example.com>"&&-gitformat-patch--no-add-header--stdoutmaster..side|-sed-e"/^\$/q">patch13&&-check_patchpatch13&&-!grep"^Header1: B E Cipient <rcipient@example.com>\$"patch13+gitformat-patch--no-add-header--stdoutmaster..side>patch13&&+sed-e"/^\$/q"patch13>hdrs13&&+check_patchhdrs13&&+!grep"^Header1: B E Cipient <rcipient@example.com>\$"hdrs13' test_expect_success'multiple files''
@@ -1629,7 +1667,8 @@ test_expect_success 'format-patch --base errors out when base commit is in revistest_must_failgitformat-patch--base=HEAD~1-2&&gitformat-patch--stdout--base=HEAD~2-2>patch&&grep"^base-commit:"patch>actual&&-echo"base-commit: $(gitrev-parseHEAD~2)">expect&&+gitrev-parseHEAD~2>commit-id-base&&+echo"base-commit: $(catcommit-id-base)">expect&&test_cmpexpectactual'
From: Denton Liu <hidden> Date: 2019-08-20 07:19:15
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.
Signed-off-by: Denton Liu <redacted>
---
Documentation/git-format-patch.txt | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
@@ -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 ------------
@@ -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
From: Denton Liu <hidden> Date: 2019-08-20 07:19:21
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.
Signed-off-by: Denton Liu <redacted>
---
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(-)
@@ -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.
@@ -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
@@ -1057,13 +1048,17 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,structcommit*origin,intnr,structcommit**list,constchar*branch_name,+intinfer_subject,intquiet){constchar*committer;-constchar*body="*** SUBJECT HERE ***\n\n*** BLURB HERE ***\n";-constchar*msg;+constchar*subject="*** SUBJECT HERE ***";+constchar*body="*** BLURB HERE ***";+constchar*description=NULL;structshortloglog;structstrbufsb=STRBUF_INIT;+structstrbufdescription_sb=STRBUF_INIT;+structstrbufsubject_sb=STRBUF_INIT;inti;constchar*encoding="UTF-8";intneed_8bit_cte=0;
@@ -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},
From: Denton Liu <hidden> Date: 2019-08-20 07:31:35
On Tue, Aug 20, 2019 at 03:19:08AM -0400, Denton Liu wrote:
quoted hunk
@@ -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?
From: Junio C Hamano <hidden> Date: 2019-08-22 20:18:13
Denton Liu [off-list ref] writes:
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.
From: Denton Liu <hidden> Date: 2019-08-23 18:20:02
On Thu, Aug 22, 2019 at 01:18:08PM -0700, Junio C Hamano wrote:
Denton Liu [off-list ref] writes:
quoted
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?
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.
From: Denton Liu <hidden> Date: 2019-08-24 08:25:26
*** 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/xmqqwof3ljcz.fsf@gitster-ct.c.googlers.com/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
--
2.23.0.248.g3a9dd8fb08
@@ -109,7 +102,6 @@ test_expect_success "format-patch result applies" '' test_expect_success"format-patch --ignore-if-in-upstream result applies"'-gitcheckout-brebuild-1master&&gitam-3patch1&&cnt=$(gitrev-listmaster..|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''-gitcat-filecommitside|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''-gitcat-filecommitrebuild-1|grep"^Side .* with .* backslash-n"-' test_expect_success'extra headers''-gitconfigformat.headers"To: R E Cipient <rcipient@example.com>" &&gitconfig--addformat.headers"Cc: S E Cipient <scipient@example.com>
@@ -145,22 +130,18 @@ test_expect_success 'extra headers' 'sed-e"/^\$/q"patch2>hdrs2&&grep"^To: R E Cipient <rcipient@example.com>\$"hdrs2&&grep"^Cc: S E Cipient <scipient@example.com>\$"hdrs2-' test_expect_success'extra headers without newlines''-gitconfig--replace-allformat.headers"To: R E Cipient <rcipient@example.com>"&&gitconfig--addformat.headers"Cc: S E Cipient <scipient@example.com>"&&gitformat-patch--stdoutmaster..side>patch3&&sed-e"/^\$/q"patch3>hdrs3&&grep"^To: R E Cipient <rcipient@example.com>\$"hdrs3&&grep"^Cc: S E Cipient <scipient@example.com>\$"hdrs3-' test_expect_success'extra headers with multiple To:s''-gitconfig--replace-allformat.headers"To: R E Cipient <rcipient@example.com>"&&gitconfig--addformat.headers"To: S E Cipient <scipient@example.com>"&&gitformat-patch--stdoutmaster..side>patch4&&
@@ -170,7 +151,6 @@ test_expect_success 'extra headers with multiple To:s' '' test_expect_success'additional command line cc (ascii)''-gitconfig--replace-allformat.headers"Cc: R E Cipient <rcipient@example.com>"&&gitformat-patch--cc="S E Cipient <scipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch5&&grep"^Cc: R E Cipient <rcipient@example.com>,\$"patch5&&
@@ -178,7 +158,6 @@ test_expect_success 'additional command line cc (ascii)' '' test_expect_failure'additional command line cc (rfc822)''-gitconfig--replace-allformat.headers"Cc: R E Cipient <rcipient@example.com>"&&gitformat-patch--cc="S. E. Cipient <scipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch5&&grep"^Cc: R E Cipient <rcipient@example.com>,\$"patch5&&
@@ -186,14 +165,12 @@ test_expect_failure 'additional command line cc (rfc822)' '' test_expect_success'command line headers''-gitconfig--unset-allformat.headers&&gitformat-patch--add-header="Cc: R E Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch6&&grep"^Cc: R E Cipient <rcipient@example.com>\$"patch6' test_expect_success'configuration headers and command line headers''-gitconfig--replace-allformat.headers"Cc: R E Cipient <rcipient@example.com>"&&gitformat-patch--add-header="Cc: S E Cipient <scipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch7&&grep"^Cc: R E Cipient <rcipient@example.com>,\$"patch7&&
@@ -201,40 +178,34 @@ test_expect_success 'configuration headers and command line headers' '' test_expect_success'command line To: header (ascii)''-gitconfig--unset-allformat.headers&&gitformat-patch--to="R E Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch8&&grep"^To: R E Cipient <rcipient@example.com>\$"patch8' test_expect_failure'command line To: header (rfc822)''-gitformat-patch--to="R. E. Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch8&&grep"^To: \"R. E. Cipient\" <rcipient@example.com>\$"patch8' test_expect_failure'command line To: header (rfc2047)''-gitformat-patch--to="R Ä Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch8&&grep"^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$"patch8' test_expect_success'configuration To: header (ascii)''-gitconfigformat.to"R E Cipient <rcipient@example.com>"&&gitformat-patch--stdoutmaster..side|sed-e"/^\$/q">patch9&&grep"^To: R E Cipient <rcipient@example.com>\$"patch9' test_expect_failure'configuration To: header (rfc822)''-gitconfigformat.to"R. E. Cipient <rcipient@example.com>"&&gitformat-patch--stdoutmaster..side|sed-e"/^\$/q">patch9&&grep"^To: \"R. E. Cipient\" <rcipient@example.com>\$"patch9' test_expect_failure'configuration To: header (rfc2047)''-gitconfigformat.to"R Ä Cipient <rcipient@example.com>"&&gitformat-patch--stdoutmaster..side|sed-e"/^\$/q">patch9&&grep"^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$"patch9
@@ -265,7 +234,6 @@ test_expect_success 'format.from=true' '' test_expect_success'format.from with address''-git-cformat.from="F R Om <from@example.com>"format-patch--stdoutmaster..side|sed-e"/^\$/q">patch&&check_patchpatch&&
@@ -273,7 +241,6 @@ test_expect_success 'format.from with address' '' test_expect_success'--no-from overrides format.from''-git-cformat.from="F R Om <from@example.com>"format-patch--no-from--stdoutmaster..side|sed-e"/^\$/q">patch&&check_patchpatch&&
@@ -281,7 +248,6 @@ test_expect_success '--no-from overrides format.from' '' test_expect_success'--from overrides format.from''-git-cformat.from="F R Om <from@example.com>"format-patch--from--stdoutmaster..side|sed-e"/^\$/q">patch&&check_patchpatch&&
From: Denton Liu <hidden> Date: 2019-08-24 08:26:58
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 106 ++++++++++++++++++++--------------------
1 file changed, 53 insertions(+), 53 deletions(-)
@@ -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]EOL8:9:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: commit with only subject''echosubject|append_signoff>actual&&-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:9:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: commit with only subject that does not end with NL''printfsubject|append_signoff>actual&&-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:9:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: no existing signoffs''
@@ -1243,24 +1243,24 @@ subject body EOF-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:10:11:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' 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]subject8:10:11:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: some random signoff''
@@ -1292,14 +1292,14 @@ Signed-off-by: my@house Tested-by:SomeOne<someone@example.com> Bug:1234 EOF-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:10:11:Signed-off-by:my@house15:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' 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]subject8:11:12:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: not really a signoff''
@@ -1324,14 +1324,14 @@ subject IwanttomentionaboutSigned-off-by:here. EOF-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:9:IwanttomentionaboutSigned-off-by:here.10:11:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: not really a signoff (2)''
@@ -1341,13 +1341,13 @@ subject Myunfortunate Signed-off-by:examplehappenstobewrappedhere. EOF-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:10:Signed-off-by:examplehappenstobewrappedhere.11:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: valid S-o-b paragraph in the middle''
@@ -1368,7 +1368,7 @@ EOF13:14:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: the same signoff at the end''
@@ -1379,24 +1379,24 @@ body Signed-off-by:COMitter<committer@example.com> EOF-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:10:11:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: the same signoff at the end, no trailing NL''printf"subject\n\nSigned-off-by: C O Mitter <committer@example.com>"|append_signoff>actual&&-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:9:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: the same signoff NOT at the end''
@@ -1408,14 +1408,14 @@ body Signed-off-by:COMitter<committer@example.com> Signed-off-by:my@house EOF-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:10:11:Signed-off-by:COMitter<committer@example.com>12:Signed-off-by:my@house EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: tolerate garbage in conforming footer''
@@ -1625,8 +1625,8 @@ test_expect_success 'format-patch --base errors out when base commit is in revistest_must_failgitformat-patch--base=HEAD~1-2&&gitformat-patch--stdout--base=HEAD~2-2>patch&&grep"^base-commit:"patch>actual&&-echo"base-commit: $(gitrev-parseHEAD~2)">expected&&-test_cmpexpectedactual+echo"base-commit: $(gitrev-parseHEAD~2)">expect&&+test_cmpexpectactual' 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 ancetest_must_failgitformat-patch--base=$(catcommit-id-Z)-3&&gitformat-patch--stdout--base=$(catcommit-id-base)-3>patch&&grep"^base-commit:"patch>actual&&-echo"base-commit: $(catcommit-id-base)">expected&&-test_cmpexpectedactual+echo"base-commit: $(catcommit-id-base)">expect&&+test_cmpexpectactual' test_expect_success'format-patch --base=auto''
@@ -1664,8 +1664,8 @@ test_expect_success 'format-patch --base=auto' 'test_commitN2&&gitformat-patch--stdout--base=auto-2>patch&&grep"^base-commit:"patch>actual&&-echo"base-commit: $(gitrev-parseupstream)">expected&&-test_cmpexpectedactual+echo"base-commit: $(gitrev-parseupstream)">expect&&+test_cmpexpectactual' test_expect_success'format-patch errors out when history involves criss-cross''
From: Denton Liu <hidden> Date: 2019-08-24 08:26:58
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
@@ -790,11 +790,13 @@ test_expect_success 'options no longer allowed for format-patch' 'test_must_failgitformat-patch--name-status2>output&&test_i18ncmpexpect.name-statusoutput&&test_must_failgitformat-patch--check2>output&&-test_i18ncmpexpect.checkoutput'+test_i18ncmpexpect.checkoutput+' test_expect_success'format-patch --numstat should produce a patch''gitformat-patch--numstat--stdoutmaster..side>output&&-test5=$(grep"^diff --git a/"output|wc-l)'+test5=$(grep"^diff --git a/"output|wc-l)+' test_expect_success'format-patch -- <path>''gitformat-patchmaster..side--file2>error&&
From: Denton Liu <hidden> Date: 2019-08-24 08:27:01
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
From: Denton Liu <hidden> Date: 2019-08-24 08:27:04
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 62 ++++++++++++++++++++---------------------
1 file changed, 31 insertions(+), 31 deletions(-)
@@ -126,8 +126,8 @@ test_expect_success 'extra headers' '" &&gitconfig--addformat.headers"Cc: S E Cipient <scipient@example.com>" &&-gitformat-patch--stdoutmaster..side>patch2&&-sed-e"/^\$/q"patch2>hdrs2&&+gitformat-patch--stdoutmaster..side>patch2&&+sed-e"/^\$/q"patch2>hdrs2&&grep"^To: R E Cipient <rcipient@example.com>\$"hdrs2&&grep"^Cc: S E Cipient <scipient@example.com>\$"hdrs2'
@@ -136,7 +136,7 @@ test_expect_success 'extra headers without newlines' 'gitconfig--replace-allformat.headers"To: R E Cipient <rcipient@example.com>"&&gitconfig--addformat.headers"Cc: S E Cipient <scipient@example.com>"&&gitformat-patch--stdoutmaster..side>patch3&&-sed-e"/^\$/q"patch3>hdrs3&&+sed-e"/^\$/q"patch3>hdrs3&&grep"^To: R E Cipient <rcipient@example.com>\$"hdrs3&&grep"^Cc: S E Cipient <scipient@example.com>\$"hdrs3'
@@ -144,8 +144,8 @@ test_expect_success 'extra headers without newlines' ' test_expect_success'extra headers with multiple To:s''gitconfig--replace-allformat.headers"To: R E Cipient <rcipient@example.com>"&&gitconfig--addformat.headers"To: S E Cipient <scipient@example.com>"&&-gitformat-patch--stdoutmaster..side>patch4&&-sed-e"/^\$/q"patch4>hdrs4&&+gitformat-patch--stdoutmaster..side>patch4&&+sed-e"/^\$/q"patch4>hdrs4&&grep"^To: R E Cipient <rcipient@example.com>,\$"hdrs4&&grep"^ *S E Cipient <scipient@example.com>\$"hdrs4'
@@ -318,7 +318,7 @@ test_expect_success 'reroll count (-v)' ' check_threading(){expect="$1"&&shift&&-(gitformat-patch--stdout"$@";echo$?>status.out)|+(gitformat-patch--stdout"$@";echo$?>status.out)|# Prints everything between the Message-ID and In-Reply-To,# and replaces all Message-ID-lookalikes by a sequence numberperl-ne'
@@ -689,7 +689,7 @@ test_expect_success 'format-patch from a subdirectory (3)' '' test_expect_success'format-patch --in-reply-to''-gitformat-patch-1--stdout--in-reply-to"baz@foo.bar">patch8&&+gitformat-patch-1--stdout--in-reply-to"baz@foo.bar">patch8&&grep"^In-Reply-To: <baz@foo.bar>"patch8&&grep"^References: <baz@foo.bar>"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_failgitformat-patch--name-only2>output&&+test_must_failgitformat-patch--name-only2>output&&test_i18ncmpexpect.name-onlyoutput&&-test_must_failgitformat-patch--name-status2>output&&+test_must_failgitformat-patch--name-status2>output&&test_i18ncmpexpect.name-statusoutput&&-test_must_failgitformat-patch--check2>output&&+test_must_failgitformat-patch--check2>output&&test_i18ncmpexpect.checkoutput' test_expect_success'format-patch --numstat should produce a patch''-gitformat-patch--numstat--stdoutmaster..side>output&&+gitformat-patch--numstat--stdoutmaster..side>output&&test5=$(grep"^diff --git a/"output|wc-l)'
From: Denton Liu <hidden> Date: 2019-08-24 08:27:06
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 368 ++++++++++++++++++++--------------------
1 file changed, 184 insertions(+), 184 deletions(-)
@@ -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:COMitter<committer@example.com>-EOF+cat<<-\EOF | sed "s/EOL$//" >expect &&+4:Subject:[PATCH]EOL+8:+9:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' test_expect_success'signoff: commit with only subject''echosubject|append_signoff>actual&&-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-9:Signed-off-by:COMitter<committer@example.com>-EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+9:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' test_expect_success'signoff: commit with only subject that does not end with NL''printfsubject|append_signoff>actual&&-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-9:Signed-off-by:COMitter<committer@example.com>-EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+9:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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:COMitter<committer@example.com>-EOF+body+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+11:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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:COMitter<committer@example.com>-EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+11:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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:COMitter<committer@example.com>-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:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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-(cherrypickedfromcommitda39a3ee5e6b4b0d3255bfef95601890afd80709)-Tested-by:SomeOne<someone@example.com>-Bug:1234-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-10:-11:Signed-off-by:my@house-15:Signed-off-by:COMitter<committer@example.com>-EOF+Signed-off-by:my@house+(cherrypickedfromcommitda39a3ee5e6b4b0d3255bfef95601890afd80709)+Tested-by:SomeOne<someone@example.com>+Bug:1234+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+11:Signed-off-by:my@house+15:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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:COMitter<committer@example.com>-EOF+body+Fooled-by-me:my@house+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+11:+12:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' test_expect_success'signoff: not really a signoff''-append_signoff<<\EOF>actual&&-subject+append_signoff<<-\EOF>actual&&+subject-IwanttomentionaboutSigned-off-by:here.-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-9:IwanttomentionaboutSigned-off-by:here.-10:-11:Signed-off-by:COMitter<committer@example.com>-EOF+IwanttomentionaboutSigned-off-by:here.+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+9:IwanttomentionaboutSigned-off-by:here.+10:+11:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' test_expect_success'signoff: not really a signoff (2)''-append_signoff<<\EOF>actual&&-subject+append_signoff<<-\EOF>actual&&+subject-Myunfortunate-Signed-off-by:examplehappenstobewrappedhere.-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-10:Signed-off-by:examplehappenstobewrappedhere.-11:Signed-off-by:COMitter<committer@example.com>-EOF+Myunfortunate+Signed-off-by:examplehappenstobewrappedhere.+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:Signed-off-by:examplehappenstobewrappedhere.+11:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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-Alotofhouses.-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:COMitter<committer@example.com>-EOF+Alotofhouses.+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:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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:COMitter<committer@example.com>-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-10:-11:Signed-off-by:COMitter<committer@example.com>-EOF+Signed-off-by:COMitter<committer@example.com>+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+11:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' test_expect_success'signoff: the same signoff at the end, no trailing NL''printf"subject\n\nSigned-off-by: C O Mitter <committer@example.com>"|append_signoff>actual&&-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-9:Signed-off-by:COMitter<committer@example.com>-EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+9:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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:COMitter<committer@example.com>-Signed-off-by:my@house-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-10:-11:Signed-off-by:COMitter<committer@example.com>-12:Signed-off-by:my@house-EOF+Signed-off-by:COMitter<committer@example.com>+Signed-off-by:my@house+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+11:Signed-off-by:COMitter<committer@example.com>+12:Signed-off-by:my@house+EOFtest_cmpexpectactual' 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-SomeTrash-Signed-off-by:COMitter<committer@example.com>-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-10:-13:Signed-off-by:COMitter<committer@example.com>-EOF+Tested-by:my@house+SomeTrash+Signed-off-by:COMitter<committer@example.com>+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+13:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' test_expect_success'signoff: respect trailer config''-append_signoff<<\EOF>actual&&-subject+append_signoff<<-\EOF>actual&&+subject-Myfooter:x-SomeTrash-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-11:-12:Signed-off-by:COMitter<committer@example.com>-EOF+Myfooter:x+SomeTrash+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+11:+12:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual&&test_configtrailer.Myfooter.ifexistsadd&&-append_signoff<<\EOF>actual&&-subject+append_signoff<<-\EOF>actual&&+subject-Myfooter:x-SomeTrash-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-11:Signed-off-by:COMitter<committer@example.com>-EOF+Myfooter:x+SomeTrash+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+11:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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:COMitter<committer@example.com>-Bug:1234-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-10:-14:Signed-off-by:COMitter<committer@example.com>-EOF+Reviewed-id:Noone+Tested-by:my@house+Change-id:Ideadbeef+Signed-off-by:COMitter<committer@example.com>+Bug:1234+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+14:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual'
From: Denton Liu <hidden> Date: 2019-08-24 08:27:08
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
@@ -1502,42 +1502,42 @@ test_expect_success 'cover letter using branch description (1)' 'gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&gitformat-patch--stdout--cover-lettermaster>actual&&-grephelloactual>/dev/null+grephelloactual' test_expect_success'cover letter using branch description (2)''gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&gitformat-patch--stdout--cover-letterrebuild-1~2..rebuild-1>actual&&-grephelloactual>/dev/null+grephelloactual' test_expect_success'cover letter using branch description (3)''gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&gitformat-patch--stdout--cover-letter^masterrebuild-1>actual&&-grephelloactual>/dev/null+grephelloactual' test_expect_success'cover letter using branch description (4)''gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&gitformat-patch--stdout--cover-lettermaster..>actual&&-grephelloactual>/dev/null+grephelloactual' test_expect_success'cover letter using branch description (5)''gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&gitformat-patch--stdout--cover-letter-2HEAD>actual&&-grephelloactual>/dev/null+grephelloactual' test_expect_success'cover letter using branch description (6)''gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&gitformat-patch--stdout--cover-letter-2>actual&&-grephelloactual>/dev/null+grephelloactual' test_expect_success'cover letter with nothing''
From: Denton Liu <hidden> Date: 2019-08-24 08:27:11
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
@@ -596,7 +596,7 @@ EOF test_expect_success'shortlog of cover-letter wraps overly-long onelines''gitformat-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_cmpexpectoutput'
From: Denton Liu <hidden> Date: 2019-08-24 08:27:14
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 35 +++++++++++++++++++----------------
1 file changed, 19 insertions(+), 16 deletions(-)
@@ -90,22 +90,23 @@ test_expect_success "format-patch doesn't consider merge commits" 'gitcheckout-bmergermaster&&test_tick&&gitmerge--no-ffslave&&-cnt=$(gitformat-patch-3--stdout|grep"^From "|wc-l)&&-test$cnt=3+gitformat-patch-3--stdout>patch&&+grep"^From "patch>from&&+test_line_count=3from' test_expect_success'format-patch result applies''gitcheckout-brebuild-0master&&gitam-3patch0&&-cnt=$(gitrev-listmaster..|wc-l)&&-test$cnt=2+gitrev-listmaster..>list&&+test_line_count=2list' test_expect_success'format-patch --ignore-if-in-upstream result applies''gitcheckout-brebuild-1master&&gitam-3patch1&&-cnt=$(gitrev-listmaster..|wc-l)&&-test$cnt=2+gitrev-listmaster..>list&&+test_line_count=2list' 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''gitformat-patch--numstat--stdoutmaster..side>output&&-test5=$(grep"^diff --git a/"output|wc-l)+grep"^diff --git a/"output>diff&&+test_line_count=5diff' test_expect_success'format-patch -- <path>''
From: Denton Liu <hidden> Date: 2019-08-24 08:27:16
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
@@ -319,7 +319,7 @@ test_expect_success 'reroll count (-v)' ' check_threading(){expect="$1"&&shift&&-(gitformat-patch--stdout"$@";echo$?>status.out)|+gitformat-patch--stdout"$@">patch&&# Prints everything between the Message-ID and In-Reply-To,# and replaces all Message-ID-lookalikes by a sequence numberperl-ne'
From: Denton Liu <hidden> Date: 2019-08-24 08:27:18
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 197 ++++++++++++++++++++++++----------------
1 file changed, 120 insertions(+), 77 deletions(-)
@@ -33,7 +33,8 @@ test_expect_success setup 'gitcommit-m"Side changes #3 with \\n backslash-n in it."&&gitcheckoutmaster&&-gitdiff-tree-pC2|gitapply--index&&+gitdiff-tree-pC2>patch&&+gitapply--index<patch&&test_tick&&gitcommit-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''-gitcat-filecommitside|grep"^Side .* with .* backslash-n"+gitcat-filecommitside>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''-gitcat-filecommitrebuild-1|grep"^Side .* with .* backslash-n"+gitcat-filecommitrebuild-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)''gitconfig--replace-allformat.headers"Cc: R E Cipient <rcipient@example.com>"&&-gitformat-patch--cc="S E Cipient <scipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch5&&-grep"^Cc: R E Cipient <rcipient@example.com>,\$"patch5&&-grep"^ *S E Cipient <scipient@example.com>\$"patch5+gitformat-patch--cc="S E Cipient <scipient@example.com>"--stdoutmaster..side>patch5&&+sed-e"/^\$/q"patch5>hdrs5&&+grep"^Cc: R E Cipient <rcipient@example.com>,\$"hdrs5&&+grep"^ *S E Cipient <scipient@example.com>\$"hdrs5' test_expect_failure'additional command line cc (rfc822)''gitconfig--replace-allformat.headers"Cc: R E Cipient <rcipient@example.com>"&&-gitformat-patch--cc="S. E. Cipient <scipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch5&&-grep"^Cc: R E Cipient <rcipient@example.com>,\$"patch5&&-grep"^ *\"S. E. Cipient\" <scipient@example.com>\$"patch5+gitformat-patch--cc="S. E. Cipient <scipient@example.com>"--stdoutmaster..side>patch5&&+sed-e"/^\$/q"patch5>hdrs5&&+grep"^Cc: R E Cipient <rcipient@example.com>,\$"hdrs5&&+grep"^ *\"S. E. Cipient\" <scipient@example.com>\$"hdrs5' test_expect_success'command line headers''gitconfig--unset-allformat.headers&&-gitformat-patch--add-header="Cc: R E Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch6&&-grep"^Cc: R E Cipient <rcipient@example.com>\$"patch6+gitformat-patch--add-header="Cc: R E Cipient <rcipient@example.com>"--stdoutmaster..side>patch6&&+sed-e"/^\$/q"patch6>hdrs6&&+grep"^Cc: R E Cipient <rcipient@example.com>\$"hdrs6' test_expect_success'configuration headers and command line headers''gitconfig--replace-allformat.headers"Cc: R E Cipient <rcipient@example.com>"&&-gitformat-patch--add-header="Cc: S E Cipient <scipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch7&&-grep"^Cc: R E Cipient <rcipient@example.com>,\$"patch7&&-grep"^ *S E Cipient <scipient@example.com>\$"patch7+gitformat-patch--add-header="Cc: S E Cipient <scipient@example.com>"--stdoutmaster..side>patch7&&+sed-e"/^\$/q"patch7>hdrs7&&+grep"^Cc: R E Cipient <rcipient@example.com>,\$"hdrs7&&+grep"^ *S E Cipient <scipient@example.com>\$"hdrs7' test_expect_success'command line To: header (ascii)''gitconfig--unset-allformat.headers&&-gitformat-patch--to="R E Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch8&&-grep"^To: R E Cipient <rcipient@example.com>\$"patch8+gitformat-patch--to="R E Cipient <rcipient@example.com>"--stdoutmaster..side>patch8&&+sed-e"/^\$/q"patch8>hdrs8&&+grep"^To: R E Cipient <rcipient@example.com>\$"hdrs8' test_expect_failure'command line To: header (rfc822)''-gitformat-patch--to="R. E. Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch8&&-grep"^To: \"R. E. Cipient\" <rcipient@example.com>\$"patch8+gitformat-patch--to="R. E. Cipient <rcipient@example.com>"--stdoutmaster..side>patch8&&+sed-e"/^\$/q"patch8>hdrs8&&+grep"^To: \"R. E. Cipient\" <rcipient@example.com>\$"hdrs8' test_expect_failure'command line To: header (rfc2047)''-gitformat-patch--to="R Ä Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch8&&-grep"^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$"patch8+gitformat-patch--to="R Ä Cipient <rcipient@example.com>"--stdoutmaster..side>patch8&&+sed-e"/^\$/q"patch8>hdrs8&&+grep"^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$"hdrs8' test_expect_success'configuration To: header (ascii)''gitconfigformat.to"R E Cipient <rcipient@example.com>"&&-gitformat-patch--stdoutmaster..side|sed-e"/^\$/q">patch9&&-grep"^To: R E Cipient <rcipient@example.com>\$"patch9+gitformat-patch--stdoutmaster..side>patch9&&+sed-e"/^\$/q"patch9>hdrs9&&+grep"^To: R E Cipient <rcipient@example.com>\$"hdrs9' test_expect_failure'configuration To: header (rfc822)''gitconfigformat.to"R. E. Cipient <rcipient@example.com>"&&-gitformat-patch--stdoutmaster..side|sed-e"/^\$/q">patch9&&-grep"^To: \"R. E. Cipient\" <rcipient@example.com>\$"patch9+gitformat-patch--stdoutmaster..side>patch9&&+sed-e"/^\$/q"patch9>hdrs9&&+grep"^To: \"R. E. Cipient\" <rcipient@example.com>\$"hdrs9' test_expect_failure'configuration To: header (rfc2047)''gitconfigformat.to"R Ä Cipient <rcipient@example.com>"&&-gitformat-patch--stdoutmaster..side|sed-e"/^\$/q">patch9&&-grep"^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$"patch9+gitformat-patch--stdoutmaster..side>patch9&&+sed-e"/^\$/q"patch9>hdrs9&&+grep"^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$"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-cformat.from=falseformat-patch--stdoutmaster..side|-sed-e"/^\$/q">patch&&+git-cformat.from=falseformat-patch--stdoutmaster..side>patch&&+sed-e"/^\$/q"patch>hdrs&&check_patchpatch&&-!grep"^From: C O Mitter <committer@example.com>\$"patch+!grep"^From: C O Mitter <committer@example.com>\$"hdrs' test_expect_success'format.from=true''-git-cformat.from=trueformat-patch--stdoutmaster..side|-sed-e"/^\$/q">patch&&-check_patchpatch&&-grep"^From: C O Mitter <committer@example.com>\$"patch+git-cformat.from=trueformat-patch--stdoutmaster..side>patch&&+sed-e"/^\$/q"patch>hdrs&&+check_patchhdrs&&+grep"^From: C O Mitter <committer@example.com>\$"hdrs' test_expect_success'format.from with address''-git-cformat.from="F R Om <from@example.com>"format-patch--stdoutmaster..side|-sed-e"/^\$/q">patch&&-check_patchpatch&&-grep"^From: F R Om <from@example.com>\$"patch+git-cformat.from="F R Om <from@example.com>"format-patch--stdoutmaster..side>patch&&+sed-e"/^\$/q"patch>hdrs&&+check_patchhdrs&&+grep"^From: F R Om <from@example.com>\$"hdrs' test_expect_success'--no-from overrides format.from''-git-cformat.from="F R Om <from@example.com>"format-patch--no-from--stdoutmaster..side|-sed-e"/^\$/q">patch&&-check_patchpatch&&-!grep"^From: F R Om <from@example.com>\$"patch+git-cformat.from="F R Om <from@example.com>"format-patch--no-from--stdoutmaster..side>patch&&+sed-e"/^\$/q"patch>hdrs&&+check_patchhdrs&&+!grep"^From: F R Om <from@example.com>\$"hdrs' test_expect_success'--from overrides format.from''-git-cformat.from="F R Om <from@example.com>"format-patch--from--stdoutmaster..side|-sed-e"/^\$/q">patch&&-check_patchpatch&&-!grep"^From: F R Om <from@example.com>\$"patch+git-cformat.from="F R Om <from@example.com>"format-patch--from--stdoutmaster..side>patch&&+sed-e"/^\$/q"patch>hdrs&&+check_patchhdrs&&+!grep"^From: F R Om <from@example.com>\$"hdrs' test_expect_success'--no-to overrides config.to''gitconfig--replace-allformat.to\"R E Cipient <rcipient@example.com>"&&-gitformat-patch--no-to--stdoutmaster..side|-sed-e"/^\$/q">patch10&&-check_patchpatch10&&-!grep"^To: R E Cipient <rcipient@example.com>\$"patch10+gitformat-patch--no-to--stdoutmaster..side>patch10&&+sed-e"/^\$/q"patch10>hdrs10&&+check_patchhdrs10&&+!grep"^To: R E Cipient <rcipient@example.com>\$"hdrs10' test_expect_success'--no-to and --to replaces config.to''gitconfig--replace-allformat.to\"Someone <someone@out.there>"&&gitformat-patch--no-to--to="Someone Else <else@out.there>"\---stdoutmaster..side|-sed-e"/^\$/q">patch11&&-check_patchpatch11&&-!grep"^To: Someone <someone@out.there>\$"patch11&&-grep"^To: Someone Else <else@out.there>\$"patch11+--stdoutmaster..side>patch11&&+sed-e"/^\$/q"patch11>hdrs11&&+check_patchhdrs11&&+!grep"^To: Someone <someone@out.there>\$"hdrs11&&+grep"^To: Someone Else <else@out.there>\$"hdrs11' test_expect_success'--no-cc overrides config.cc''gitconfig--replace-allformat.cc\"C E Cipient <rcipient@example.com>"&&-gitformat-patch--no-cc--stdoutmaster..side|-sed-e"/^\$/q">patch12&&-check_patchpatch12&&-!grep"^Cc: C E Cipient <rcipient@example.com>\$"patch12+gitformat-patch--no-cc--stdoutmaster..side>patch12&&+sed-e"/^\$/q"patch12>hdrs12&&+check_patchhdrs12&&+!grep"^Cc: C E Cipient <rcipient@example.com>\$"hdrs12' test_expect_success'--no-add-header overrides config.headers''gitconfig--replace-allformat.headers\"Header1: B E Cipient <rcipient@example.com>"&&-gitformat-patch--no-add-header--stdoutmaster..side|-sed-e"/^\$/q">patch13&&-check_patchpatch13&&-!grep"^Header1: B E Cipient <rcipient@example.com>\$"patch13+gitformat-patch--no-add-header--stdoutmaster..side>patch13&&+sed-e"/^\$/q"patch13>hdrs13&&+check_patchhdrs13&&+!grep"^Header1: B E Cipient <rcipient@example.com>\$"hdrs13' test_expect_success'multiple files''
@@ -1629,7 +1668,8 @@ test_expect_success 'format-patch --base errors out when base commit is in revistest_must_failgitformat-patch--base=HEAD~1-2&&gitformat-patch--stdout--base=HEAD~2-2>patch&&grep"^base-commit:"patch>actual&&-echo"base-commit: $(gitrev-parseHEAD~2)">expect&&+gitrev-parseHEAD~2>commit-id-base&&+echo"base-commit: $(catcommit-id-base)">expect&&test_cmpexpectactual'
From: Denton Liu <hidden> Date: 2019-08-24 08:27:21
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.
Signed-off-by: Denton Liu <redacted>
---
Documentation/git-format-patch.txt | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
@@ -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 ------------
@@ -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
@@ -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.
From: Denton Liu <hidden> Date: 2019-08-24 08:28:20
On Sat, Aug 24, 2019 at 04:25:17AM -0400, Denton Liu wrote:
*** BLURB HERE ***
Whoops, perhaps we also need a configuration option for turning this off
as well ;)
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/xmqqwof3ljcz.fsf@gitster-ct.c.googlers.com/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
--
2.23.0.248.g3a9dd8fb08
From: Eric Sunshine <hidden> Date: 2019-08-26 00:42:39
On Sat, Aug 24, 2019 at 4:27 AM Denton Liu [off-list ref] wrote:
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.
From: Denton Liu <hidden> Date: 2019-08-27 04:04:53
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/xmqqwof3ljcz.fsf@gitster-ct.c.googlers.com/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.
Signed-off-by: Denton Liu [off-list ref]
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
--
2.23.0.248.g3a9dd8fb08
@@ -109,7 +102,6 @@ test_expect_success "format-patch result applies" '' test_expect_success"format-patch --ignore-if-in-upstream result applies"'-gitcheckout-brebuild-1master&&gitam-3patch1&&cnt=$(gitrev-listmaster..|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''-gitcat-filecommitside|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''-gitcat-filecommitrebuild-1|grep"^Side .* with .* backslash-n"-' test_expect_success'extra headers''-gitconfigformat.headers"To: R E Cipient <rcipient@example.com>" &&gitconfig--addformat.headers"Cc: S E Cipient <scipient@example.com>
@@ -145,22 +130,18 @@ test_expect_success 'extra headers' 'sed-e"/^\$/q"patch2>hdrs2&&grep"^To: R E Cipient <rcipient@example.com>\$"hdrs2&&grep"^Cc: S E Cipient <scipient@example.com>\$"hdrs2-' test_expect_success'extra headers without newlines''-gitconfig--replace-allformat.headers"To: R E Cipient <rcipient@example.com>"&&gitconfig--addformat.headers"Cc: S E Cipient <scipient@example.com>"&&gitformat-patch--stdoutmaster..side>patch3&&sed-e"/^\$/q"patch3>hdrs3&&grep"^To: R E Cipient <rcipient@example.com>\$"hdrs3&&grep"^Cc: S E Cipient <scipient@example.com>\$"hdrs3-' test_expect_success'extra headers with multiple To:s''-gitconfig--replace-allformat.headers"To: R E Cipient <rcipient@example.com>"&&gitconfig--addformat.headers"To: S E Cipient <scipient@example.com>"&&gitformat-patch--stdoutmaster..side>patch4&&
@@ -170,7 +151,6 @@ test_expect_success 'extra headers with multiple To:s' '' test_expect_success'additional command line cc (ascii)''-gitconfig--replace-allformat.headers"Cc: R E Cipient <rcipient@example.com>"&&gitformat-patch--cc="S E Cipient <scipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch5&&grep"^Cc: R E Cipient <rcipient@example.com>,\$"patch5&&
@@ -178,7 +158,6 @@ test_expect_success 'additional command line cc (ascii)' '' test_expect_failure'additional command line cc (rfc822)''-gitconfig--replace-allformat.headers"Cc: R E Cipient <rcipient@example.com>"&&gitformat-patch--cc="S. E. Cipient <scipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch5&&grep"^Cc: R E Cipient <rcipient@example.com>,\$"patch5&&
@@ -186,14 +165,12 @@ test_expect_failure 'additional command line cc (rfc822)' '' test_expect_success'command line headers''-gitconfig--unset-allformat.headers&&gitformat-patch--add-header="Cc: R E Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch6&&grep"^Cc: R E Cipient <rcipient@example.com>\$"patch6' test_expect_success'configuration headers and command line headers''-gitconfig--replace-allformat.headers"Cc: R E Cipient <rcipient@example.com>"&&gitformat-patch--add-header="Cc: S E Cipient <scipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch7&&grep"^Cc: R E Cipient <rcipient@example.com>,\$"patch7&&
@@ -201,40 +178,34 @@ test_expect_success 'configuration headers and command line headers' '' test_expect_success'command line To: header (ascii)''-gitconfig--unset-allformat.headers&&gitformat-patch--to="R E Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch8&&grep"^To: R E Cipient <rcipient@example.com>\$"patch8' test_expect_failure'command line To: header (rfc822)''-gitformat-patch--to="R. E. Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch8&&grep"^To: \"R. E. Cipient\" <rcipient@example.com>\$"patch8' test_expect_failure'command line To: header (rfc2047)''-gitformat-patch--to="R Ä Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch8&&grep"^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$"patch8' test_expect_success'configuration To: header (ascii)''-gitconfigformat.to"R E Cipient <rcipient@example.com>"&&gitformat-patch--stdoutmaster..side|sed-e"/^\$/q">patch9&&grep"^To: R E Cipient <rcipient@example.com>\$"patch9' test_expect_failure'configuration To: header (rfc822)''-gitconfigformat.to"R. E. Cipient <rcipient@example.com>"&&gitformat-patch--stdoutmaster..side|sed-e"/^\$/q">patch9&&grep"^To: \"R. E. Cipient\" <rcipient@example.com>\$"patch9' test_expect_failure'configuration To: header (rfc2047)''-gitconfigformat.to"R Ä Cipient <rcipient@example.com>"&&gitformat-patch--stdoutmaster..side|sed-e"/^\$/q">patch9&&grep"^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$"patch9
@@ -265,7 +234,6 @@ test_expect_success 'format.from=true' '' test_expect_success'format.from with address''-git-cformat.from="F R Om <from@example.com>"format-patch--stdoutmaster..side|sed-e"/^\$/q">patch&&check_patchpatch&&
@@ -273,7 +241,6 @@ test_expect_success 'format.from with address' '' test_expect_success'--no-from overrides format.from''-git-cformat.from="F R Om <from@example.com>"format-patch--no-from--stdoutmaster..side|sed-e"/^\$/q">patch&&check_patchpatch&&
@@ -281,7 +248,6 @@ test_expect_success '--no-from overrides format.from' '' test_expect_success'--from overrides format.from''-git-cformat.from="F R Om <from@example.com>"format-patch--from--stdoutmaster..side|sed-e"/^\$/q">patch&&check_patchpatch&&
From: Denton Liu <hidden> Date: 2019-08-27 04:04:58
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 106 ++++++++++++++++++++--------------------
1 file changed, 53 insertions(+), 53 deletions(-)
@@ -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]EOL8:9:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: commit with only subject''echosubject|append_signoff>actual&&-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:9:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: commit with only subject that does not end with NL''printfsubject|append_signoff>actual&&-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:9:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: no existing signoffs''
@@ -1243,24 +1243,24 @@ subject body EOF-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:10:11:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' 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]subject8:10:11:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: some random signoff''
@@ -1292,14 +1292,14 @@ Signed-off-by: my@house Tested-by:SomeOne<someone@example.com> Bug:1234 EOF-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:10:11:Signed-off-by:my@house15:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' 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]subject8:11:12:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: not really a signoff''
@@ -1324,14 +1324,14 @@ subject IwanttomentionaboutSigned-off-by:here. EOF-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:9:IwanttomentionaboutSigned-off-by:here.10:11:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: not really a signoff (2)''
@@ -1341,13 +1341,13 @@ subject Myunfortunate Signed-off-by:examplehappenstobewrappedhere. EOF-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:10:Signed-off-by:examplehappenstobewrappedhere.11:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: valid S-o-b paragraph in the middle''
@@ -1368,7 +1368,7 @@ EOF13:14:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: the same signoff at the end''
@@ -1379,24 +1379,24 @@ body Signed-off-by:COMitter<committer@example.com> EOF-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:10:11:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: the same signoff at the end, no trailing NL''printf"subject\n\nSigned-off-by: C O Mitter <committer@example.com>"|append_signoff>actual&&-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:9:Signed-off-by:COMitter<committer@example.com> EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: the same signoff NOT at the end''
@@ -1408,14 +1408,14 @@ body Signed-off-by:COMitter<committer@example.com> Signed-off-by:my@house EOF-cat>expected<<\EOF&&+cat>expect<<\EOF&&4:Subject:[PATCH]subject8:10:11:Signed-off-by:COMitter<committer@example.com>12:Signed-off-by:my@house EOF-test_cmpexpectedactual+test_cmpexpectactual' test_expect_success'signoff: tolerate garbage in conforming footer''
@@ -1625,8 +1625,8 @@ test_expect_success 'format-patch --base errors out when base commit is in revistest_must_failgitformat-patch--base=HEAD~1-2&&gitformat-patch--stdout--base=HEAD~2-2>patch&&grep"^base-commit:"patch>actual&&-echo"base-commit: $(gitrev-parseHEAD~2)">expected&&-test_cmpexpectedactual+echo"base-commit: $(gitrev-parseHEAD~2)">expect&&+test_cmpexpectactual' 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 ancetest_must_failgitformat-patch--base=$(catcommit-id-Z)-3&&gitformat-patch--stdout--base=$(catcommit-id-base)-3>patch&&grep"^base-commit:"patch>actual&&-echo"base-commit: $(catcommit-id-base)">expected&&-test_cmpexpectedactual+echo"base-commit: $(catcommit-id-base)">expect&&+test_cmpexpectactual' test_expect_success'format-patch --base=auto''
@@ -1664,8 +1664,8 @@ test_expect_success 'format-patch --base=auto' 'test_commitN2&&gitformat-patch--stdout--base=auto-2>patch&&grep"^base-commit:"patch>actual&&-echo"base-commit: $(gitrev-parseupstream)">expected&&-test_cmpexpectedactual+echo"base-commit: $(gitrev-parseupstream)">expect&&+test_cmpexpectactual' test_expect_success'format-patch errors out when history involves criss-cross''
From: Denton Liu <hidden> Date: 2019-08-27 04:05:00
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
@@ -790,11 +790,13 @@ test_expect_success 'options no longer allowed for format-patch' 'test_must_failgitformat-patch--name-status2>output&&test_i18ncmpexpect.name-statusoutput&&test_must_failgitformat-patch--check2>output&&-test_i18ncmpexpect.checkoutput'+test_i18ncmpexpect.checkoutput+' test_expect_success'format-patch --numstat should produce a patch''gitformat-patch--numstat--stdoutmaster..side>output&&-test5=$(grep"^diff --git a/"output|wc-l)'+test5=$(grep"^diff --git a/"output|wc-l)+' test_expect_success'format-patch -- <path>''gitformat-patchmaster..side--file2>error&&
From: Denton Liu <hidden> Date: 2019-08-27 04:05:03
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
From: Denton Liu <hidden> Date: 2019-08-27 04:05:05
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 62 ++++++++++++++++++++---------------------
1 file changed, 31 insertions(+), 31 deletions(-)
@@ -126,8 +126,8 @@ test_expect_success 'extra headers' '" &&gitconfig--addformat.headers"Cc: S E Cipient <scipient@example.com>" &&-gitformat-patch--stdoutmaster..side>patch2&&-sed-e"/^\$/q"patch2>hdrs2&&+gitformat-patch--stdoutmaster..side>patch2&&+sed-e"/^\$/q"patch2>hdrs2&&grep"^To: R E Cipient <rcipient@example.com>\$"hdrs2&&grep"^Cc: S E Cipient <scipient@example.com>\$"hdrs2'
@@ -136,7 +136,7 @@ test_expect_success 'extra headers without newlines' 'gitconfig--replace-allformat.headers"To: R E Cipient <rcipient@example.com>"&&gitconfig--addformat.headers"Cc: S E Cipient <scipient@example.com>"&&gitformat-patch--stdoutmaster..side>patch3&&-sed-e"/^\$/q"patch3>hdrs3&&+sed-e"/^\$/q"patch3>hdrs3&&grep"^To: R E Cipient <rcipient@example.com>\$"hdrs3&&grep"^Cc: S E Cipient <scipient@example.com>\$"hdrs3'
@@ -144,8 +144,8 @@ test_expect_success 'extra headers without newlines' ' test_expect_success'extra headers with multiple To:s''gitconfig--replace-allformat.headers"To: R E Cipient <rcipient@example.com>"&&gitconfig--addformat.headers"To: S E Cipient <scipient@example.com>"&&-gitformat-patch--stdoutmaster..side>patch4&&-sed-e"/^\$/q"patch4>hdrs4&&+gitformat-patch--stdoutmaster..side>patch4&&+sed-e"/^\$/q"patch4>hdrs4&&grep"^To: R E Cipient <rcipient@example.com>,\$"hdrs4&&grep"^ *S E Cipient <scipient@example.com>\$"hdrs4'
@@ -318,7 +318,7 @@ test_expect_success 'reroll count (-v)' ' check_threading(){expect="$1"&&shift&&-(gitformat-patch--stdout"$@";echo$?>status.out)|+(gitformat-patch--stdout"$@";echo$?>status.out)|# Prints everything between the Message-ID and In-Reply-To,# and replaces all Message-ID-lookalikes by a sequence numberperl-ne'
@@ -689,7 +689,7 @@ test_expect_success 'format-patch from a subdirectory (3)' '' test_expect_success'format-patch --in-reply-to''-gitformat-patch-1--stdout--in-reply-to"baz@foo.bar">patch8&&+gitformat-patch-1--stdout--in-reply-to"baz@foo.bar">patch8&&grep"^In-Reply-To: <baz@foo.bar>"patch8&&grep"^References: <baz@foo.bar>"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_failgitformat-patch--name-only2>output&&+test_must_failgitformat-patch--name-only2>output&&test_i18ncmpexpect.name-onlyoutput&&-test_must_failgitformat-patch--name-status2>output&&+test_must_failgitformat-patch--name-status2>output&&test_i18ncmpexpect.name-statusoutput&&-test_must_failgitformat-patch--check2>output&&+test_must_failgitformat-patch--check2>output&&test_i18ncmpexpect.checkoutput' test_expect_success'format-patch --numstat should produce a patch''-gitformat-patch--numstat--stdoutmaster..side>output&&+gitformat-patch--numstat--stdoutmaster..side>output&&test5=$(grep"^diff --git a/"output|wc-l)'
From: Denton Liu <hidden> Date: 2019-08-27 04:05:08
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 368 ++++++++++++++++++++--------------------
1 file changed, 184 insertions(+), 184 deletions(-)
@@ -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:COMitter<committer@example.com>-EOF+cat<<-\EOF | sed "s/EOL$//" >expect &&+4:Subject:[PATCH]EOL+8:+9:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' test_expect_success'signoff: commit with only subject''echosubject|append_signoff>actual&&-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-9:Signed-off-by:COMitter<committer@example.com>-EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+9:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' test_expect_success'signoff: commit with only subject that does not end with NL''printfsubject|append_signoff>actual&&-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-9:Signed-off-by:COMitter<committer@example.com>-EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+9:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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:COMitter<committer@example.com>-EOF+body+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+11:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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:COMitter<committer@example.com>-EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+11:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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:COMitter<committer@example.com>-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:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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-(cherrypickedfromcommitda39a3ee5e6b4b0d3255bfef95601890afd80709)-Tested-by:SomeOne<someone@example.com>-Bug:1234-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-10:-11:Signed-off-by:my@house-15:Signed-off-by:COMitter<committer@example.com>-EOF+Signed-off-by:my@house+(cherrypickedfromcommitda39a3ee5e6b4b0d3255bfef95601890afd80709)+Tested-by:SomeOne<someone@example.com>+Bug:1234+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+11:Signed-off-by:my@house+15:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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:COMitter<committer@example.com>-EOF+body+Fooled-by-me:my@house+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+11:+12:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' test_expect_success'signoff: not really a signoff''-append_signoff<<\EOF>actual&&-subject+append_signoff<<-\EOF>actual&&+subject-IwanttomentionaboutSigned-off-by:here.-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-9:IwanttomentionaboutSigned-off-by:here.-10:-11:Signed-off-by:COMitter<committer@example.com>-EOF+IwanttomentionaboutSigned-off-by:here.+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+9:IwanttomentionaboutSigned-off-by:here.+10:+11:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' test_expect_success'signoff: not really a signoff (2)''-append_signoff<<\EOF>actual&&-subject+append_signoff<<-\EOF>actual&&+subject-Myunfortunate-Signed-off-by:examplehappenstobewrappedhere.-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-10:Signed-off-by:examplehappenstobewrappedhere.-11:Signed-off-by:COMitter<committer@example.com>-EOF+Myunfortunate+Signed-off-by:examplehappenstobewrappedhere.+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:Signed-off-by:examplehappenstobewrappedhere.+11:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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-Alotofhouses.-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:COMitter<committer@example.com>-EOF+Alotofhouses.+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:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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:COMitter<committer@example.com>-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-10:-11:Signed-off-by:COMitter<committer@example.com>-EOF+Signed-off-by:COMitter<committer@example.com>+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+11:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' test_expect_success'signoff: the same signoff at the end, no trailing NL''printf"subject\n\nSigned-off-by: C O Mitter <committer@example.com>"|append_signoff>actual&&-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-9:Signed-off-by:COMitter<committer@example.com>-EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+9:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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:COMitter<committer@example.com>-Signed-off-by:my@house-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-10:-11:Signed-off-by:COMitter<committer@example.com>-12:Signed-off-by:my@house-EOF+Signed-off-by:COMitter<committer@example.com>+Signed-off-by:my@house+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+11:Signed-off-by:COMitter<committer@example.com>+12:Signed-off-by:my@house+EOFtest_cmpexpectactual' 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-SomeTrash-Signed-off-by:COMitter<committer@example.com>-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-10:-13:Signed-off-by:COMitter<committer@example.com>-EOF+Tested-by:my@house+SomeTrash+Signed-off-by:COMitter<committer@example.com>+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+13:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' test_expect_success'signoff: respect trailer config''-append_signoff<<\EOF>actual&&-subject+append_signoff<<-\EOF>actual&&+subject-Myfooter:x-SomeTrash-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-11:-12:Signed-off-by:COMitter<committer@example.com>-EOF+Myfooter:x+SomeTrash+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+11:+12:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual&&test_configtrailer.Myfooter.ifexistsadd&&-append_signoff<<\EOF>actual&&-subject+append_signoff<<-\EOF>actual&&+subject-Myfooter:x-SomeTrash-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-11:Signed-off-by:COMitter<committer@example.com>-EOF+Myfooter:x+SomeTrash+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+11:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual' 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:COMitter<committer@example.com>-Bug:1234-EOF-cat>expect<<\EOF&&-4:Subject:[PATCH]subject-8:-10:-14:Signed-off-by:COMitter<committer@example.com>-EOF+Reviewed-id:Noone+Tested-by:my@house+Change-id:Ideadbeef+Signed-off-by:COMitter<committer@example.com>+Bug:1234+EOF+cat>expect<<-\EOF&&+4:Subject:[PATCH]subject+8:+10:+14:Signed-off-by:COMitter<committer@example.com>+EOFtest_cmpexpectactual'
From: Denton Liu <hidden> Date: 2019-08-27 04:05:10
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
@@ -1502,42 +1502,42 @@ test_expect_success 'cover letter using branch description (1)' 'gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&gitformat-patch--stdout--cover-lettermaster>actual&&-grephelloactual>/dev/null+grephelloactual' test_expect_success'cover letter using branch description (2)''gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&gitformat-patch--stdout--cover-letterrebuild-1~2..rebuild-1>actual&&-grephelloactual>/dev/null+grephelloactual' test_expect_success'cover letter using branch description (3)''gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&gitformat-patch--stdout--cover-letter^masterrebuild-1>actual&&-grephelloactual>/dev/null+grephelloactual' test_expect_success'cover letter using branch description (4)''gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&gitformat-patch--stdout--cover-lettermaster..>actual&&-grephelloactual>/dev/null+grephelloactual' test_expect_success'cover letter using branch description (5)''gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&gitformat-patch--stdout--cover-letter-2HEAD>actual&&-grephelloactual>/dev/null+grephelloactual' test_expect_success'cover letter using branch description (6)''gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&gitformat-patch--stdout--cover-letter-2>actual&&-grephelloactual>/dev/null+grephelloactual' test_expect_success'cover letter with nothing''
From: Denton Liu <hidden> Date: 2019-08-27 04:05:13
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
@@ -596,7 +596,7 @@ EOF test_expect_success'shortlog of cover-letter wraps overly-long onelines''gitformat-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_cmpexpectoutput'
From: Denton Liu <hidden> Date: 2019-08-27 04:05:15
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 35 +++++++++++++++++++----------------
1 file changed, 19 insertions(+), 16 deletions(-)
@@ -90,22 +90,23 @@ test_expect_success "format-patch doesn't consider merge commits" 'gitcheckout-bmergermaster&&test_tick&&gitmerge--no-ffslave&&-cnt=$(gitformat-patch-3--stdout|grep"^From "|wc-l)&&-test$cnt=3+gitformat-patch-3--stdout>patch&&+grep"^From "patch>from&&+test_line_count=3from' test_expect_success'format-patch result applies''gitcheckout-brebuild-0master&&gitam-3patch0&&-cnt=$(gitrev-listmaster..|wc-l)&&-test$cnt=2+gitrev-listmaster..>list&&+test_line_count=2list' test_expect_success'format-patch --ignore-if-in-upstream result applies''gitcheckout-brebuild-1master&&gitam-3patch1&&-cnt=$(gitrev-listmaster..|wc-l)&&-test$cnt=2+gitrev-listmaster..>list&&+test_line_count=2list' 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''gitformat-patch--numstat--stdoutmaster..side>output&&-test5=$(grep"^diff --git a/"output|wc-l)+grep"^diff --git a/"output>diff&&+test_line_count=5diff' test_expect_success'format-patch -- <path>''
From: Denton Liu <hidden> Date: 2019-08-27 04:05:17
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
@@ -319,7 +319,7 @@ test_expect_success 'reroll count (-v)' ' check_threading(){expect="$1"&&shift&&-(gitformat-patch--stdout"$@";echo$?>status.out)|+gitformat-patch--stdout"$@">patch&&# Prints everything between the Message-ID and In-Reply-To,# and replaces all Message-ID-lookalikes by a sequence numberperl-ne'
From: Denton Liu <hidden> Date: 2019-08-27 04:05:20
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.
Signed-off-by: Denton Liu <redacted>
---
t/t4014-format-patch.sh | 197 ++++++++++++++++++++++++----------------
1 file changed, 120 insertions(+), 77 deletions(-)
@@ -33,7 +33,8 @@ test_expect_success setup 'gitcommit-m"Side changes #3 with \\n backslash-n in it."&&gitcheckoutmaster&&-gitdiff-tree-pC2|gitapply--index&&+gitdiff-tree-pC2>patch&&+gitapply--index<patch&&test_tick&&gitcommit-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''-gitcat-filecommitside|grep"^Side .* with .* backslash-n"+gitcat-filecommitside>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''-gitcat-filecommitrebuild-1|grep"^Side .* with .* backslash-n"+gitcat-filecommitrebuild-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)''gitconfig--replace-allformat.headers"Cc: R E Cipient <rcipient@example.com>"&&-gitformat-patch--cc="S E Cipient <scipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch5&&-grep"^Cc: R E Cipient <rcipient@example.com>,\$"patch5&&-grep"^ *S E Cipient <scipient@example.com>\$"patch5+gitformat-patch--cc="S E Cipient <scipient@example.com>"--stdoutmaster..side>patch5&&+sed-e"/^\$/q"patch5>hdrs5&&+grep"^Cc: R E Cipient <rcipient@example.com>,\$"hdrs5&&+grep"^ *S E Cipient <scipient@example.com>\$"hdrs5' test_expect_failure'additional command line cc (rfc822)''gitconfig--replace-allformat.headers"Cc: R E Cipient <rcipient@example.com>"&&-gitformat-patch--cc="S. E. Cipient <scipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch5&&-grep"^Cc: R E Cipient <rcipient@example.com>,\$"patch5&&-grep"^ *\"S. E. Cipient\" <scipient@example.com>\$"patch5+gitformat-patch--cc="S. E. Cipient <scipient@example.com>"--stdoutmaster..side>patch5&&+sed-e"/^\$/q"patch5>hdrs5&&+grep"^Cc: R E Cipient <rcipient@example.com>,\$"hdrs5&&+grep"^ *\"S. E. Cipient\" <scipient@example.com>\$"hdrs5' test_expect_success'command line headers''gitconfig--unset-allformat.headers&&-gitformat-patch--add-header="Cc: R E Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch6&&-grep"^Cc: R E Cipient <rcipient@example.com>\$"patch6+gitformat-patch--add-header="Cc: R E Cipient <rcipient@example.com>"--stdoutmaster..side>patch6&&+sed-e"/^\$/q"patch6>hdrs6&&+grep"^Cc: R E Cipient <rcipient@example.com>\$"hdrs6' test_expect_success'configuration headers and command line headers''gitconfig--replace-allformat.headers"Cc: R E Cipient <rcipient@example.com>"&&-gitformat-patch--add-header="Cc: S E Cipient <scipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch7&&-grep"^Cc: R E Cipient <rcipient@example.com>,\$"patch7&&-grep"^ *S E Cipient <scipient@example.com>\$"patch7+gitformat-patch--add-header="Cc: S E Cipient <scipient@example.com>"--stdoutmaster..side>patch7&&+sed-e"/^\$/q"patch7>hdrs7&&+grep"^Cc: R E Cipient <rcipient@example.com>,\$"hdrs7&&+grep"^ *S E Cipient <scipient@example.com>\$"hdrs7' test_expect_success'command line To: header (ascii)''gitconfig--unset-allformat.headers&&-gitformat-patch--to="R E Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch8&&-grep"^To: R E Cipient <rcipient@example.com>\$"patch8+gitformat-patch--to="R E Cipient <rcipient@example.com>"--stdoutmaster..side>patch8&&+sed-e"/^\$/q"patch8>hdrs8&&+grep"^To: R E Cipient <rcipient@example.com>\$"hdrs8' test_expect_failure'command line To: header (rfc822)''-gitformat-patch--to="R. E. Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch8&&-grep"^To: \"R. E. Cipient\" <rcipient@example.com>\$"patch8+gitformat-patch--to="R. E. Cipient <rcipient@example.com>"--stdoutmaster..side>patch8&&+sed-e"/^\$/q"patch8>hdrs8&&+grep"^To: \"R. E. Cipient\" <rcipient@example.com>\$"hdrs8' test_expect_failure'command line To: header (rfc2047)''-gitformat-patch--to="R Ä Cipient <rcipient@example.com>"--stdoutmaster..side|sed-e"/^\$/q">patch8&&-grep"^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$"patch8+gitformat-patch--to="R Ä Cipient <rcipient@example.com>"--stdoutmaster..side>patch8&&+sed-e"/^\$/q"patch8>hdrs8&&+grep"^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$"hdrs8' test_expect_success'configuration To: header (ascii)''gitconfigformat.to"R E Cipient <rcipient@example.com>"&&-gitformat-patch--stdoutmaster..side|sed-e"/^\$/q">patch9&&-grep"^To: R E Cipient <rcipient@example.com>\$"patch9+gitformat-patch--stdoutmaster..side>patch9&&+sed-e"/^\$/q"patch9>hdrs9&&+grep"^To: R E Cipient <rcipient@example.com>\$"hdrs9' test_expect_failure'configuration To: header (rfc822)''gitconfigformat.to"R. E. Cipient <rcipient@example.com>"&&-gitformat-patch--stdoutmaster..side|sed-e"/^\$/q">patch9&&-grep"^To: \"R. E. Cipient\" <rcipient@example.com>\$"patch9+gitformat-patch--stdoutmaster..side>patch9&&+sed-e"/^\$/q"patch9>hdrs9&&+grep"^To: \"R. E. Cipient\" <rcipient@example.com>\$"hdrs9' test_expect_failure'configuration To: header (rfc2047)''gitconfigformat.to"R Ä Cipient <rcipient@example.com>"&&-gitformat-patch--stdoutmaster..side|sed-e"/^\$/q">patch9&&-grep"^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$"patch9+gitformat-patch--stdoutmaster..side>patch9&&+sed-e"/^\$/q"patch9>hdrs9&&+grep"^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$"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-cformat.from=falseformat-patch--stdoutmaster..side|-sed-e"/^\$/q">patch&&+git-cformat.from=falseformat-patch--stdoutmaster..side>patch&&+sed-e"/^\$/q"patch>hdrs&&check_patchpatch&&-!grep"^From: C O Mitter <committer@example.com>\$"patch+!grep"^From: C O Mitter <committer@example.com>\$"hdrs' test_expect_success'format.from=true''-git-cformat.from=trueformat-patch--stdoutmaster..side|-sed-e"/^\$/q">patch&&-check_patchpatch&&-grep"^From: C O Mitter <committer@example.com>\$"patch+git-cformat.from=trueformat-patch--stdoutmaster..side>patch&&+sed-e"/^\$/q"patch>hdrs&&+check_patchhdrs&&+grep"^From: C O Mitter <committer@example.com>\$"hdrs' test_expect_success'format.from with address''-git-cformat.from="F R Om <from@example.com>"format-patch--stdoutmaster..side|-sed-e"/^\$/q">patch&&-check_patchpatch&&-grep"^From: F R Om <from@example.com>\$"patch+git-cformat.from="F R Om <from@example.com>"format-patch--stdoutmaster..side>patch&&+sed-e"/^\$/q"patch>hdrs&&+check_patchhdrs&&+grep"^From: F R Om <from@example.com>\$"hdrs' test_expect_success'--no-from overrides format.from''-git-cformat.from="F R Om <from@example.com>"format-patch--no-from--stdoutmaster..side|-sed-e"/^\$/q">patch&&-check_patchpatch&&-!grep"^From: F R Om <from@example.com>\$"patch+git-cformat.from="F R Om <from@example.com>"format-patch--no-from--stdoutmaster..side>patch&&+sed-e"/^\$/q"patch>hdrs&&+check_patchhdrs&&+!grep"^From: F R Om <from@example.com>\$"hdrs' test_expect_success'--from overrides format.from''-git-cformat.from="F R Om <from@example.com>"format-patch--from--stdoutmaster..side|-sed-e"/^\$/q">patch&&-check_patchpatch&&-!grep"^From: F R Om <from@example.com>\$"patch+git-cformat.from="F R Om <from@example.com>"format-patch--from--stdoutmaster..side>patch&&+sed-e"/^\$/q"patch>hdrs&&+check_patchhdrs&&+!grep"^From: F R Om <from@example.com>\$"hdrs' test_expect_success'--no-to overrides config.to''gitconfig--replace-allformat.to\"R E Cipient <rcipient@example.com>"&&-gitformat-patch--no-to--stdoutmaster..side|-sed-e"/^\$/q">patch10&&-check_patchpatch10&&-!grep"^To: R E Cipient <rcipient@example.com>\$"patch10+gitformat-patch--no-to--stdoutmaster..side>patch10&&+sed-e"/^\$/q"patch10>hdrs10&&+check_patchhdrs10&&+!grep"^To: R E Cipient <rcipient@example.com>\$"hdrs10' test_expect_success'--no-to and --to replaces config.to''gitconfig--replace-allformat.to\"Someone <someone@out.there>"&&gitformat-patch--no-to--to="Someone Else <else@out.there>"\---stdoutmaster..side|-sed-e"/^\$/q">patch11&&-check_patchpatch11&&-!grep"^To: Someone <someone@out.there>\$"patch11&&-grep"^To: Someone Else <else@out.there>\$"patch11+--stdoutmaster..side>patch11&&+sed-e"/^\$/q"patch11>hdrs11&&+check_patchhdrs11&&+!grep"^To: Someone <someone@out.there>\$"hdrs11&&+grep"^To: Someone Else <else@out.there>\$"hdrs11' test_expect_success'--no-cc overrides config.cc''gitconfig--replace-allformat.cc\"C E Cipient <rcipient@example.com>"&&-gitformat-patch--no-cc--stdoutmaster..side|-sed-e"/^\$/q">patch12&&-check_patchpatch12&&-!grep"^Cc: C E Cipient <rcipient@example.com>\$"patch12+gitformat-patch--no-cc--stdoutmaster..side>patch12&&+sed-e"/^\$/q"patch12>hdrs12&&+check_patchhdrs12&&+!grep"^Cc: C E Cipient <rcipient@example.com>\$"hdrs12' test_expect_success'--no-add-header overrides config.headers''gitconfig--replace-allformat.headers\"Header1: B E Cipient <rcipient@example.com>"&&-gitformat-patch--no-add-header--stdoutmaster..side|-sed-e"/^\$/q">patch13&&-check_patchpatch13&&-!grep"^Header1: B E Cipient <rcipient@example.com>\$"patch13+gitformat-patch--no-add-header--stdoutmaster..side>patch13&&+sed-e"/^\$/q"patch13>hdrs13&&+check_patchhdrs13&&+!grep"^Header1: B E Cipient <rcipient@example.com>\$"hdrs13' test_expect_success'multiple files''
@@ -1629,7 +1668,8 @@ test_expect_success 'format-patch --base errors out when base commit is in revistest_must_failgitformat-patch--base=HEAD~1-2&&gitformat-patch--stdout--base=HEAD~2-2>patch&&grep"^base-commit:"patch>actual&&-echo"base-commit: $(gitrev-parseHEAD~2)">expect&&+gitrev-parseHEAD~2>commit-id-base&&+echo"base-commit: $(catcommit-id-base)">expect&&test_cmpexpectactual'
From: Denton Liu <hidden> Date: 2019-08-27 04:05:22
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.
Signed-off-by: Denton Liu <redacted>
---
Documentation/git-format-patch.txt | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
@@ -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 ------------
@@ -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
From: Denton Liu <hidden> Date: 2019-09-04 11:21:10
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
On Tue, Aug 27, 2019 at 12:04:47AM -0400, Denton Liu wrote:
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/xmqqwof3ljcz.fsf@gitster-ct.c.googlers.com/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.
Signed-off-by: Denton Liu [off-list ref]
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
--
2.23.0.248.g3a9dd8fb08
From: Denton Liu <hidden> Date: 2019-10-11 19:12:54
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(-)
--
2.23.0.17.g7cce04acd6.dirty
From: Denton Liu <hidden> Date: 2019-10-11 19:12:56
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.
Signed-off-by: Denton Liu <redacted>
---
builtin/log.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Denton Liu <hidden> Date: 2019-10-11 19:12:59
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.
Signed-off-by: Denton Liu <redacted>
---
builtin/log.c | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
From: Denton Liu <hidden> Date: 2019-10-11 19:13:01
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).
Signed-off-by: Denton Liu <redacted>
---
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(-)
@@ -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.
@@ -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
@@ -37,6 +37,7 @@#include"range-diff.h"#define MAIL_DEFAULT_WRAP 72+#define COVER_FROM_AUTO_MAX_SUBJECT_LEN 100/* Set a default date-time format for git log ("log.date" config variable) */staticconstchar*default_date_mode=NULL;
@@ -1061,13 +1076,16 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,structcommit*origin,intnr,structcommit**list,constchar*branch_name,+enumcover_from_descriptioncover_from_description_mode,intquiet){constchar*committer;-constchar*body="*** SUBJECT HERE ***\n\n*** BLURB HERE ***\n";-constchar*msg;+constchar*subject="*** SUBJECT HERE ***";+constchar*body="*** BLURB HERE ***";structshortloglog;structstrbufsb=STRBUF_INIT;+structstrbufdescription_sb=STRBUF_INIT;+structstrbufsubject_sb=STRBUF_INIT;inti;constchar*encoding="UTF-8";intneed_8bit_cte=0;
@@ -1581,6 +1617,9 @@ 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_STRING(0,"cover-from-description",&cover_from_description_arg,+N_("cover-from-description-mode"),+N_("generate parts of a cover letter based on a branch's description")),{OPTION_CALLBACK,0,"subject-prefix",&rev,N_("prefix"),N_("Use [<prefix>] instead of [PATCH]"),PARSE_OPT_NONEG,subject_prefix_callback},
@@ -1517,6 +1517,178 @@ test_expect_success 'format patch ignores color.ui' 'test_cmpexpectactual'+test_expect_success'cover letter with invalid --cover-from-description and config''+test_configbranch.rebuild-1.description"config subject++body" &&+test_must_failgitformat-patch--cover-letter--cover-from-descriptiongarbagemaster&&+test_configformat.coverFromDescriptiongarbage&&+test_must_failgitformat-patch--cover-lettermaster+'++test_expect_success'cover letter with format.coverFromDescription = default''+test_configbranch.rebuild-1.description"config subject++body" &&+test_configformat.coverFromDescriptiondefault&&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-lettermaster>actual&&+grep"^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$"actual&&+!grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+grep"^config subject$"actual&&+grep"^body$"actual+'++test_expect_success'cover letter with --cover-from-description default''+test_configbranch.rebuild-1.description"config subject++body" &&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-letter--cover-from-descriptiondefaultmaster>actual&&+grep"^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$"actual&&+!grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+grep"^config subject$"actual&&+grep"^body$"actual+'++test_expect_success'cover letter with format.coverFromDescription = none''+test_configbranch.rebuild-1.description"config subject++body" &&+test_configformat.coverFromDescriptionnone&&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-lettermaster>actual&&+grep"^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$"actual&&+grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+!grep"^config subject$"actual&&+!grep"^body$"actual+'++test_expect_success'cover letter with --cover-from-description none''+test_configbranch.rebuild-1.description"config subject++body" &&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-letter--cover-from-descriptionnonemaster>actual&&+grep"^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$"actual&&+grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+!grep"^config subject$"actual&&+!grep"^body$"actual+'++test_expect_success'cover letter with format.coverFromDescription = message''+test_configbranch.rebuild-1.description"config subject++body" &&+test_configformat.coverFromDescriptionmessage&&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-lettermaster>actual&&+grep"^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$"actual&&+!grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+grep"^config subject$"actual&&+grep"^body$"actual+'++test_expect_success'cover letter with --cover-from-description message''+test_configbranch.rebuild-1.description"config subject++body" &&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-letter--cover-from-descriptionmessagemaster>actual&&+grep"^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$"actual&&+!grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+grep"^config subject$"actual&&+grep"^body$"actual+'++test_expect_success'cover letter with format.coverFromDescription = subject''+test_configbranch.rebuild-1.description"config subject++body" &&+test_configformat.coverFromDescriptionsubject&&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-lettermaster>actual&&+grep"^Subject: \[PATCH 0/2\] config subject$"actual&&+!grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+!grep"^config subject$"actual&&+grep"^body$"actual+'++test_expect_success'cover letter with --cover-from-description subject''+test_configbranch.rebuild-1.description"config subject++body" &&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-letter--cover-from-descriptionsubjectmaster>actual&&+grep"^Subject: \[PATCH 0/2\] config subject$"actual&&+!grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+!grep"^config subject$"actual&&+grep"^body$"actual+'++test_expect_success'cover letter with format.coverFromDescription = auto (short subject line)''+test_configbranch.rebuild-1.description"config subject++body" &&+test_configformat.coverFromDescriptionauto&&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-lettermaster>actual&&+grep"^Subject: \[PATCH 0/2\] config subject$"actual&&+!grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+!grep"^config subject$"actual&&+grep"^body$"actual+'++test_expect_success'cover letter with --cover-from-description auto (short subject line)''+test_configbranch.rebuild-1.description"config subject++body" &&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-letter--cover-from-descriptionautomaster>actual&&+grep"^Subject: \[PATCH 0/2\] config subject$"actual&&+!grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+!grep"^config subject$"actual&&+grep"^body$"actual+'++test_expect_success'cover letter with format.coverFromDescription = auto (long subject line)''+test_configbranch.rebuild-1.description"this is a really long first line and it is over 100 characters long which is the threshold for long subjects++body" &&+test_configformat.coverFromDescriptionauto&&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-lettermaster>actual&&+grep"^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$"actual&&+!grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+grep"^this is a really long first line and it is over 100 characters long which is the threshold for long subjects$"actual&&+grep"^body$"actual+'++test_expect_success'cover letter with --cover-from-description auto (long subject line)''+test_configbranch.rebuild-1.description"this is a really long first line and it is over 100 characters long which is the threshold for long subjects++body" &&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-letter--cover-from-descriptionautomaster>actual&&+grep"^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$"actual&&+!grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+grep"^this is a really long first line and it is over 100 characters long which is the threshold for long subjects$"actual&&+grep"^body$"actual+'++test_expect_success'cover letter with command-line --cover-from-description overrides config''+test_configbranch.rebuild-1.description"config subject++body" &&+test_configformat.coverFromDescriptionnone&&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-letter--cover-from-descriptionsubjectmaster>actual&&+grep"^Subject: \[PATCH 0/2\] config subject$"actual&&+!grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+!grep"^config subject$"actual&&+grep"^body$"actual+'+ test_expect_success'cover letter using branch description (1)''gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&
From: Denton Liu <hidden> Date: 2019-10-14 20:47:01
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 [off-list ref]
## 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: Denton Liu [off-list ref]
- Signed-off-by: Junio C Hamano [off-list ref]
## 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: Denton Liu [off-list ref]
- Signed-off-by: Junio C Hamano [off-list ref]
## 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 [off-list ref]
- Signed-off-by: Junio C Hamano [off-list ref]
-
## 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 "
+ '
+
--
2.23.0.17.g315c308950
From: Denton Liu <hidden> Date: 2019-10-14 20:47:03
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
Signed-off-by: Denton Liu <redacted>
---
builtin/log.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Denton Liu <hidden> Date: 2019-10-14 20:47:06
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.
Signed-off-by: Denton Liu <redacted>
---
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(-)
From: Denton Liu <hidden> Date: 2019-10-14 20:47:09
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).
Signed-off-by: Denton Liu <redacted>
---
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(-)
@@ -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.
@@ -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 ------------
@@ -37,6 +37,7 @@#include"range-diff.h"#define MAIL_DEFAULT_WRAP 72+#define COVER_FROM_AUTO_MAX_SUBJECT_LEN 100/* Set a default date-time format for git log ("log.date" config variable) */staticconstchar*default_date_mode=NULL;
@@ -1581,6 +1630,9 @@ 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_STRING(0,"cover-from-description",&cover_from_description_arg,+N_("cover-from-description-mode"),+N_("generate parts of a cover letter based on a branch's description")),{OPTION_CALLBACK,0,"subject-prefix",&rev,N_("prefix"),N_("Use [<prefix>] instead of [PATCH]"),PARSE_OPT_NONEG,subject_prefix_callback},
@@ -1517,6 +1517,178 @@ test_expect_success 'format patch ignores color.ui' 'test_cmpexpectactual'+test_expect_success'cover letter with invalid --cover-from-description and config''+test_configbranch.rebuild-1.description"config subject++body" &&+test_must_failgitformat-patch--cover-letter--cover-from-descriptiongarbagemaster&&+test_configformat.coverFromDescriptiongarbage&&+test_must_failgitformat-patch--cover-lettermaster+'++test_expect_success'cover letter with format.coverFromDescription = default''+test_configbranch.rebuild-1.description"config subject++body" &&+test_configformat.coverFromDescriptiondefault&&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-lettermaster>actual&&+grep"^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$"actual&&+!grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+grep"^config subject$"actual&&+grep"^body$"actual+'++test_expect_success'cover letter with --cover-from-description default''+test_configbranch.rebuild-1.description"config subject++body" &&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-letter--cover-from-descriptiondefaultmaster>actual&&+grep"^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$"actual&&+!grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+grep"^config subject$"actual&&+grep"^body$"actual+'++test_expect_success'cover letter with format.coverFromDescription = none''+test_configbranch.rebuild-1.description"config subject++body" &&+test_configformat.coverFromDescriptionnone&&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-lettermaster>actual&&+grep"^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$"actual&&+grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+!grep"^config subject$"actual&&+!grep"^body$"actual+'++test_expect_success'cover letter with --cover-from-description none''+test_configbranch.rebuild-1.description"config subject++body" &&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-letter--cover-from-descriptionnonemaster>actual&&+grep"^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$"actual&&+grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+!grep"^config subject$"actual&&+!grep"^body$"actual+'++test_expect_success'cover letter with format.coverFromDescription = message''+test_configbranch.rebuild-1.description"config subject++body" &&+test_configformat.coverFromDescriptionmessage&&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-lettermaster>actual&&+grep"^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$"actual&&+!grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+grep"^config subject$"actual&&+grep"^body$"actual+'++test_expect_success'cover letter with --cover-from-description message''+test_configbranch.rebuild-1.description"config subject++body" &&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-letter--cover-from-descriptionmessagemaster>actual&&+grep"^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$"actual&&+!grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+grep"^config subject$"actual&&+grep"^body$"actual+'++test_expect_success'cover letter with format.coverFromDescription = subject''+test_configbranch.rebuild-1.description"config subject++body" &&+test_configformat.coverFromDescriptionsubject&&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-lettermaster>actual&&+grep"^Subject: \[PATCH 0/2\] config subject$"actual&&+!grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+!grep"^config subject$"actual&&+grep"^body$"actual+'++test_expect_success'cover letter with --cover-from-description subject''+test_configbranch.rebuild-1.description"config subject++body" &&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-letter--cover-from-descriptionsubjectmaster>actual&&+grep"^Subject: \[PATCH 0/2\] config subject$"actual&&+!grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+!grep"^config subject$"actual&&+grep"^body$"actual+'++test_expect_success'cover letter with format.coverFromDescription = auto (short subject line)''+test_configbranch.rebuild-1.description"config subject++body" &&+test_configformat.coverFromDescriptionauto&&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-lettermaster>actual&&+grep"^Subject: \[PATCH 0/2\] config subject$"actual&&+!grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+!grep"^config subject$"actual&&+grep"^body$"actual+'++test_expect_success'cover letter with --cover-from-description auto (short subject line)''+test_configbranch.rebuild-1.description"config subject++body" &&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-letter--cover-from-descriptionautomaster>actual&&+grep"^Subject: \[PATCH 0/2\] config subject$"actual&&+!grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+!grep"^config subject$"actual&&+grep"^body$"actual+'++test_expect_success'cover letter with format.coverFromDescription = auto (long subject line)''+test_configbranch.rebuild-1.description"this is a really long first line and it is over 100 characters long which is the threshold for long subjects++body" &&+test_configformat.coverFromDescriptionauto&&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-lettermaster>actual&&+grep"^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$"actual&&+!grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+grep"^this is a really long first line and it is over 100 characters long which is the threshold for long subjects$"actual&&+grep"^body$"actual+'++test_expect_success'cover letter with --cover-from-description auto (long subject line)''+test_configbranch.rebuild-1.description"this is a really long first line and it is over 100 characters long which is the threshold for long subjects++body" &&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-letter--cover-from-descriptionautomaster>actual&&+grep"^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$"actual&&+!grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+grep"^this is a really long first line and it is over 100 characters long which is the threshold for long subjects$"actual&&+grep"^body$"actual+'++test_expect_success'cover letter with command-line --cover-from-description overrides config''+test_configbranch.rebuild-1.description"config subject++body" &&+test_configformat.coverFromDescriptionnone&&+gitcheckoutrebuild-1&&+gitformat-patch--stdout--cover-letter--cover-from-descriptionsubjectmaster>actual&&+grep"^Subject: \[PATCH 0/2\] config subject$"actual&&+!grep"^\*\*\* BLURB HERE \*\*\*$"actual&&+!grep"^config subject$"actual&&+grep"^body$"actual+'+ test_expect_success'cover letter using branch description (1)''gitcheckoutrebuild-1&&test_configbranch.rebuild-1.descriptionhello&&