{"thread":{"id":"43920","subject":"[PATCH v3] format-patch: show 0/1 and 1/1 for singleton patch with cover letter","startedAt":"2016-08-23T22:45:57Z","lastAt":"2016-08-24T05:39:05Z","messageCount":2,"participants":["Jacob Keller","Junio C Hamano"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"300012","messageId":"20160823224550.32406-1-jacob.e.keller@intel.com","threadId":"43920","inReplyTo":null,"subject":"[PATCH v3] format-patch: show 0/1 and 1/1 for singleton patch with cover letter","fromName":"Jacob Keller","fromEmail":"jacob.e.keller@intel.com","sentAt":"2016-08-23T22:45:50Z","receivedAt":"2016-08-23T22:45:57Z","isPatch":true,"sender":{"key":"jacob.e.keller@intel.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"From: Jacob Keller <jacob.keller@gmail.com>\n\nChange the default behavior of git-format-patch to generate numbered\nsequence of 0/1 and 1/1 when generating both a cover-letter and a single\npatch. This standardizes the cover letter to have 0/N which helps\ndistinguish the cover letter from the patch itself. Since the behavior\nis easily changed via configuration as well as the use of -n and -N this\nshould be acceptable default behavior.\n\nAdd tests for the new default behavior.\n\nSigned-off-by: Jacob Keller <jacob.keller@gmail.com>\n---\n builtin/log.c                    |  8 ++++----\n t/t4021-format-patch-numbered.sh | 17 +++++++++++++++++\n 2 files changed, 21 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 92dc34dcb0cc..49aa534f4a01 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -1676,16 +1676,16 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\t/* nothing to do */\n \t\treturn 0;\n \ttotal = nr;\n-\tif (!keep_subject && auto_number && total > 1)\n-\t\tnumbered = 1;\n-\tif (numbered)\n-\t\trev.total = total + start_number - 1;\n \tif (cover_letter == -1) {\n \t\tif (config_cover_letter == COVER_AUTO)\n \t\t\tcover_letter = (total > 1);\n \t\telse\n \t\t\tcover_letter = (config_cover_letter == COVER_ON);\n \t}\n+\tif (!keep_subject && auto_number && (total > 1 || cover_letter))\n+\t\tnumbered = 1;\n+\tif (numbered)\n+\t\trev.total = total + start_number - 1;\n \n \tif (!signature) {\n \t\t; /* --no-signature inhibits all signatures */\ndiff --git a/t/t4021-format-patch-numbered.sh b/t/t4021-format-patch-numbered.sh\nindex 886494b58f67..9be65fd4440a 100755\n--- a/t/t4021-format-patch-numbered.sh\n+++ b/t/t4021-format-patch-numbered.sh\n@@ -36,6 +36,11 @@ test_no_numbered() {\n \ttest_num_no_numbered $1 2\n }\n \n+test_single_cover_letter_numbered() {\n+\tgrep \"^Subject: \\[PATCH 0/1\\]\" $1 &&\n+\tgrep \"^Subject: \\[PATCH 1/1\\]\" $1\n+}\n+\n test_single_numbered() {\n \tgrep \"^Subject: \\[PATCH 1/1\\]\" $1\n }\n@@ -121,4 +126,16 @@ test_expect_success '--start-number && --numbered' '\n \tgrep \"^Subject: \\[PATCH 3/3\\]\" patch8\n '\n \n+test_expect_success 'single patch with cover-letter defaults to numbers' '\n+\tgit format-patch --cover-letter --stdout HEAD~1 >patch9.single &&\n+\ttest_single_cover_letter_numbered patch9.single\n+'\n+\n+test_expect_success 'Use --no-numbered and --cover-letter single patch' '\n+\tgit format-patch --no-numbered --stdout --cover-letter HEAD~1 >patch10 &&\n+\ttest_no_numbered patch10\n+'\n+\n+\n+\n test_done\n-- \n2.10.0.rc0.259.g83512d9\n\n"},{"id":"300020","messageId":"xmqq1t1eu3q2.fsf@gitster.mtv.corp.google.com","threadId":"43920","inReplyTo":"20160823224550.32406-1-jacob.e.keller@intel.com","subject":"Re: [PATCH v3] format-patch: show 0/1 and 1/1 for singleton patch with cover letter","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-08-24T05:37:41Z","receivedAt":"2016-08-24T05:39:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jacob Keller <jacob.e.keller@intel.com> writes:\n\n> From: Jacob Keller <jacob.keller@gmail.com>\n>\n> Change the default behavior of git-format-patch to generate numbered\n> sequence of 0/1 and 1/1 when generating both a cover-letter and a single\n> patch. This standardizes the cover letter to have 0/N which helps\n> distinguish the cover letter from the patch itself. Since the behavior\n> is easily changed via configuration as well as the use of -n and -N this\n> should be acceptable default behavior.\n>\n> Add tests for the new default behavior.\n>\n> Signed-off-by: Jacob Keller <jacob.keller@gmail.com>\n> ---\n>  builtin/log.c                    |  8 ++++----\n>  t/t4021-format-patch-numbered.sh | 17 +++++++++++++++++\n>  2 files changed, 21 insertions(+), 4 deletions(-)\n\nLooks good, thanks.  Queued.\n"}]}