37
38
#define MAIL_DEFAULT_WRAP 72
39
#define COVER_FROM_AUTO_MAX_SUBJECT_LEN 100
40
+#define FORMAT_PATCH_NAME_MAX_DEFAULT 64
41
42
/* Set a default date-time format for git log ("log.date" config variable) */
43
static const char *default_date_mode = NULL;
51
static int decoration_given;
52
static int use_mailmap_config = 1;
53
static const char *fmt_patch_subject_prefix = "PATCH";
54
+static int fmt_patch_name_max = FORMAT_PATCH_NAME_MAX_DEFAULT;
55
static const char *fmt_pretty;
56
57
static const char * const builtin_log_usage[] = {
152
rev->abbrev_commit = default_abbrev_commit;
153
rev->show_root_diff = default_show_root;
154
rev->subject_prefix = fmt_patch_subject_prefix;
155
+ rev->patch_name_max = fmt_patch_name_max;
156
rev->show_signature = default_show_signature;
157
rev->encode_email_headers = default_encode_email_headers;
158
rev->diffopt.flags.allow_textconv = 1;
457
return git_config_string(&fmt_pretty, var, value);
458
if (!strcmp(var, "format.subjectprefix"))
459
return git_config_string(&fmt_patch_subject_prefix, var, value);
460
+ if (!strcmp(var, "format.filenamemaxlength")) {
461
+ fmt_patch_name_max = git_config_int(var, value);
462
+ return 0;
463
+ }
464
if (!strcmp(var, "format.encodeemailheaders")) {
465
default_encode_email_headers = git_config_bool(var, value);
466
return 0;
962
struct rev_info *rev, int quiet)
963
{
964
struct strbuf filename = STRBUF_INIT;
958
- int suffix_len = strlen(rev->patch_suffix) + 1;
965
966
if (output_directory) {
967
strbuf_addstr(&filename, output_directory);
962
- if (filename.len >=
963
- PATH_MAX - FORMAT_PATCH_NAME_MAX - suffix_len) {
964
- strbuf_release(&filename);
965
- return error(_("name of output directory is too long"));
966
- }
968
strbuf_complete(&filename, '/');
969
}
970
1752
N_("start numbering patches at <n> instead of 1")),
1753
OPT_INTEGER('v', "reroll-count", &reroll_count,
1754
N_("mark the series as Nth re-roll")),
1755
+ OPT_INTEGER(0, "filename-max-length", &fmt_patch_name_max,
1756
+ N_("max length of output filename")),
1757
OPT_CALLBACK_F(0, "rfc", &rev, NULL,
1758
N_("Use [RFC PATCH] instead of [PATCH]"),
1759
PARSE_OPT_NOARG | PARSE_OPT_NONEG, rfc_callback),
1854
PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN |
1855
PARSE_OPT_KEEP_DASHDASH);
1856
1857
+ /* Make sure "0000-$sub.patch" gives non-negative length for $sub */
1858
+ if (fmt_patch_name_max <= strlen("0000-") + strlen(fmt_patch_suffix))
1859
+ fmt_patch_name_max = strlen("0000-") + strlen(fmt_patch_suffix);
1860
+
1861
if (cover_from_description_arg)
1862
cover_from_description_mode = parse_cover_from_description(cover_from_description_arg);
1863
1942
rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
1943
1944
rev.zero_commit = zero_commit;
1945
+ rev.patch_name_max = fmt_patch_name_max;
1946
1947
if (!rev.diffopt.flags.text && !no_binary_diff)
1948
rev.diffopt.flags.binary = 1;