threads / patch / 15754

patchRe: [PATCH] format-patch: autonumber by default

Subject: Re: [PATCH] format-patch: autonumber by default

## tl;dr

21 messages between Oct 2, 2008 and Nov 4, 2009. Diffs are folded; open one to read it.

replies: 20people: 9as markdown or json

Giuseppe Bilotta· Oct 2, 2008, 11:27 UTC · lore

[PATCH] format-patch: autonumber by default

Set auto-number true by default, allowing the format.number key to be
set to 'noauto' to override this.
---
 builtin-log.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
Show changes to builtin-log.c +5 −1
diff --git a/builtin-log.c b/builtin-log.c
index fc5e4da..5187dc2 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -426,7 +426,7 @@ static int istitlechar(char c)
 
 static const char *fmt_patch_suffix = ".patch";
 static int numbered = 0;
-static int auto_number = 0;
+static int auto_number = 1;
 
 static char **extra_hdr;
 static int extra_hdr_nr;
@@ -484,6 +484,10 @@ static int git_format_config(const char *var, const char *value, void *cb)
 			auto_number = 1;
 			return 0;
 		}
+		if (value && !strcasecmp(value, "noauto")) {
+			auto_number = 0;
+			return 0;
+		}
 		numbered = git_config_bool(var, value);
 		return 0;
 	}
-- 
1.5.6.5
Johannes Schindelin· Oct 2, 2008, 12:33 UTC · re: Giuseppe Bilotta · lore
Hi,
On Thu, 2 Oct 2008, Giuseppe Bilotta wrote:
Show 5 quoted lines
> Set auto-number true by default, allowing the format.number key to be
> set to 'noauto' to override this.
> ---
>  builtin-log.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)

Interesting. No sign-off, no defense why this is actually desirable, after we lived for so long without this behavior... Care to elaborate?

Ciao, Dscho

Giuseppe Bilotta· Oct 2, 2008, 13:10 UTC · re: Johannes Schindelin · lore

On Thu, Oct 2, 2008 at 2:33 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

Show 12 quoted lines
> Hi,
>
> On Thu, 2 Oct 2008, Giuseppe Bilotta wrote:
>
>> Set auto-number true by default, allowing the format.number key to be
>> set to 'noauto' to override this.
>> ---
>>  builtin-log.c |    6 +++++-
>>  1 files changed, 5 insertions(+), 1 deletions(-)
>
> Interesting.  No sign-off, no defense why this is actually desirable,
> after we lived for so long without this behavior... Care to elaborate?
Doh, sorry about the Sign-off, I'll resend with.

Now, about the reason for this patch: I would say that the most common use-case of format-patch being used to prepare multiple patches is when one plans on sending a patchset. When format.numbering is set to auto, single-patches will still be extracted without numbers, but patchset will be properly numbered.

Of course, there may be cases where one doesn't want numbering (for which there is the -N flag already), and of course we want to give the user the choice to disable autonumbering at the config level, for which there is the new noauto option for format.numbering.

If this explanation is good enough for you, I'll plop it in the resend message too :)

-- 
Giuseppe "Oblomov" Bilotta
Johannes Schindelin· Oct 2, 2008, 13:42 UTC · re: Giuseppe Bilotta · lore
Hi,
On Thu, 2 Oct 2008, Giuseppe Bilotta wrote:
Show 29 quoted lines
> On Thu, Oct 2, 2008 at 2:33 PM, Johannes Schindelin
> <Johannes.Schindelin@gmx.de> wrote:
>
> > On Thu, 2 Oct 2008, Giuseppe Bilotta wrote:
> >
> >> Set auto-number true by default, allowing the format.number key to be
> >> set to 'noauto' to override this.
> >> ---
> >>  builtin-log.c |    6 +++++-
> >>  1 files changed, 5 insertions(+), 1 deletions(-)
> >
> > Interesting.  No sign-off, no defense why this is actually desirable,
> > after we lived for so long without this behavior... Care to elaborate?
> 
> Doh, sorry about the Sign-off, I'll resend with.
> 
> Now, about the reason for this patch: I would say that the most common
> use-case of format-patch being used to prepare multiple patches is
> when one plans on sending a patchset. When format.numbering is set to
> auto, single-patches will still be extracted without numbers, but
> patchset will be properly numbered.
> 
> Of course, there may be cases where one doesn't want numbering (for
> which there is the -N flag already), and of course we want to give the
> user the choice to disable autonumbering at the config level, for
> which there is the new noauto option for format.numbering.
> 
> If this explanation is good enough for you, I'll plop it in the resend
> message too :)
Yep, this is worthy of a commit message.

