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

Previous thread: Re: [PATCH] Be nice with compilers that do not support runtime paths at all. by Brian Dessent on Monday, October 22, 2007 - 2:52 am. (1 message)

Next thread: [PATCH] Let users override name of per-directory ignore file by Andreas Ericsson on Monday, October 15, 2007 - 8:09 am. (3 messages)
To: <git@...>
Cc: <spearce@...>
Date: Sunday, October 21, 2007 - 4:13 am

[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

-

To: Andreas Ericsson <ae@...>
Cc: <spearce@...>, <git@...>
Date: Monday, October 22, 2007 - 5:44 am

Hi,

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

-

To: <git@...>
Cc: Johannes Schindelin <Johannes.Schindelin@...>, Andreas Ericsson <ae@...>, <spearce@...>
Date: Saturday, November 3, 2007 - 11:44 am

Automagically enable numbering if we output more than one patch.

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

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

-

To: Mike Hommey <mh@...>
Cc: Andreas Ericsson <ae@...>, <spearce@...>, <git@...>
Date: Saturday, November 3, 2007 - 12:31 pm

Hi,

Still DWIDNSAA.

Ciao,
Dscho

-

To: Johannes Schindelin <Johannes.Schindelin@...>
Cc: Mike Hommey <mh@...>, <spearce@...>, <git@...>
Date: Saturday, November 3, 2007 - 12:34 pm

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
-

To: Andreas Ericsson <ae@...>
Cc: Mike Hommey <mh@...>, <spearce@...>, <git@...>
Date: Saturday, November 3, 2007 - 8:25 pm

Hi,

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

-

To: Johannes Schindelin <Johannes.Schindelin@...>
Cc: Mike Hommey <mh@...>, <spearce@...>, <git@...>
Date: Sunday, November 4, 2007 - 5:49 am

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

Dito.

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

To: Mike Hommey <mh@...>
Cc: Johannes Schindelin <Johannes.Schindelin@...>, <spearce@...>, <git@...>
Date: Saturday, November 3, 2007 - 11:59 am

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
-

To: Andreas Ericsson <ae@...>
Cc: Johannes Schindelin <Johannes.Schindelin@...>, <spearce@...>, <git@...>
Date: Saturday, November 3, 2007 - 12:03 pm

Does it make sense to turn it off ?

Mike
-

To: Mike Hommey <mh@...>
Cc: Johannes Schindelin <Johannes.Schindelin@...>, <spearce@...>, <git@...>
Date: Saturday, November 3, 2007 - 12:32 pm

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
-

To: Johannes Schindelin <Johannes.Schindelin@...>
Cc: <spearce@...>, <git@...>
Date: Monday, October 22, 2007 - 6:14 am

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

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

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
-

To: Andreas Ericsson <ae@...>
Cc: <spearce@...>, <git@...>
Date: Monday, October 22, 2007 - 6:22 am

Hi,

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

-

To: Johannes Schindelin <Johannes.Schindelin@...>
Cc: <spearce@...>, <git@...>
Date: Monday, October 22, 2007 - 7:13 am

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

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
-

Previous thread: Re: [PATCH] Be nice with compilers that do not support runtime paths at all. by Brian Dessent on Monday, October 22, 2007 - 2:52 am. (1 message)

Next thread: [PATCH] Let users override name of per-directory ignore file by Andreas Ericsson on Monday, October 15, 2007 - 8:09 am. (3 messages)