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>
This commit is contained in:
parent
140dd77a5c
commit
49604a4d62
@ -432,6 +432,12 @@ fetch.unpackLimit::
|
|||||||
pack from a push can make the push operation complete faster,
|
pack from a push can make the push operation complete faster,
|
||||||
especially on slow filesystems.
|
especially on slow filesystems.
|
||||||
|
|
||||||
|
format.numbered::
|
||||||
|
A boolean which can enable sequence numbers in patch subjects.
|
||||||
|
Seting this option to "auto" will enable it only if there is
|
||||||
|
more than one patch. See --numbered option in
|
||||||
|
gitlink:git-format-patch[1].
|
||||||
|
|
||||||
format.headers::
|
format.headers::
|
||||||
Additional email headers to include in a patch to be submitted
|
Additional email headers to include in a patch to be submitted
|
||||||
by mail. See gitlink:git-format-patch[1].
|
by mail. See gitlink:git-format-patch[1].
|
||||||
|
@ -9,7 +9,7 @@ git-format-patch - Prepare patches for e-mail submission
|
|||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
--------
|
--------
|
||||||
[verse]
|
[verse]
|
||||||
'git-format-patch' [-n | -k] [-o <dir> | --stdout] [--thread]
|
'git-format-patch' [-n | -N | -k] [-o <dir> | --stdout] [--thread]
|
||||||
[--attach[=<boundary>] | --inline[=<boundary>]]
|
[--attach[=<boundary>] | --inline[=<boundary>]]
|
||||||
[-s | --signoff] [<common diff options>]
|
[-s | --signoff] [<common diff options>]
|
||||||
[--start-number <n>] [--numbered-files]
|
[--start-number <n>] [--numbered-files]
|
||||||
@ -77,6 +77,9 @@ include::diff-options.txt[]
|
|||||||
-n|--numbered::
|
-n|--numbered::
|
||||||
Name output in '[PATCH n/m]' format.
|
Name output in '[PATCH n/m]' format.
|
||||||
|
|
||||||
|
-N|--no-numbered::
|
||||||
|
Name output in '[PATCH]' format.
|
||||||
|
|
||||||
--start-number <n>::
|
--start-number <n>::
|
||||||
Start numbering the patches at <n> instead of 1.
|
Start numbering the patches at <n> instead of 1.
|
||||||
|
|
||||||
@ -142,15 +145,16 @@ not add any suffix.
|
|||||||
|
|
||||||
CONFIGURATION
|
CONFIGURATION
|
||||||
-------------
|
-------------
|
||||||
You can specify extra mail header lines to be added to each
|
You can specify extra mail header lines to be added to each message
|
||||||
message in the repository configuration. You can also specify
|
in the repository configuration, new defaults for the subject prefix
|
||||||
new defaults for the subject prefix and file suffix.
|
and file suffix, and number patches when outputting more than one.
|
||||||
|
|
||||||
------------
|
------------
|
||||||
[format]
|
[format]
|
||||||
headers = "Organization: git-foo\n"
|
headers = "Organization: git-foo\n"
|
||||||
subjectprefix = CHANGE
|
subjectprefix = CHANGE
|
||||||
suffix = .txt
|
suffix = .txt
|
||||||
|
numbered = auto
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -273,6 +273,8 @@ static int istitlechar(char c)
|
|||||||
static char *extra_headers = NULL;
|
static char *extra_headers = NULL;
|
||||||
static int extra_headers_size = 0;
|
static int extra_headers_size = 0;
|
||||||
static const char *fmt_patch_suffix = ".patch";
|
static const char *fmt_patch_suffix = ".patch";
|
||||||
|
static int numbered = 0;
|
||||||
|
static int auto_number = 0;
|
||||||
|
|
||||||
static int git_format_config(const char *var, const char *value)
|
static int git_format_config(const char *var, const char *value)
|
||||||
{
|
{
|
||||||
@ -297,6 +299,15 @@ static int git_format_config(const char *var, const char *value)
|
|||||||
if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) {
|
if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (!strcmp(var, "format.numbered")) {
|
||||||
|
if (!strcasecmp(value, "auto")) {
|
||||||
|
auto_number = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
numbered = git_config_bool(var, value);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return git_log_config(var, value);
|
return git_log_config(var, value);
|
||||||
}
|
}
|
||||||
@ -466,7 +477,6 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
|||||||
struct rev_info rev;
|
struct rev_info rev;
|
||||||
int nr = 0, total, i, j;
|
int nr = 0, total, i, j;
|
||||||
int use_stdout = 0;
|
int use_stdout = 0;
|
||||||
int numbered = 0;
|
|
||||||
int start_number = -1;
|
int start_number = -1;
|
||||||
int keep_subject = 0;
|
int keep_subject = 0;
|
||||||
int numbered_files = 0; /* _just_ numbers */
|
int numbered_files = 0; /* _just_ numbers */
|
||||||
@ -503,6 +513,11 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
|||||||
else if (!strcmp(argv[i], "-n") ||
|
else if (!strcmp(argv[i], "-n") ||
|
||||||
!strcmp(argv[i], "--numbered"))
|
!strcmp(argv[i], "--numbered"))
|
||||||
numbered = 1;
|
numbered = 1;
|
||||||
|
else if (!strcmp(argv[i], "-N") ||
|
||||||
|
!strcmp(argv[i], "--no-numbered")) {
|
||||||
|
numbered = 0;
|
||||||
|
auto_number = 0;
|
||||||
|
}
|
||||||
else if (!prefixcmp(argv[i], "--start-number="))
|
else if (!prefixcmp(argv[i], "--start-number="))
|
||||||
start_number = strtol(argv[i] + 15, NULL, 10);
|
start_number = strtol(argv[i] + 15, NULL, 10);
|
||||||
else if (!strcmp(argv[i], "--numbered-files"))
|
else if (!strcmp(argv[i], "--numbered-files"))
|
||||||
@ -642,6 +657,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
|||||||
list[nr - 1] = commit;
|
list[nr - 1] = commit;
|
||||||
}
|
}
|
||||||
total = nr;
|
total = nr;
|
||||||
|
if (!keep_subject && auto_number && total > 1)
|
||||||
|
numbered = 1;
|
||||||
if (numbered)
|
if (numbered)
|
||||||
rev.total = total + start_number - 1;
|
rev.total = total + start_number - 1;
|
||||||
rev.add_signoff = add_signoff;
|
rev.add_signoff = add_signoff;
|
||||||
|
Loading…
Reference in New Issue
Block a user