threads / patch / 10421

patchgit-format-patch: Don't number patches when there's only one

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

## tl;dr

14 messages between Oct 21, 2007 and Nov 4, 2007. Diffs are folded; open one to read it.

replies: 13people: 4as markdown or json

Andreas Ericsson· Oct 21, 2007, 08:13 UTC · lore

[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(-)
Show changes to 2 files +6 −1

Documentation/git-format-patch.txt, builtin-log.c

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· Oct 22, 2007, 09:44 UTC · re: Andreas Ericsson · lore

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

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· Oct 22, 2007, 10:14 UTC · re: Johannes Schindelin · lore

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

Johannes Schindelin wrote:
Show 8 quoted lines
> 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.

Show 5 quoted lines
> 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· Oct 22, 2007, 10:22 UTC · re: Andreas Ericsson · lore

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

Hi,
On Mon, 22 Oct 2007, Andreas Ericsson wrote:
Show 15 quoted lines
> 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· Oct 22, 2007, 11:13 UTC · re: Johannes Schindelin · lore

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

Johannes Schindelin wrote:
Show 23 quoted lines
> 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.

Show 7 quoted lines
> 	[...]
> 
> 	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· Nov 3, 2007, 15:44 UTC · re: Johannes Schindelin · lore

[PATCH] git-format-patch: Number patches when there are more than one

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:
Show 15 quoted lines
> 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(-)
Show changes to 2 files +4 −1

Documentation/git-format-patch.txt, builtin-log.c

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· Nov 3, 2007, 15:59 UTC · re: Mike Hommey · lore

Re: [PATCH] git-format-patch: Number patches when there are more than one

Mike Hommey wrote:
Show 23 quoted lines
> 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· Nov 3, 2007, 16:03 UTC · re: Andreas Ericsson · lore

Re: [PATCH] git-format-patch: Number patches when there are more than one

On Sat, Nov 03, 2007 at 04:59:56PM +0100, Andreas Ericsson wrote:
Show 22 quoted lines
> 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
Andreas Ericsson· Nov 3, 2007, 16:32 UTC · re: Mike Hommey · lore

Re: [PATCH] git-format-patch: Number patches when there are more than one

Mike Hommey wrote:
Show 25 quoted lines
> 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
Samuel Tardieu· Nov 3, 2007, 18:56 UTC · re: Andreas Ericsson · lore

Re: [PATCH] git-format-patch: Number patches when there are more than one

>>>>> "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· Nov 3, 2007, 16:31 UTC · re: Mike Hommey · lore

Re: [PATCH] git-format-patch: Number patches when there are more than one

Hi,
On Sat, 3 Nov 2007, Mike Hommey wrote:
Show 23 quoted lines
> 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· Nov 3, 2007, 16:34 UTC · re: Johannes Schindelin · lore

Re: [PATCH] git-format-patch: Number patches when there are more than one

Johannes Schindelin wrote:
Show 28 quoted lines
> 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
Johannes Schindelin· Nov 4, 2007, 00:25 UTC · re: Andreas Ericsson · lore

Re: [PATCH] git-format-patch: Number patches when there are more than one

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· Nov 4, 2007, 09:49 UTC · re: Johannes Schindelin · lore

Re: [PATCH] git-format-patch: Number patches when there are more than one

Johannes Schindelin wrote:
Show 11 quoted lines
> 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

← back to recent threads