# [PATCH] git-format-patch: Don't number patches when there's only one

14 messages from 2007-10-21 to 2007-11-04. Participants: Andreas Ericsson, Johannes Schindelin, Mike Hommey, Samuel Tardieu.
Thread: https://gitlist.dev/t/10421

## Andreas Ericsson, 2007-10-21 08:13

Subject: [PATCH] git-format-patch: Don't number patches when there's only one
Message-ID: <20071021144637.762085BB92@nox.op5.se>
URL: https://gitlist.dev/e/20071021144637.762085BB92%40nox.op5.se

```
[PATCH 1/1] looks a bit silly, and automagically handling
this in git-format-patch makes some scripting around it a
lot more pleasant.

Signed-off-by: Andreas Ericsson <ae@op5.se>
---
 Documentation/git-format-patch.txt |    3 ++-
 builtin-log.c                      |    4 ++++
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index c9857a2..9f16951 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -56,7 +56,8 @@ If -o is specified, output files are created in <dir>.  Otherwise
 they are created in the current working directory.
 
 If -n is specified, instead of "[PATCH] Subject", the first line
-is formatted as "[PATCH n/m] Subject".
+is formatted as "[PATCH n/m] Subject" if the revision range to
+format contains more than one commit.
 
 If given --thread, git-format-patch will generate In-Reply-To and
 References headers to make the second and subsequent patch mails appear
diff --git a/builtin-log.c b/builtin-log.c
index e8b982d..5c48f4d 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -642,6 +642,10 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 		list[nr - 1] = commit;
 	}
 	total = nr;
+
+	/* don't number patches when there's only one */
+	if (total == 1)
+		numbered = 0;
 	if (numbered)
 		rev.total = total + start_number - 1;
 	rev.add_signoff = add_signoff;
-- 
1.5.3.4.1273.g725c19

```

## Johannes Schindelin, 2007-10-22 09:44

Subject: Re: [PATCH] git-format-patch: Don't number patches when there's only one
Message-ID: <Pine.LNX.4.64.0710221044080.25221@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0710221044080.25221%40racer.site
In-Reply-To: <20071021144637.762085BB92@nox.op5.se>

```
Hi,

On Sun, 21 Oct 2007, Andreas Ericsson wrote:

> [PATCH 1/1] looks a bit silly, and automagically handling this in 
> git-format-patch makes some scripting around it a lot more pleasant.

I think you should not use "-n" if you do not want to have the numbers.  
In circumstances as yours, where you can have patch series larger than 
one, I imagine that the "[PATCH 1/1]" bears an important information, 
which is not present in "[PATCH]": this patch series contains only one 
patch.

IOW I do not like your patch: too much DWIDNS (Do What I Did NOT Say) for 
me.

Ciao,
Dscho

```

## Andreas Ericsson, 2007-10-22 10:14

Subject: Re: [PATCH] git-format-patch: Don't number patches when there's only one
Message-ID: <471C77F0.5050701@op5.se>
URL: https://gitlist.dev/e/471C77F0.5050701%40op5.se
In-Reply-To: <Pine.LNX.4.64.0710221044080.25221@racer.site>

```
Johannes Schindelin wrote:
> Hi,
> 
> On Sun, 21 Oct 2007, Andreas Ericsson wrote:
> 
>> [PATCH 1/1] looks a bit silly, and automagically handling this in 
>> git-format-patch makes some scripting around it a lot more pleasant.
> 
> I think you should not use "-n" if you do not want to have the numbers.  

This stems from creating scripts around it where I only want to see the 
numbers if there is more than a single patch. Currently I can't do that 
without running git-format-patch twice or re-implementing the revision 
parsing machinery to count revisions prior to passing arguments to 
format-patch.

> In circumstances as yours, where you can have patch series larger than 
> one, I imagine that the "[PATCH 1/1]" bears an important information, 
> which is not present in "[PATCH]": this patch series contains only one 
> patch.
> 

That's sort of implicit in [PATCH], since all patch-series added by the 
tool I'm scripting will have [PATCH n/m], while I'd prefer for 
single-patches to have only [PATCH].

> IOW I do not like your patch: too much DWIDNS (Do What I Did NOT Say) for 
> me.
> 

Would a separate option be acceptable to you?

It doesn't have to be fancy or short, since I really only mean to use it 
from our scripts.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

```

