git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] format-patch: show 0/1 and 1/1 for singleton patch with cover letter
@ 2016-08-19 23:49 Jacob Keller
  2016-08-23 16:33 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Jacob Keller @ 2016-08-19 23:49 UTC (permalink / raw)
  To: git, Josh Triplett, James Hogan; +Cc: Jacob Keller

From: Jacob Keller <jacob.keller@gmail.com>

Change the default behavior of git-format-patch to generate numbered
sequence of 0/1 and 1/1 when generating both a cover-letter and a single
patch. This standardizes the cover letter to have 0/N which helps
distinguish the cover letter from the patch itself. Since the behavior
is easily changed via configuration as well as the use of -n and -N this
should be acceptable default behavior.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
---
 builtin/log.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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;
-- 
2.10.0.rc0.259.g83512d9


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] format-patch: show 0/1 and 1/1 for singleton patch with cover letter
  2016-08-19 23:49 [PATCH] format-patch: show 0/1 and 1/1 for singleton patch with cover letter Jacob Keller
@ 2016-08-23 16:33 ` Junio C Hamano
  2016-08-23 21:06   ` Jacob Keller
  2016-08-23 21:21   ` Junio C Hamano
  0 siblings, 2 replies; 5+ messages in thread
From: Junio C Hamano @ 2016-08-23 16:33 UTC (permalink / raw)
  To: Jacob Keller; +Cc: git, Josh Triplett, James Hogan, Jacob Keller

Jacob Keller <jacob.e.keller@intel.com> writes:

> From: Jacob Keller <jacob.keller@gmail.com>
>
> Change the default behavior of git-format-patch to generate numbered
> sequence of 0/1 and 1/1 when generating both a cover-letter and a single
> patch. This standardizes the cover letter to have 0/N which helps
> distinguish the cover letter from the patch itself. Since the behavior
> is easily changed via configuration as well as the use of -n and -N this
> should be acceptable default behavior.
>
> Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
> ---

This obviously changes the behaviour, but I do not think of a reason
why this change is a bad idea.  

>  builtin/log.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> 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;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] format-patch: show 0/1 and 1/1 for singleton patch with cover letter
  2016-08-23 16:33 ` Junio C Hamano
@ 2016-08-23 21:06   ` Jacob Keller
  2016-08-23 21:21   ` Junio C Hamano
  1 sibling, 0 replies; 5+ messages in thread
From: Jacob Keller @ 2016-08-23 21:06 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jacob Keller, Git mailing list, Josh Triplett, James Hogan

On Tue, Aug 23, 2016 at 9:33 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Jacob Keller <jacob.e.keller@intel.com> writes:
>
>> From: Jacob Keller <jacob.keller@gmail.com>
>>
>> Change the default behavior of git-format-patch to generate numbered
>> sequence of 0/1 and 1/1 when generating both a cover-letter and a single
>> patch. This standardizes the cover letter to have 0/N which helps
>> distinguish the cover letter from the patch itself. Since the behavior
>> is easily changed via configuration as well as the use of -n and -N this
>> should be acceptable default behavior.
>>
>> Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
>> ---
>
> This obviously changes the behaviour, but I do not think of a reason
> why this change is a bad idea.
>

Yes. The basic idea is "number all files outputted if we generate more
than 1 file" Since a cover letter is a separate file, we number 0/1
and 1/1.

Thanks,
Jake

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] format-patch: show 0/1 and 1/1 for singleton patch with cover letter
  2016-08-23 16:33 ` Junio C Hamano
  2016-08-23 21:06   ` Jacob Keller
@ 2016-08-23 21:21   ` Junio C Hamano
  2016-08-23 21:28     ` Jacob Keller
  1 sibling, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2016-08-23 21:21 UTC (permalink / raw)
  To: Jacob Keller; +Cc: git, Josh Triplett, James Hogan, Jacob Keller

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.  

>> 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 */

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] format-patch: show 0/1 and 1/1 for singleton patch with cover letter
  2016-08-23 21:21   ` Junio C Hamano
@ 2016-08-23 21:28     ` Jacob Keller
  0 siblings, 0 replies; 5+ messages in thread
From: Jacob Keller @ 2016-08-23 21:28 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jacob Keller, Git mailing list, Josh Triplett, James Hogan

On Tue, Aug 23, 2016 at 2:21 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>>>      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.
>

Oops! Sorry for not running tests.

> 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.
>

I'll add a new test and squash your fix in.

Thanks,
Jake

>  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 */

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-08-23 21:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-19 23:49 [PATCH] format-patch: show 0/1 and 1/1 for singleton patch with cover letter Jacob Keller
2016-08-23 16:33 ` Junio C Hamano
2016-08-23 21:06   ` Jacob Keller
2016-08-23 21:21   ` Junio C Hamano
2016-08-23 21:28     ` Jacob Keller

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).