git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] format-patch: show 0/1 and 1/1 for singleton patch with cover letter

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 23, 2016, 21:21 UTC
Message-ID
<xmqqinuruqpk.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<xmqq37lvxx5o.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
> This obviously changes the behaviour, but I do not think of a reason
> why this change is a bad idea.  
Show 13 quoted lines
>> diff --git a/builtin/log.c b/builtin/log.c
>> index 92dc34dcb0cc..8e6100fb0c5b 100644
>> --- a/builtin/log.c
>> +++ b/builtin/log.c
>> @@ -1676,7 +1676,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
>>  		/* nothing to do */
>>  		return 0;
>>  	total = nr;
>> -	if (!keep_subject && auto_number && total > 1)
>> +	if (!keep_subject && auto_number && (total > 1 || cover_letter))
>>  		numbered = 1;
>>  	if (numbered)
>>  		rev.total = total + start_number - 1;

Actually there is a very good reason why this patch is not good (yet). When the --cover option is not specified on the command line, cover_letter is -1 (use configuration or turn it on only when it is a multi-patch series) at this point.

I think you would have noticed it if you ran any format-patch tests. t/t4021-format-patch-numbered.sh fails at the very beginning.

With the attached SQUASH, existing tests pass, which is a strong sign that this new feature needs to be protected by a new test in the t4021 script to make sure other people would not break it in the future.

 builtin/log.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/builtin/log.c b/builtin/log.c
index e50d361..b7bfeb9 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1650,16 +1650,16 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 		/* nothing to do */
 		return 0;
 	total = nr;
-	if (!keep_subject && auto_number && (total > 1 || cover_letter))
-		numbered = 1;
-	if (numbered)
-		rev.total = total + start_number - 1;
 	if (cover_letter == -1) {
 		if (config_cover_letter == COVER_AUTO)
 			cover_letter = (total > 1);
 		else
 			cover_letter = (config_cover_letter == COVER_ON);
 	}
+	if (!keep_subject && auto_number && (total > 1 || cover_letter))
+		numbered = 1;
+	if (numbered)
+		rev.total = total + start_number - 1;
 
 	if (!signature) {
 		; /* --no-signature inhibits all signatures */
Previous: Jacob KellerNext: Jacob Keller
Message 4 of 5 in “format-patch: show 0/1 and 1/1 for singleton patch with cover letter”
  1. format-patch: show 0/1 and 1/1 for singleton patch with cover letterJacob Keller, Aug 19, 2016
  2. Junio C HamanoAug 23, 2016
  3. Jacob KellerAug 23, 2016
  4. Junio C HamanoAug 23, 2016
  5. Jacob KellerAug 23, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.