Thanks, Dscho

Giuseppe Bilotta· Oct 2, 2008, 13:47 UTC · re: Johannes Schindelin · lore

[PATCH] format-patch: autonumber by default

format-patch is most commoly used for multiple patches at once when sending a patchset, in which case we want to number the patches; on the other hand, single-patches are not usually expected to be numbered.

The typical behavior expected by format-patch is therefore the one obtained by enabling autonumber, which should therefore be the default.

Users that want to disable numbering for a particular patchset can do so with the existing -N command-line switch. For users that want to change the default behavior we provide a 'noauto' option for the format.numbering config key.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 builtin-log.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
Show changes to builtin-log.c +5 −1
diff --git a/builtin-log.c b/builtin-log.c
index fc5e4da..5187dc2 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -426,7 +426,7 @@ static int istitlechar(char c)
 
 static const char *fmt_patch_suffix = ".patch";
 static int numbered = 0;
-static int auto_number = 0;
+static int auto_number = 1;
 
 static char **extra_hdr;
 static int extra_hdr_nr;
@@ -484,6 +484,10 @@ static int git_format_config(const char *var, const char *value, void *cb)
 			auto_number = 1;
 			return 0;
 		}
+		if (value && !strcasecmp(value, "noauto")) {
+			auto_number = 0;
+			return 0;
+		}
 		numbered = git_config_bool(var, value);
 		return 0;
 	}
-- 
1.5.6.5
Jakub Narebski· Oct 2, 2008, 14:08 UTC · re: Giuseppe Bilotta · lore
Giuseppe Bilotta wrote:
> format-patch is most commoly used for multiple patches at once when
s/commoly/commonly/;
I'm not sure about 'most' there...
Show 10 quoted lines
> sending a patchset, in which case we want to number the patches; on the
> other hand, single-patches are not usually expected to be numbered.
> 
> The typical behavior expected by format-patch is therefore the one
> obtained by enabling autonumber, which should therefore be the default.
> 
> Users that want to disable numbering for a particular patchset can do so
> with the existing -N command-line switch. For users that want to change
> the default behavior we provide a 'noauto' option for the
> format.numbering config key.
Nice. I like it.
-- 
Jakub Narebski
Poland
Andreas Ericsson· Oct 2, 2008, 14:14 UTC · re: Jakub Narebski · lore
Jakub Narebski wrote:
Show 6 quoted lines
> Giuseppe Bilotta wrote:
>> format-patch is most commoly used for multiple patches at once when
> 
> s/commoly/commonly/;
> 
> I'm not sure about 'most' there...
In that case, just make it "often" and cut "most commoly" (sic) out.
-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
Giuseppe Bilotta· Oct 2, 2008, 17:58 UTC · re: Andreas Ericsson · lore

[PATCH] format-patch: autonumber by default

format-patch is often used for multiple patches at once when sending a patchset, in which case we want to number the patches; on the other hand, single-patches are not usually expected to be numbered.

The typical behavior expected by format-patch is therefore the one obtained by enabling autonumber, which should thus be the default.

Users that want to disable numbering for a particular patchset can do so with the existing -N command-line switch. For users that want to change the default behavior we provide a 'noauto' option for the format.numbering config key.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 builtin-log.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
Show changes to builtin-log.c +5 −1
diff --git a/builtin-log.c b/builtin-log.c
index fc5e4da..5187dc2 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -426,7 +426,7 @@ static int istitlechar(char c)
 
 static const char *fmt_patch_suffix = ".patch";
 static int numbered = 0;
-static int auto_number = 0;
+static int auto_number = 1;
 
 static char **extra_hdr;
 static int extra_hdr_nr;
@@ -484,6 +484,10 @@ static int git_format_config(const char *var, const char *value, void *cb)
 			auto_number = 1;
 			return 0;
 		}
+		if (value && !strcasecmp(value, "noauto")) {
+			auto_number = 0;
+			return 0;
+		}
 		numbered = git_config_bool(var, value);
 		return 0;
 	}