## Johannes Schindelin, 2007-10-22 10:22

Subject: Re: [PATCH] git-format-patch: Don't number patches when there's only one
Message-ID: <Pine.LNX.4.64.0710221119300.25221@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0710221119300.25221%40racer.site
In-Reply-To: <471C77F0.5050701@op5.se>

```
Hi,

On Mon, 22 Oct 2007, Andreas Ericsson wrote:

> Johannes Schindelin wrote:
> 
> > On Sun, 21 Oct 2007, Andreas Ericsson wrote:
> > 
> > > [PATCH 1/1] looks a bit silly, and automagically handling this in 
> > > git-format-patch makes some scripting around it a lot more pleasant.
> > 
> > I think you should not use "-n" if you do not want to have the 
> > numbers.
> 
> This stems from creating scripts around it where I only want to see the 
> numbers if there is more than a single patch. Currently I can't do that 
> without running git-format-patch twice or re-implementing the revision 
> parsing machinery to count revisions prior to passing arguments to 
> format-patch.

Why not have something as simple as

	numbered=
	test $(git rev-list $options | wc -l) -gt 1 && numbered=-n

	[...]

	git format-patch $numbered $options

At the moment, the semantics of "--numbered" is really clear and precise.  
And I really like that.  It makes for less surprises.

Ciao,
Dscho

```

## Andreas Ericsson, 2007-10-22 11:13

Subject: Re: [PATCH] git-format-patch: Don't number patches when there's only one
Message-ID: <471C85C1.3020308@op5.se>
URL: https://gitlist.dev/e/471C85C1.3020308%40op5.se
In-Reply-To: <Pine.LNX.4.64.0710221119300.25221@racer.site>

```
Johannes Schindelin wrote:
> Hi,
> 
> On Mon, 22 Oct 2007, Andreas Ericsson wrote:
> 
>> Johannes Schindelin wrote:
>>
>>> On Sun, 21 Oct 2007, Andreas Ericsson wrote:
>>>
>>>> [PATCH 1/1] looks a bit silly, and automagically handling this in 
>>>> git-format-patch makes some scripting around it a lot more pleasant.
>>> I think you should not use "-n" if you do not want to have the 
>>> numbers.
>> This stems from creating scripts around it where I only want to see the 
>> numbers if there is more than a single patch. Currently I can't do that 
>> without running git-format-patch twice or re-implementing the revision 
>> parsing machinery to count revisions prior to passing arguments to 
>> format-patch.
> 
> Why not have something as simple as
> 
> 	numbered=
> 	test $(git rev-list $options | wc -l) -gt 1 && numbered=-n
> 

Because 23498~12 != 23498~12..HEAD to git rev-list, but it is to
git-format-patch, meaning I'll have to duplicate the logic in every 
script that's supposed to use it or risk introducing a third way of 
specifying a list of revisions.

> 	[...]
> 
> 	git format-patch $numbered $options
> 
> At the moment, the semantics of "--numbered" is really clear and precise.  
> And I really like that.  It makes for less surprises.
> 

Semantics could be equally clear for --numbered-if-multiple.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

```

## Mike Hommey, 2007-11-03 15:44

Subject: [PATCH] git-format-patch: Number patches when there are more than one
Message-ID: <1194104694-12530-1-git-send-email-mh@glandium.org>
URL: https://gitlist.dev/e/1194104694-12530-1-git-send-email-mh%40glandium.org
In-Reply-To: <Pine.LNX.4.64.0710221044080.25221@racer.site>

