format-patch: don't pass on the --quiet flag
The --quiet flag is not meant to be passed on to the diff, as the user always wants the patches to be produced so catch it and pass it to reopen_stdout which decides whether to print the filename or not. Noticed by Paul Gortmaker Signed-off-by: Carlos Martín Nieto <cmn@elego.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Carlos Martín Nieto committed
Apr 12, 2011 at 17:35 UTC
250087f2e5da8c066cf260c513478f19fa942c72
1 file changed
+10
-6
builtin/log.c
+10
-6
@@ -623,7 +623,7 @@ static FILE *realstdout = NULL;
623
static const char *output_directory = NULL;
624
static int outdir_offset;
625
626
-static int reopen_stdout(struct commit *commit, struct rev_info *rev)
626
+static int reopen_stdout(struct commit *commit, struct rev_info *rev, int quiet)
627
{
628
struct strbuf filename = STRBUF_INIT;
629
int suffix_len = strlen(fmt_patch_suffix) + 1;
@@ -639,7 +639,7 @@ static int reopen_stdout(struct commit *commit, struct rev_info *rev)
639
640
get_patch_filename(commit, rev->nr, fmt_patch_suffix, &filename);
641
642
- if (!DIFF_OPT_TST(&rev->diffopt, QUICK))
642
+ if (!quiet)
643
fprintf(realstdout, "%s\n", filename.buf + outdir_offset);
644
645
if (freopen(filename.buf, "w", stdout) == NULL)
@@ -718,7 +718,8 @@ static void print_signature(void)
718
static void make_cover_letter(struct rev_info *rev, int use_stdout,
719
int numbered, int numbered_files,
720
struct commit *origin,
721
- int nr, struct commit **list, struct commit *head)
721
+ int nr, struct commit **list, struct commit *head,
722
+ int quiet)
723
{
724
const char *committer;
725
const char *subject_start = NULL;
@@ -754,7 +755,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
755
sha1_to_hex(head->object.sha1), committer, committer);
756
}
757
757
- if (!use_stdout && reopen_stdout(commit, rev))
758
+ if (!use_stdout && reopen_stdout(commit, rev, quiet))
759
return;
760
761
if (commit) {
@@ -995,6 +996,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
996
char *add_signoff = NULL;
997
struct strbuf buf = STRBUF_INIT;
998
int use_patch_format = 0;
999
+ int quiet = 0;
1000
const struct option builtin_format_patch_options[] = {
1001
{ OPTION_CALLBACK, 'n', "numbered", &numbered, NULL,
1002
"use [PATCH n/m] even with a single patch",
@@ -1050,6 +1052,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1052
PARSE_OPT_OPTARG, thread_callback },
1053
OPT_STRING(0, "signature", &signature, "signature",
1054
"add a signature"),
1055
+ OPT_BOOLEAN(0, "quiet", &quiet,
1056
+ "don't print the patch filenames"),
1057
OPT_END()
1058
};
1059
@@ -1259,7 +1263,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1263
if (thread)
1264
gen_message_id(&rev, "cover");
1265
make_cover_letter(&rev, use_stdout, numbered, numbered_files,
1262
- origin, nr, list, head);
1266
+ origin, nr, list, head, quiet);
1267
total++;
1268
start_number--;
1269
}
@@ -1305,7 +1309,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1309
}
1310
1311
if (!use_stdout && reopen_stdout(numbered_files ? NULL : commit,
1308
- &rev))
1312
+ &rev, quiet))
1313
die(_("Failed to create output files"));
1314
shown = log_tree_commit(&rev, commit);
1315
free(commit->buffer);