-- 
1.5.6.5
Jeff King· Oct 2, 2008, 20:03 UTC · re: Giuseppe Bilotta · lore
On Thu, Oct 02, 2008 at 07:58:11PM +0200, Giuseppe Bilotta wrote:
Show 6 quoted lines
> format-patch is often used for multiple patches at once when sending a
> patchset, in which case we want to number the patches; on the other
> hand, single-patches are not usually expected to be numbered.
> 
> The typical behavior expected by format-patch is therefore the one
> obtained by enabling autonumber, which should thus be the default.

I personally do not agree with this default. My usual use of format-patch is to dump a cluster of miscellaneous patches since "origin", and then grab the one(s) I want by title.

However, I would not be surprised to find that my use is unlike that of most other people[1], so I am not opposed to the patch.

[1] Actually, my use has a deficiency, which is that I am often sending 2/4, without nobody having seen 1/4, on which it might actually depend. This works in practice for me because I am often producing unrelated janitorial patches for git. :)

So I think the goal is reasonable, but:
> ---
>  builtin-log.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
Documentation update?
-Peff
Giuseppe Bilotta· Oct 2, 2008, 20:15 UTC · re: Jeff King · lore

[PATCH] format-patch: autonumber by default

format-patch is most commoly used for multiple patches at once when sending a patchset, in which case we want to number the patches; on the other hand, single patches are not usually expected to be numbered.

In other words, the typical behavior expected from format-patch is the one obtained by enabling autonumber, so we set it to be the default.

Users that want to disable numbering for a particular patchset can do so with the existing -N command-line switch. For users that want to change the default behavior we provide a 'noauto' option for the format.numbering config key.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 Documentation/config.txt           |    5 +++--
 Documentation/git-format-patch.txt |    9 ++++++---
 builtin-log.c                      |    6 +++++-
 3 files changed, 14 insertions(+), 6 deletions(-)
Show changes to 3 files +14 −6

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

diff --git a/Documentation/config.txt b/Documentation/config.txt
index bbe38cc..9a9ed98 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -633,8 +633,9 @@ fetch.unpackLimit::
 format.numbered::
 	A boolean which can enable sequence numbers in patch subjects.
 	Setting this option to "auto" will enable it only if there is
-	more than one patch.  See --numbered option in
-	linkgit:git-format-patch[1].
+	more than one patch. This is the default behavior and can be
+	disabled by setting this option to "noauto".  See --numbered
+	option in linkgit:git-format-patch[1].
 
 format.headers::
 	Additional email headers to include in a patch to be submitted
diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index adb4ea7..d7be5bb 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -59,7 +59,9 @@ 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 behavior
+when outputting more than one patch, and it can be suppressed with
+the -N command line option.
 
 If given --thread, 'git-format-patch' will generate In-Reply-To and
 References headers to make the second and subsequent patch mails appear
@@ -171,14 +173,15 @@ CONFIGURATION
 -------------
 You can specify extra mail header lines to be added to each message
 in the repository configuration, new defaults for the subject prefix
-and file suffix, and number patches when outputting more than one.
+and file suffix, and disable automatic numbering of patches when outputting
+more than one.
 
 ------------
 [format]
 	headers = "Organization: git-foo\n"
 	subjectprefix = CHANGE
 	suffix = .txt
-	numbered = auto
+	numbered = noauto
 	cc = <email>
 ------------
 
diff --git a/builtin-log.c b/builtin-log.c
index fc5e4da..5187dc2 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -426,7 +426,7 @@ static int istitlechar(char c)
 
 static const char *fmt_patch_suffix = ".patch";
 static int numbered = 0;
-static int auto_number = 0;
+static int auto_number = 1;
 
 static char **extra_hdr;
 static int extra_hdr_nr;
@@ -484,6 +484,10 @@ static int git_format_config(const char *var, const char *value, void *cb)
 			auto_number = 1;
 			return 0;
 		}
+		if (value && !strcasecmp(value, "noauto")) {
+			auto_number = 0;
+			return 0;
+		}
 		numbered = git_config_bool(var, value);
 		return 0;
 	}
-- 
1.5.6.5
Jeff King· Oct 2, 2008, 21:06 UTC · re: Giuseppe Bilotta · lore
On Thu, Oct 02, 2008 at 10:15:00PM +0200, Giuseppe Bilotta wrote:
>  Documentation/config.txt           |    5 +++--
>  Documentation/git-format-patch.txt |    9 ++++++---
>  builtin-log.c                      |    6 +++++-
>  3 files changed, 14 insertions(+), 6 deletions(-)

