static int numbered = 0;
static int auto_number = 1;
+static char *default_attach = NULL;
+
static char **extra_hdr;
static int extra_hdr_nr;
static int extra_hdr_alloc;
auto_number = auto_number && numbered;
return 0;
}
+ if (!strcmp(var, "format.attach")) {
+ if (value && *value)
+ default_attach = xstrdup(value);
+ else
+ default_attach = xstrdup(git_version_string);
+ return 0;
+ }
if (!strcmp(var, "format.thread")) {
if (value && !strcasecmp(value, "deep")) {
thread = THREAD_DEEP;
static const char *output_directory = NULL;
static int outdir_offset;
-static int reopen_stdout(const char *oneline, int nr, int total)
+static int reopen_stdout(const char *oneline, int nr, struct rev_info *rev)
{
char filename[PATH_MAX];
int len = 0;
strcpy(filename + len, fmt_patch_suffix);
}
- fprintf(realstdout, "%s\n", filename + outdir_offset);
+ if (!DIFF_OPT_TST(&rev->diffopt, QUIET))
+ fprintf(realstdout, "%s\n", filename + outdir_offset);
+
if (freopen(filename, "w", stdout) == NULL)
return error("Cannot open patch file %s",filename);
die("Cover letter needs email format");
if (!use_stdout && reopen_stdout(numbered_files ?
- NULL : "cover-letter", 0, rev->total))
+ NULL : "cover-letter", 0, rev))
return;
head_sha1 = sha1_to_hex(head->object.sha1);
rev.subject_prefix = fmt_patch_subject_prefix;
+ if (default_attach) {
+ rev.mime_boundary = default_attach;
+ rev.no_inline = 1;
+ }
+
/*
* Parse the arguments before setup_revisions(), or something
* like "git format-patch -o a123 HEAD^.." may fail; a123 is
rev.mime_boundary = argv[i] + 9;
rev.no_inline = 1;
}
+ else if (!strcmp(argv[i], "--no-attach")) {
+ rev.mime_boundary = NULL;
+ rev.no_inline = 0;
+ }
else if (!strcmp(argv[i], "--inline")) {
rev.mime_boundary = git_version_string;
rev.no_inline = 0;
die ("-n and -k are mutually exclusive.");
if (keep_subject && subject_prefix)
die ("--subject-prefix and -k are mutually exclusive.");
- if (numbered_files && use_stdout)
- die ("--numbered-files and --stdout are mutually exclusive.");
argc = setup_revisions(argc, argv, &rev, "HEAD");
if (argc > 1)
}
if (!use_stdout && reopen_stdout(numbered_files ? NULL :
get_oneline_for_filename(commit, keep_subject),
- rev.nr, rev.total))
+ rev.nr, &rev))
die("Failed to create output files");
shown = log_tree_commit(&rev, commit);
free(commit->buffer);