Skip to contentSkip to conversation

format-patch: autonumber by default

PATCH In review Giuseppe Bilotta 9 participants 21 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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(-)
builtin-log.c +5 -1
index fc5e4da..5187dc2 100644
@@ -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;
 	}
Signature · 1 line
1.5.6.5
#1 lore raw

Hi,

Quoted 5 lines · Giuseppe Bilotta

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

#2 lore raw
Quoted 4 lines · Johannes Schindelin

Hi,

On Thu, 2 Oct 2008, Giuseppe Bilotta wrote:

Quoted 8 lines
Quoted 5 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?

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 :)

Signature · 1 line
Giuseppe "Oblomov" Bilotta
#3 lore raw
Quoted 14 lines · Giuseppe Bilotta
Quoted 11 lines · Johannes Schindelin

Hi,

Quoted 5 lines · Giuseppe Bilotta

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?

Quoted 8 lines

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.

Signature · 3 lines
Andreas Ericsson                   [email protected]
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
#4 lore raw
In reply to Giuseppe Bilotta
Quoted 10 lines · Giuseppe Bilotta

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

#5 lore raw
In reply to Giuseppe Bilotta

Hi,

Quoted 22 lines · Giuseppe Bilotta
Quoted 10 lines · Johannes Schindelin
Quoted 5 lines · Giuseppe Bilotta

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.

Quoted 7 lines

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

#6 lore raw

PATCH 1/1 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.

---
 builtin-log.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
builtin-log.c +5 -1
index fc5e4da..5187dc2 100644
@@ -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;
 	}
Signature · 1 line
1.5.6.5
#7 lore raw
Quoted 1 line · Giuseppe Bilotta

format-patch is most commoly used for multiple patches at once when

s/commoly/commonly/;

I'm not sure about 'most' there...

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

Signature · 2 lines
Jakub Narebski
Poland
#8 lore raw
Quoted 6 lines · Jakub Narebski
Quoted 1 line · Giuseppe Bilotta

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.

Signature · 3 lines
Andreas Ericsson                   [email protected]
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
#9 lore raw

PATCH 1/1 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.

---
 builtin-log.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
builtin-log.c +5 -1
index fc5e4da..5187dc2 100644
@@ -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;
 	}
Signature · 1 line
1.5.6.5
#10 lore raw
Quoted 6 lines · Giuseppe Bilotta

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:

Quoted 3 lines
---
 builtin-log.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

Documentation update?

-Peff

#11 lore raw

PATCH 1/1 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.

---
 Documentation/config.txt           |    5 +++--
 Documentation/git-format-patch.txt |    9 ++++++---
 builtin-log.c                      |    6 +++++-
 3 files changed, 14 insertions(+), 6 deletions(-)
Documentation/config.txt +3 -2
index bbe38cc..9a9ed98 100644
@@ -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
Documentation/git-format-patch.txt +6 -3
index adb4ea7..d7be5bb 100644
@@ -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>
 ------------
 
builtin-log.c +5 -1
index fc5e4da..5187dc2 100644
@@ -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;
 	}
Signature · 1 line
1.5.6.5
#12 lore raw
Quoted 4 lines · Giuseppe Bilotta
 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(-)
t/t4021-format-patch-numbered.sh +10 -5
index 43d64bb..390af23 100755
@@ -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
 
 '
 
Signature · 1 line
1.6.0.2.570.g2c958
#13 lore raw
In reply to Giuseppe Bilotta
Quoted 24 lines · Giuseppe Bilotta
builtin-log.c +5 -1
index fc5e4da..5187dc2 100644
@@ -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;
Quoted 1 line

}

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

#14 lore raw

PATCH 1/1 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.

---

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(-)
Documentation/config.txt +5 -4
index da18a54..5ba3ffa 100644
@@ -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
Documentation/git-format-patch.txt +5 -3
index adb4ea7..ac36ce8 100644
@@ -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::
builtin-log.c +2 -1
index fc5e4da..93987ee 100644
@@ -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;
 	}
 
Signature · 1 line
1.6.0.2.589.gcd70
#15 lore raw

PATCH 1/1 format-patch: autonumber by default

In reply to Brian Gernhardt

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.

---

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(-)
Documentation/config.txt +5 -4
index da18a54..5ba3ffa 100644
@@ -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
Documentation/git-format-patch.txt +5 -3
index adb4ea7..ac36ce8 100644
@@ -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::
builtin-log.c +2 -1
index fc5e4da..93987ee 100644
@@ -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;
 	}
 
Signature · 1 line
1.6.0.2.589.gcd70
#16 lore raw

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.

Quoted 101 lines · Brian Gernhardt

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.

---

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(-)
Documentation/config.txt +0 -0
index da18a54..5ba3ffa 100644
@@ -640,10 +640,11 @@ fetch.unpackLimit::
 	`transfer.unpackLimit` is used instead.
 

format.numbered::

Documentation/config.txt +5 -4
-	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

Documentation/git-format-patch.txt +0 -0
index adb4ea7..ac36ce8 100644
@@ -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.

Documentation/git-format-patch.txt +4 -2
-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

Documentation/git-format-patch.txt +1 -5
@@ -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::
builtin-log.c +2 -1
index fc5e4da..93987ee 100644
@@ -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;
 	}
Signature · 7 lines
-- 
1.6.0.2.589.gcd70

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#17 lore raw

PATCH v2 1/1 format-patch: autonumber by default

In reply to Brian Gernhardt

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.

---

_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(-)
Documentation/config.txt +5 -4
index da18a54..5ba3ffa 100644
@@ -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
Documentation/git-format-patch.txt +5 -3
index adb4ea7..ac36ce8 100644
@@ -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::
builtin-log.c +2 -1
index fc5e4da..ee7c34e 100644
@@ -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;
 	}
 
Signature · 1 line
1.6.0.2.589.gcd70
#18 lore raw
Quoted 8 lines · Brian Gernhardt

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.

Quoted 6 lines

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.

---

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

#19 lore raw
Quoted 18 lines · [email protected] (Eric W. Biederman) writes:
Quoted 8 lines · Brian Gernhardt

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.

Quoted 6 lines

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.

---

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

That change was in 1.6.1.1 or so, no? Welcome to year 2009 ;-)

Out of curiousity, which version did you update _from_?

#20 lore raw
In reply to Eric W. Biederman
Quoted 6 lines · Eric W. Biederman

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