Thanks, the documentation updates look good to me. There are also some updates required in t4013 (since the expected outputs for some instances will now be numbered) and t4020 (which explicitly checks that the default is no numbering). Probably t4020 should be modified in light of the new default, like so:

---
 t/t4021-format-patch-numbered.sh |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)
Show changes to t/t4021-format-patch-numbered.sh +10 −5
diff --git a/t/t4021-format-patch-numbered.sh b/t/t4021-format-patch-numbered.sh
index 43d64bb..390af23 100755
--- a/t/t4021-format-patch-numbered.sh
+++ b/t/t4021-format-patch-numbered.sh
@@ -45,17 +45,22 @@ test_numbered() {
 	grep "^Subject: \[PATCH 2/2\]" $1
 }
 
-test_expect_success 'Default: no numbered' '
+test_expect_success 'single patch defaults to no numbers' '
+	git format-patch --stdout HEAD~1 >patch0.single &&
+	test_single_no_numbered patch0.single
+'
+
+test_expect_success 'multiple patch defaults to numbered' '
 
-	git format-patch --stdout HEAD~2 >patch0 &&
-	test_no_numbered patch0
+	git format-patch --stdout HEAD~2 >patch0.multiple &&
+	test_numbered patch0.multiple
 
 '
 
 test_expect_success 'Use --numbered' '
 
-	git format-patch --numbered --stdout HEAD~2 >patch1 &&
-	test_numbered patch1
+	git format-patch --numbered --stdout HEAD~1 >patch1 &&
+	test_single_numbered patch1
 
 '
 
-- 
1.6.0.2.570.g2c958
Brian Gernhardt· Oct 2, 2008, 20:17 UTC · re: Giuseppe Bilotta · lore
On Oct 2, 2008, at 1:58 PM, Giuseppe Bilotta wrote:
Show 25 quoted lines
> diff --git a/builtin-log.c b/builtin-log.c
> index fc5e4da..5187dc2 100644
> --- a/builtin-log.c
> +++ b/builtin-log.c
> @@ -426,7 +426,7 @@ static int istitlechar(char c)
>
> static const char *fmt_patch_suffix = ".patch";
> static int numbered = 0;
> -static int auto_number = 0;
> +static int auto_number = 1;
>
> static char **extra_hdr;
> static int extra_hdr_nr;
> @@ -484,6 +484,10 @@ static int git_format_config(const char *var,  
> const char *value, void *cb)
>  			auto_number = 1;
>  			return 0;
>  		}
> +		if (value && !strcasecmp(value, "noauto")) {
> +			auto_number = 0;
> +			return 0;
> +		}
>  		numbered = git_config_bool(var, value);
>  		return 0;
>  	}

format.numbered is a tri-state config option right now: {yes, no, auto}. With this patch, if you add "[format] numbered = false" into your config, you still get auto-numbering.

A better way to do this might be to default both numbered and auto_number to true and only use auto_number is numbered is true. Or turn off auto-numbering when numbering is turned off just below your hunk.

Either way, "noauto" is a bad idea.  It's spelled "no" or "false".
~~ Brian Gernhardt
Brian Gernhardt· Oct 2, 2008, 20:36 UTC · re: Brian Gernhardt · lore

[PATCH] format-patch: autonumber by default

format-patch is most commonly used for multiple patches at once when sending a patchset, in which case we want to number the patches; on the other hand, single patches are not usually expected to be numbered.

In other words, the typical behavior expected from format-patch is the one obtained by enabling autonumber, so we set it to be the default.

Users that want to disable numbering for a particular patchset can do so with the existing -N command-line switch. Users that want to change the default behavior can use the format.numbering config key.

Signed-off-by: Brian Gernhardt <benji@silverinsanity.com>
---
 This is what I was talking about.  The appropriate setting to turn it off is
 "false", not "noauto".
 Documentation/config.txt           |    9 +++++----
 Documentation/git-format-patch.txt |    8 +++++---
 builtin-log.c                      |    3 ++-
 3 files changed, 12 insertions(+), 8 deletions(-)
Show changes to 3 files +12 −8

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

diff --git a/Documentation/config.txt b/Documentation/config.txt
index da18a54..5ba3ffa 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -640,10 +640,11 @@ fetch.unpackLimit::
 	`transfer.unpackLimit` is used instead.
 
 format.numbered::
