@matheusbsbs / matheus-bagliano / commits / 49604a4d62
Fork 0

format-patch: Add configuration and off switch for --numbered

format.numbered is a tri-state variable. Boolean values enable or disable numbering by default and "auto" enables number when outputting more than one patch. --no-numbered (short: -N) will disable numbering. Signed-off-by: Brian Gernhardt <benji@silverinsanity.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brian Gernhardt committed Nov 3, 2007 at 23:38 UTC 49604a4d62d9055dbfc06472e7ef20d8a6114123
3 files changed +32 -5
Documentation/config.txt
+6
@@ -432,6 +432,12 @@ fetch.unpackLimit::
432 pack from a push can make the push operation complete faster,
433 especially on slow filesystems.
434
435 +format.numbered::
436 + A boolean which can enable sequence numbers in patch subjects.
437 + Seting this option to "auto" will enable it only if there is
438 + more than one patch. See --numbered option in
439 + gitlink:git-format-patch[1].
440 +
441 format.headers::
442 Additional email headers to include in a patch to be submitted
443 by mail. See gitlink:git-format-patch[1].
Documentation/git-format-patch.txt
+8 -4
@@ -9,7 +9,7 @@ git-format-patch - Prepare patches for e-mail submission
9 SYNOPSIS
10 --------
11 [verse]
12 -'git-format-patch' [-n | -k] [-o <dir> | --stdout] [--thread]
12 +'git-format-patch' [-n | -N | -k] [-o <dir> | --stdout] [--thread]
13 [--attach[=<boundary>] | --inline[=<boundary>]]
14 [-s | --signoff] [<common diff options>]
15 [--start-number <n>] [--numbered-files]
@@ -77,6 +77,9 @@ include::diff-options.txt[]
77 -n|--numbered::
78 Name output in '[PATCH n/m]' format.
79
80 +-N|--no-numbered::
81 + Name output in '[PATCH]' format.
82 +
83 --start-number <n>::
84 Start numbering the patches at <n> instead of 1.
85
@@ -142,15 +145,16 @@ not add any suffix.
145
146 CONFIGURATION
147 -------------
145 -You can specify extra mail header lines to be added to each
146 -message in the repository configuration. You can also specify
147 -new defaults for the subject prefix and file suffix.
148 +You can specify extra mail header lines to be added to each message
149 +in the repository configuration, new defaults for the subject prefix
150 +and file suffix, and number patches when outputting more than one.
151
152 ------------
153 [format]
154 headers = "Organization: git-foo\n"
155 subjectprefix = CHANGE
156 suffix = .txt
157 + numbered = auto
158 ------------
159
160
builtin-log.c
+18 -1
@@ -273,6 +273,8 @@ static int istitlechar(char c)
273 static char *extra_headers = NULL;
274 static int extra_headers_size = 0;
275 static const char *fmt_patch_suffix = ".patch";
276 +static int numbered = 0;
277 +static int auto_number = 0;
278
279 static int git_format_config(const char *var, const char *value)
280 {
@@ -297,6 +299,15 @@ static int git_format_config(const char *var, const char *value)
299 if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) {
300 return 0;
301 }
302 + if (!strcmp(var, "format.numbered")) {
303 + if (!strcasecmp(value, "auto")) {
304 + auto_number = 1;
305 + return 0;
306 + }
307 +
308 + numbered = git_config_bool(var, value);
309 + return 0;
310 + }
311
312 return git_log_config(var, value);
313 }
@@ -466,7 +477,6 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
477 struct rev_info rev;
478 int nr = 0, total, i, j;
479 int use_stdout = 0;
469 - int numbered = 0;
480 int start_number = -1;
481 int keep_subject = 0;
482 int numbered_files = 0; /* _just_ numbers */
@@ -503,6 +513,11 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
513 else if (!strcmp(argv[i], "-n") ||
514 !strcmp(argv[i], "--numbered"))
515 numbered = 1;
516 + else if (!strcmp(argv[i], "-N") ||
517 + !strcmp(argv[i], "--no-numbered")) {
518 + numbered = 0;
519 + auto_number = 0;
520 + }
521 else if (!prefixcmp(argv[i], "--start-number="))
522 start_number = strtol(argv[i] + 15, NULL, 10);
523 else if (!strcmp(argv[i], "--numbered-files"))
@@ -642,6 +657,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
657 list[nr - 1] = commit;
658 }
659 total = nr;
660 + if (!keep_subject && auto_number && total > 1)
661 + numbered = 1;
662 if (numbered)
663 rev.total = total + start_number - 1;
664 rev.add_signoff = add_signoff;