```
Automagically enable numbering if we output more than one patch.

Signed-off-by: Mike Hommey <mh@glandium.org>
---

On Mon, Oct 22, 2007 at 10:44:12AM +0100, Johannes Schindelin wrote:
> Hi,
> 
> On Sun, 21 Oct 2007, Andreas Ericsson wrote:
> 
> > [PATCH 1/1] looks a bit silly, and automagically handling this in 
> > git-format-patch makes some scripting around it a lot more pleasant.
> 
> I think you should not use "-n" if you do not want to have the numbers.  
> In circumstances as yours, where you can have patch series larger than 
> one, I imagine that the "[PATCH 1/1]" bears an important information, 
> which is not present in "[PATCH]": this patch series contains only one 
> patch.
> 
> IOW I do not like your patch: too much DWIDNS (Do What I Did NOT Say) for 
> me.

How about the contrary ?


 Documentation/git-format-patch.txt |    3 ++-
 builtin-log.c                      |    2 ++
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index f0617ef..b77daed 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -56,7 +56,8 @@ If -o is specified, output files are created in <dir>.  Otherwise
 they are created in the current working directory.
 
 If -n is specified, instead of "[PATCH] Subject", the first line
-is formatted as "[PATCH n/m] Subject".
+is formatted as "[PATCH n/m] Subject". This is the default when
+there is more than one commit to prepare patches for.
 
 If given --thread, git-format-patch will generate In-Reply-To and
 References headers to make the second and subsequent patch mails appear
diff --git a/builtin-log.c b/builtin-log.c
index 8b2bf63..640d6e7 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -642,6 +642,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 		list[nr - 1] = commit;
 	}
 	total = nr;
+	if (!keep_subject && total > 1)
+		numbered = 1;
 	if (numbered)
 		rev.total = total + start_number - 1;
 	rev.add_signoff = add_signoff;
-- 
1.5.3.5

```

## Andreas Ericsson, 2007-11-03 15:59

Subject: Re: [PATCH] git-format-patch: Number patches when there are more than one
Message-ID: <472C9AFC.3000509@op5.se>
URL: https://gitlist.dev/e/472C9AFC.3000509%40op5.se
In-Reply-To: <1194104694-12530-1-git-send-email-mh@glandium.org>

```
Mike Hommey wrote:
> Automagically enable numbering if we output more than one patch.
> 
> Signed-off-by: Mike Hommey <mh@glandium.org>
> ---
> 
> On Mon, Oct 22, 2007 at 10:44:12AM +0100, Johannes Schindelin wrote:
>> Hi,
>>
>> On Sun, 21 Oct 2007, Andreas Ericsson wrote:
>>
>>> [PATCH 1/1] looks a bit silly, and automagically handling this in 
>>> git-format-patch makes some scripting around it a lot more pleasant.
>> I think you should not use "-n" if you do not want to have the numbers.  
>> In circumstances as yours, where you can have patch series larger than 
>> one, I imagine that the "[PATCH 1/1]" bears an important information, 
>> which is not present in "[PATCH]": this patch series contains only one 
>> patch.
>>
>> IOW I do not like your patch: too much DWIDNS (Do What I Did NOT Say) for 
>> me.
> 
> How about the contrary ?
> 

Works for me. How does one turn it off?

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

```

## Mike Hommey, 2007-11-03 16:03

Subject: Re: [PATCH] git-format-patch: Number patches when there are more than one
Message-ID: <20071103160323.GA13284@glandium.org>
URL: https://gitlist.dev/e/20071103160323.GA13284%40glandium.org
In-Reply-To: <472C9AFC.3000509@op5.se>

```
On Sat, Nov 03, 2007 at 04:59:56PM +0100, Andreas Ericsson wrote:
> Mike Hommey wrote:
>> Automagically enable numbering if we output more than one patch.
>> Signed-off-by: Mike Hommey <mh@glandium.org>
>> ---
>> On Mon, Oct 22, 2007 at 10:44:12AM +0100, Johannes Schindelin wrote:
>>> Hi,
>>>
>>> On Sun, 21 Oct 2007, Andreas Ericsson wrote:
>>>
>>>> [PATCH 1/1] looks a bit silly, and automagically handling this in 
>>>> git-format-patch makes some scripting around it a lot more pleasant.
>>> I think you should not use "-n" if you do not want to have the numbers.  
>>> In circumstances as yours, where you can have patch series larger than 
>>> one, I imagine that the "[PATCH 1/1]" bears an important information, 
>>> which is not present in "[PATCH]": this patch series contains only one 
>>> patch.
>>>
>>> IOW I do not like your patch: too much DWIDNS (Do What I Did NOT Say) for 
>>> me.
>> How about the contrary ?
>
> Works for me. How does one turn it off?

Does it make sense to turn it off ?

Mike

```