-	A boolean which can enable sequence numbers in patch subjects.
-	Setting this option to "auto" will enable it only if there is
-	more than one patch.  See --numbered option in
-	linkgit:git-format-patch[1].
+	A boolean which can enable or disable sequence numbers in patch
+	subjects.  It defaults to "auto" which enables it only if there
+	is more than one patch.  It can be enabled or disabled for all
+	messages by setting it to "true" or "false".  See --numbered
+	option in linkgit:git-format-patch[1].
 
 format.headers::
 	Additional email headers to include in a patch to be submitted
diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index adb4ea7..ac36ce8 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -58,8 +58,10 @@ output, unless the --stdout option is specified.
 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".
+By default, the subject of a single patch is "[PATCH] First Line" and
+the subject when multiple patches are output is "[PATCH n/m] First
+Line". To force 1/1 to be added for a single patch, use -n.  To omit
+patch numbers from the subject, use -N
 
 If given --thread, 'git-format-patch' will generate In-Reply-To and
 References headers to make the second and subsequent patch mails appear
@@ -81,7 +83,7 @@ include::diff-options.txt[]
 
 -n::
 --numbered::
-	Name output in '[PATCH n/m]' format.
+	Name output in '[PATCH n/m]' format, even with a single patch.
 
 -N::
 --no-numbered::
diff --git a/builtin-log.c b/builtin-log.c
index fc5e4da..93987ee 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -426,7 +426,7 @@ static int istitlechar(char c)
 
 static const char *fmt_patch_suffix = ".patch";
 static int numbered = 0;
-static int auto_number = 0;
+static int auto_number = 1;
 
 static char **extra_hdr;
 static int extra_hdr_nr;
@@ -485,6 +485,7 @@ static int git_format_config(const char *var, const char *value, void *cb)
 			return 0;
 		}
 		numbered = git_config_bool(var, value);
+		auto_number &&= numbered;
 		return 0;
 	}
 
-- 
1.6.0.2.589.gcd70
Brian Gernhardt· Oct 2, 2008, 20:41 UTC · re: Brian Gernhardt · lore

[PATCH] format-patch: autonumber by default

format-patch is most commonly used for multiple patches at once when sending a patchset, in which case we want to number the patches; on the other hand, single patches are not usually expected to be numbered.

In other words, the typical behavior expected from format-patch is the one obtained by enabling autonumber, so we set it to be the default.

Users that want to disable numbering for a particular patchset can do so with the existing -N command-line switch. Users that want to change the default behavior can use the format.numbering config key.

Signed-off-by: Brian Gernhardt <benji@silverinsanity.com>
---
 This is what I was talking about.  The appropriate setting to turn it off is
 "false", not "noauto".
 Re-sending with the correct CC list.
 Documentation/config.txt           |    9 +++++----
 Documentation/git-format-patch.txt |    8 +++++---
 builtin-log.c                      |    3 ++-
 3 files changed, 12 insertions(+), 8 deletions(-)
Show changes to 3 files +12 −8

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

diff --git a/Documentation/config.txt b/Documentation/config.txt
index da18a54..5ba3ffa 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -640,10 +640,11 @@ fetch.unpackLimit::
 	`transfer.unpackLimit` is used instead.
 
 format.numbered::
-	A boolean which can enable sequence numbers in patch subjects.
-	Setting this option to "auto" will enable it only if there is
-	more than one patch.  See --numbered option in
-	linkgit:git-format-patch[1].
+	A boolean which can enable or disable sequence numbers in patch
+	subjects.  It defaults to "auto" which enables it only if there
+	is more than one patch.  It can be enabled or disabled for all
+	messages by setting it to "true" or "false".  See --numbered
+	option in linkgit:git-format-patch[1].
 
 format.headers::
 	Additional email headers to include in a patch to be submitted
diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index adb4ea7..ac36ce8 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -58,8 +58,10 @@ output, unless the --stdout option is specified.
 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".
+By default, the subject of a single patch is "[PATCH] First Line" and
+the subject when multiple patches are output is "[PATCH n/m] First
+Line". To force 1/1 to be added for a single patch, use -n.  To omit
+patch numbers from the subject, use -N
 
 If given --thread, 'git-format-patch' will generate In-Reply-To and
 References headers to make the second and subsequent patch mails appear
@@ -81,7 +83,7 @@ include::diff-options.txt[]
 
 -n::
 --numbered::
-	Name output in '[PATCH n/m]' format.
+	Name output in '[PATCH n/m]' format, even with a single patch.
 
 -N::
 --no-numbered::
diff --git a/builtin-log.c b/builtin-log.c
index fc5e4da..93987ee 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -426,7 +426,7 @@ static int istitlechar(char c)
 
 static const char *fmt_patch_suffix = ".patch";
 static int numbered = 0;
-static int auto_number = 0;
+static int auto_number = 1;
 
 static char **extra_hdr;
 static int extra_hdr_nr;
@@ -485,6 +485,7 @@ static int git_format_config(const char *var, const char *value, void *cb)
 			return 0;
 		}
 		numbered = git_config_bool(var, value);
+		auto_number &&= numbered;
 		return 0;
 	}
 
-- 
1.6.0.2.589.gcd70
Brian Gernhardt· Oct 2, 2008, 20:50 UTC · re: Brian Gernhardt · lore

Okay, I should wait for my test build to finish before I send the patch. This doesn't build. Nor does it pass the tests, since they test the old behavior.

I'll fix the build error, but I'm not inclined to spend the time fixing the tests since I don't actually care about changing the default.

On Oct 2, 2008, at 4:41 PM, Brian Gernhardt wrote:
Show 104 quoted lines
>
> format-patch is most commonly used for multiple patches at once when
> sending a patchset, in which case we want to number the patches; on
> the other hand, single patches are not usually expected to be
> numbered.
>
> In other words, the typical behavior expected from format-patch is the
> one obtained by enabling autonumber, so we set it to be the default.
>
> Users that want to disable numbering for a particular patchset can do
> so with the existing -N command-line switch.  Users that want to
> change the default behavior can use the format.numbering config key.
>
> Signed-off-by: Brian Gernhardt <benji@silverinsanity.com>
> ---
>
> This is what I was talking about.  The appropriate setting to turn  
> it off is
> "false", not "noauto".
>
> Re-sending with the correct CC list.
>
> Documentation/config.txt           |    9 +++++----
> Documentation/git-format-patch.txt |    8 +++++---
> builtin-log.c                      |    3 ++-
> 3 files changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> index da18a54..5ba3ffa 100644
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
> @@ -640,10 +640,11 @@ fetch.unpackLimit::
> 	`transfer.unpackLimit` is used instead.
>
> format.numbered::
> -	A boolean which can enable sequence numbers in patch subjects.
> -	Setting this option to "auto" will enable it only if there is
> -	more than one patch.  See --numbered option in
> -	linkgit:git-format-patch[1].
> +	A boolean which can enable or disable sequence numbers in patch
> +	subjects.  It defaults to "auto" which enables it only if there
> +	is more than one patch.  It can be enabled or disabled for all
> +	messages by setting it to "true" or "false".  See --numbered
> +	option in linkgit:git-format-patch[1].
>
> format.headers::
> 	Additional email headers to include in a patch to be submitted
> diff --git a/Documentation/git-format-patch.txt b/Documentation/git- 
> format-patch.txt
> index adb4ea7..ac36ce8 100644
> --- a/Documentation/git-format-patch.txt
> +++ b/Documentation/git-format-patch.txt
> @@ -58,8 +58,10 @@ output, unless the --stdout option is specified.
> 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".
> +By default, the subject of a single patch is "[PATCH] First Line" and
> +the subject when multiple patches are output is "[PATCH n/m] First
> +Line". To force 1/1 to be added for a single patch, use -n.  To omit
> +patch numbers from the subject, use -N
>
> If given --thread, 'git-format-patch' will generate In-Reply-To and
> References headers to make the second and subsequent patch mails  
> appear
> @@ -81,7 +83,7 @@ include::diff-options.txt[]
>
> -n::
> --numbered::
> -	Name output in '[PATCH n/m]' format.
> +	Name output in '[PATCH n/m]' format, even with a single patch.
>
> -N::
> --no-numbered::
> diff --git a/builtin-log.c b/builtin-log.c
> index fc5e4da..93987ee 100644
> --- a/builtin-log.c
> +++ b/builtin-log.c
> @@ -426,7 +426,7 @@ static int istitlechar(char c)
>
> static const char *fmt_patch_suffix = ".patch";
> static int numbered = 0;
> -static int auto_number = 0;
> +static int auto_number = 1;
>
> static char **extra_hdr;
> static int extra_hdr_nr;
> @@ -485,6 +485,7 @@ static int git_format_config(const char *var,  
> const char *value, void *cb)
> 			return 0;
> 		}
> 		numbered = git_config_bool(var, value);
> +		auto_number &&= numbered;
> 		return 0;
> 	}
>
> -- 
> 1.6.0.2.589.gcd70
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Brian Gernhardt· Oct 2, 2008, 20:55 UTC · re: Brian Gernhardt · lore