## Johannes Schindelin, 2007-11-03 16:31

Subject: Re: [PATCH] git-format-patch: Number patches when there are more than one
Message-ID: <Pine.LNX.4.64.0711031631020.4362@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0711031631020.4362%40racer.site
In-Reply-To: <1194104694-12530-1-git-send-email-mh@glandium.org>

```
Hi,

On Sat, 3 Nov 2007, Mike Hommey wrote:

> Automagically enable numbering if we output more than one patch.
> 
> Signed-off-by: Mike Hommey <mh@glandium.org>
> ---
> 
> On Mon, Oct 22, 2007 at 10:44:12AM +0100, Johannes Schindelin wrote:
> > Hi,
> > 
> > On Sun, 21 Oct 2007, Andreas Ericsson wrote:
> > 
> > > [PATCH 1/1] looks a bit silly, and automagically handling this in 
> > > git-format-patch makes some scripting around it a lot more pleasant.
> > 
> > I think you should not use "-n" if you do not want to have the numbers.  
> > In circumstances as yours, where you can have patch series larger than 
> > one, I imagine that the "[PATCH 1/1]" bears an important information, 
> > which is not present in "[PATCH]": this patch series contains only one 
> > patch.
> > 
> > IOW I do not like your patch: too much DWIDNS (Do What I Did NOT Say) for 
> > me.
> 
> How about the contrary ?

Still DWIDNSAA.

Ciao,
Dscho

```

## Andreas Ericsson, 2007-11-03 16:32

Subject: Re: [PATCH] git-format-patch: Number patches when there are more than one
Message-ID: <472CA29F.3090701@op5.se>
URL: https://gitlist.dev/e/472CA29F.3090701%40op5.se
In-Reply-To: <20071103160323.GA13284@glandium.org>

```
Mike Hommey wrote:
> On Sat, Nov 03, 2007 at 04:59:56PM +0100, Andreas Ericsson wrote:
>> Mike Hommey wrote:
>>> Automagically enable numbering if we output more than one patch.
>>> Signed-off-by: Mike Hommey <mh@glandium.org>
>>> ---
>>> On Mon, Oct 22, 2007 at 10:44:12AM +0100, Johannes Schindelin wrote:
>>>> Hi,
>>>>
>>>> On Sun, 21 Oct 2007, Andreas Ericsson wrote:
>>>>
>>>>> [PATCH 1/1] looks a bit silly, and automagically handling this in 
>>>>> git-format-patch makes some scripting around it a lot more pleasant.
>>>> I think you should not use "-n" if you do not want to have the numbers.  
>>>> In circumstances as yours, where you can have patch series larger than 
>>>> one, I imagine that the "[PATCH 1/1]" bears an important information, 
>>>> which is not present in "[PATCH]": this patch series contains only one 
>>>> patch.
>>>>
>>>> IOW I do not like your patch: too much DWIDNS (Do What I Did NOT Say) for 
>>>> me.
>>> How about the contrary ?
>> Works for me. How does one turn it off?
> 
> Does it make sense to turn it off ?
> 

Sometimes, yes. I frequently gather several small fixes on a branch and then
send all of them at once. They rarely depend on each other, and apply order
is usually not important, so it doesn't make sense to order them.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

```

## Andreas Ericsson, 2007-11-03 16:34

Subject: Re: [PATCH] git-format-patch: Number patches when there are more than one
Message-ID: <472CA301.50508@op5.se>
URL: https://gitlist.dev/e/472CA301.50508%40op5.se
In-Reply-To: <Pine.LNX.4.64.0711031631020.4362@racer.site>