[PATCH v2] format-patch: autonumber by default

format-patch is most commonly used for multiple patches at once when sending a patchset, in which case we want to number the patches; on the other hand, single patches are not usually expected to be numbered.

In other words, the typical behavior expected from format-patch is the one obtained by enabling autonumber, so we set it to be the default.

Users that want to disable numbering for a particular patchset can do so with the existing -N command-line switch. Users that want to change the default behavior can use the format.numbering config key.

Signed-off-by: Brian Gernhardt <benji@silverinsanity.com>
---
 _This_ patch changes the default and makes the config variable act
 properly.  Does not pass tests.  4014 and 4021 would have to be
 updated for the new defaults.
 Documentation/config.txt           |    9 +++++----
 Documentation/git-format-patch.txt |    8 +++++---
 builtin-log.c                      |    3 ++-
 3 files changed, 12 insertions(+), 8 deletions(-)
Show changes to 3 files +12 −8

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

diff --git a/Documentation/config.txt b/Documentation/config.txt
index da18a54..5ba3ffa 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -640,10 +640,11 @@ fetch.unpackLimit::
 	`transfer.unpackLimit` is used instead.
 
 format.numbered::
-	A boolean which can enable sequence numbers in patch subjects.
-	Setting this option to "auto" will enable it only if there is
-	more than one patch.  See --numbered option in
-	linkgit:git-format-patch[1].
+	A boolean which can enable or disable sequence numbers in patch
+	subjects.  It defaults to "auto" which enables it only if there
+	is more than one patch.  It can be enabled or disabled for all
+	messages by setting it to "true" or "false".  See --numbered
+	option in linkgit:git-format-patch[1].
 
 format.headers::
 	Additional email headers to include in a patch to be submitted
diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index adb4ea7..ac36ce8 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -58,8 +58,10 @@ output, unless the --stdout option is specified.
 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".
+By default, the subject of a single patch is "[PATCH] First Line" and
+the subject when multiple patches are output is "[PATCH n/m] First
+Line". To force 1/1 to be added for a single patch, use -n.  To omit
+patch numbers from the subject, use -N
 
 If given --thread, 'git-format-patch' will generate In-Reply-To and
 References headers to make the second and subsequent patch mails appear
@@ -81,7 +83,7 @@ include::diff-options.txt[]
 
 -n::
 --numbered::
-	Name output in '[PATCH n/m]' format.
+	Name output in '[PATCH n/m]' format, even with a single patch.
 
 -N::
 --no-numbered::
diff --git a/builtin-log.c b/builtin-log.c
index fc5e4da..ee7c34e 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -426,7 +426,7 @@ static int istitlechar(char c)
 
 static const char *fmt_patch_suffix = ".patch";
 static int numbered = 0;
-static int auto_number = 0;
+static int auto_number = 1;
 
 static char **extra_hdr;
 static int extra_hdr_nr;
@@ -485,6 +485,7 @@ static int git_format_config(const char *var, const char *value, void *cb)
 			return 0;
 		}
 		numbered = git_config_bool(var, value);
+		auto_number = auto_number && numbered;
 		return 0;
 	}
 
-- 
1.6.0.2.589.gcd70
Eric W. Biederman· Nov 4, 2009, 11:20 UTC · re: Brian Gernhardt · lore

Re: [PATCH v2] format-patch: autonumber by default

Brian Gernhardt <benji@silverinsanity.com> writes:
Show 14 quoted lines
> format-patch is most commonly used for multiple patches at once when
> sending a patchset, in which case we want to number the patches; on
> the other hand, single patches are not usually expected to be
> numbered.
>
> In other words, the typical behavior expected from format-patch is the
> one obtained by enabling autonumber, so we set it to be the default.
>
> Users that want to disable numbering for a particular patchset can do
> so with the existing -N command-line switch.  Users that want to
> change the default behavior can use the format.numbering config key.
>
> Signed-off-by: Brian Gernhardt <benji@silverinsanity.com>
> ---

Grumble. I updated git last night and this change just bit me. Grumble. Grumble.

It is probably a good change, but it was unexpected. Grumble. Grumble. Grumble.