```
Johannes Schindelin wrote:
> Hi,
> 
> On Sat, 3 Nov 2007, Mike Hommey wrote:
> 
>> Automagically enable numbering if we output more than one patch.
>>
>> Signed-off-by: Mike Hommey <mh@glandium.org>
>> ---
>>
>> On Mon, Oct 22, 2007 at 10:44:12AM +0100, Johannes Schindelin wrote:
>>> Hi,
>>>
>>> On Sun, 21 Oct 2007, Andreas Ericsson wrote:
>>>
>>>> [PATCH 1/1] looks a bit silly, and automagically handling this in 
>>>> git-format-patch makes some scripting around it a lot more pleasant.
>>> I think you should not use "-n" if you do not want to have the numbers.  
>>> In circumstances as yours, where you can have patch series larger than 
>>> one, I imagine that the "[PATCH 1/1]" bears an important information, 
>>> which is not present in "[PATCH]": this patch series contains only one 
>>> patch.
>>>
>>> IOW I do not like your patch: too much DWIDNS (Do What I Did NOT Say) for 
>>> me.
>> How about the contrary ?
> 
> Still DWIDNSAA.
> 

Every piece of DWIM can be translated as "do what I didn't say". If you had to
say it, it wouldn't be DWIM after all.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

```

## Samuel Tardieu, 2007-11-03 18:56

Subject: Re: [PATCH] git-format-patch: Number patches when there are more than one
Message-ID: <87hck3cg4o.fsf@willow.rfc1149.net>
URL: https://gitlist.dev/e/87hck3cg4o.fsf%40willow.rfc1149.net
In-Reply-To: <472CA29F.3090701@op5.se>

```
>>>>> "Andreas" == Andreas Ericsson <ae@op5.se> writes:

>> Does it make sense to turn it off ?

Andreas> Sometimes, yes. I frequently gather several small fixes on a
Andreas> branch and then send all of them at once. They rarely depend
Andreas> on each other, and apply order is usually not important, so
Andreas> it doesn't make sense to order them.

So do I. I prefer the auto-numbering to be off by default as it is now.

  Sam
-- 
Samuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/

```

## Johannes Schindelin, 2007-11-04 00:25

Subject: Re: [PATCH] git-format-patch: Number patches when there are more than one
Message-ID: <Pine.LNX.4.64.0711040023000.4362@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0711040023000.4362%40racer.site
In-Reply-To: <472CA301.50508@op5.se>

```
Hi,

On Sat, 3 Nov 2007, Andreas Ericsson wrote:

> Every piece of DWIM can be translated as "do what I didn't say". If you 
> had to say it, it wouldn't be DWIM after all.

At some point, though, it becomes a "Do what _I_ (and nobody else does, or 
at least what a substantial part of the rest of the world did not) mean", 
and that point is reached here and now.

Wow.  I did not think I had to explain _that_.

Ciao,
Dscho

```

## Andreas Ericsson, 2007-11-04 09:49

Subject: Re: [PATCH] git-format-patch: Number patches when there are more than one
Message-ID: <472D95A3.3030108@op5.se>
URL: https://gitlist.dev/e/472D95A3.3030108%40op5.se
In-Reply-To: <Pine.LNX.4.64.0711040023000.4362@racer.site>

```
Johannes Schindelin wrote:
> Hi,
> 
> On Sat, 3 Nov 2007, Andreas Ericsson wrote:
> 
>> Every piece of DWIM can be translated as "do what I didn't say". If you 
>> had to say it, it wouldn't be DWIM after all.
> 
> At some point, though, it becomes a "Do what _I_ (and nobody else does, or 
> at least what a substantial part of the rest of the world did not) mean", 
> and that point is reached here and now.
> 

Every piece of dwimmery is suggested by someone and usually backed by a few,
so it's likely wanted by many. Your ultra-conserative "works for *me*, so
shut up and stop trying to change things" means git really has to be flawless.
For you, that is. For others, there are still things to improve. I'd
appreciate if you could losen the "MY playpen" a little though, as it takes
an awful lot of energy from the constructive discussions.

> Wow.  I did not think I had to explain _that_.
> 

Dito.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

```