Eric
Junio C Hamano· Nov 4, 2009, 17:38 UTC · re: Eric W. Biederman · lore

Re: [PATCH v2] format-patch: autonumber by default

ebiederm@xmission.com (Eric W. Biederman) writes:
Show 24 quoted lines
> Brian Gernhardt <benji@silverinsanity.com> writes:
>
>> format-patch is most commonly used for multiple patches at once when
>> sending a patchset, in which case we want to number the patches; on
>> the other hand, single patches are not usually expected to be
>> numbered.
>>
>> In other words, the typical behavior expected from format-patch is the
>> one obtained by enabling autonumber, so we set it to be the default.
>>
>> Users that want to disable numbering for a particular patchset can do
>> so with the existing -N command-line switch.  Users that want to
>> change the default behavior can use the format.numbering config key.
>>
>> Signed-off-by: Brian Gernhardt <benji@silverinsanity.com>
>> ---
>
>
> Grumble.  I updated git last night and this change just bit me.
> Grumble.
> Grumble.
>
> It is probably a good change, but it was unexpected.
> Grumble. Grumble. Grumble.
That change was in 1.6.1.1 or so, no?  Welcome to year 2009 ;-)
Out of curiousity, which version did you update _from_?
Brian Gernhardt· Nov 4, 2009, 17:48 UTC · re: Eric W. Biederman · lore

Re: [PATCH v2] format-patch: autonumber by default

On Nov 4, 2009, at 6:20 AM, Eric W. Biederman wrote:
Show 6 quoted lines
> Grumble.  I updated git last night and this change just bit me.
> Grumble.
> Grumble.
>
> It is probably a good change, but it was unexpected.
> Grumble. Grumble. Grumble.

The change is a year old, and mentioned in the release notes from 1.6.1. If you're updating from old versions of git, it can be extremely useful to read the release notes as we do periodically have changes like this. (In the git repository, they can be found as Documentation/RelNotes-*.txt)

If you wish to go back to the old default for a single project, use `git config format.numbered false`. If you use the --global flag, it will set it for you all the time. For a single set of unrelated patches being output at once, use the --no-numbered (short: -N) option to format-patch.

Sorry it caught you unawares. Having it auto-number seemed like the most useful default.

~~ Brian
Andreas Ericsson· Oct 2, 2008, 13:43 UTC · re: Giuseppe Bilotta · lore
Giuseppe Bilotta wrote:
Show 22 quoted lines
> On Thu, Oct 2, 2008 at 2:33 PM, Johannes Schindelin
> <Johannes.Schindelin@gmx.de> wrote:
>> Hi,
>>
>> On Thu, 2 Oct 2008, Giuseppe Bilotta wrote:
>>
>>> Set auto-number true by default, allowing the format.number key to be
>>> set to 'noauto' to override this.
>>> ---
>>>  builtin-log.c |    6 +++++-
>>>  1 files changed, 5 insertions(+), 1 deletions(-)
>> Interesting.  No sign-off, no defense why this is actually desirable,
>> after we lived for so long without this behavior... Care to elaborate?
> 
> Doh, sorry about the Sign-off, I'll resend with.
> 
> Now, about the reason for this patch: I would say that the most common
> use-case of format-patch being used to prepare multiple patches is
> when one plans on sending a patchset. When format.numbering is set to
> auto, single-patches will still be extracted without numbers, but
> patchset will be properly numbered.
> 

I like it. It hasn't bitten me since I moved to imap-send, but when I used send-email I sometimes forgot and ended up sending patch-series without numbers.

I sent a patch for it once, but changed the default instead of making it configurable so it got turned down.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
Johannes Sixt· Oct 2, 2008, 13:54 UTC · re: Giuseppe Bilotta · lore
Giuseppe Bilotta schrieb:
Show 10 quoted lines
> Now, about the reason for this patch: I would say that the most common
> use-case of format-patch being used to prepare multiple patches is
> when one plans on sending a patchset. When format.numbering is set to
> auto, single-patches will still be extracted without numbers, but
> patchset will be properly numbered.
> 
> Of course, there may be cases where one doesn't want numbering (for
> which there is the -N flag already), and of course we want to give the
> user the choice to disable autonumbering at the config level, for
> which there is the new noauto option for format.numbering.

I recall that this has been discussed (months or years ago), but I don't recall whether there was a conclusion or whether the change was dismissed. Did you research the ML archives?

-- Hannes

← back to recent threads