Skip to content

Commit 250087f

Browse files
carlosmngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ff46a49 commit 250087f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

builtin/log.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ static FILE *realstdout = NULL;
623623
static const char *output_directory = NULL;
624624
static int outdir_offset;
625625

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)
627627
{
628628
struct strbuf filename = STRBUF_INIT;
629629
int suffix_len = strlen(fmt_patch_suffix) + 1;
@@ -639,7 +639,7 @@ static int reopen_stdout(struct commit *commit, struct rev_info *rev)
639639

640640
get_patch_filename(commit, rev->nr, fmt_patch_suffix, &filename);
641641

642-
if (!DIFF_OPT_TST(&rev->diffopt, QUICK))
642+
if (!quiet)
643643
fprintf(realstdout, "%s\n", filename.buf + outdir_offset);
644644

645645
if (freopen(filename.buf, "w", stdout) == NULL)
@@ -718,7 +718,8 @@ static void print_signature(void)
718718
static void make_cover_letter(struct rev_info *rev, int use_stdout,
719719
int numbered, int numbered_files,
720720
struct commit *origin,
721-
int nr, struct commit **list, struct commit *head)
721+
int nr, struct commit **list, struct commit *head,
722+
int quiet)
722723
{
723724
const char *committer;
724725
const char *subject_start = NULL;
@@ -754,7 +755,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
754755
sha1_to_hex(head->object.sha1), committer, committer);
755756
}
756757

757-
if (!use_stdout && reopen_stdout(commit, rev))
758+
if (!use_stdout && reopen_stdout(commit, rev, quiet))
758759
return;
759760

760761
if (commit) {
@@ -995,6 +996,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
995996
char *add_signoff = NULL;
996997
struct strbuf buf = STRBUF_INIT;
997998
int use_patch_format = 0;
999+
int quiet = 0;
9981000
const struct option builtin_format_patch_options[] = {
9991001
{ OPTION_CALLBACK, 'n', "numbered", &numbered, NULL,
10001002
"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)
10501052
PARSE_OPT_OPTARG, thread_callback },
10511053
OPT_STRING(0, "signature", &signature, "signature",
10521054
"add a signature"),
1055+
OPT_BOOLEAN(0, "quiet", &quiet,
1056+
"don't print the patch filenames"),
10531057
OPT_END()
10541058
};
10551059

@@ -1259,7 +1263,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
12591263
if (thread)
12601264
gen_message_id(&rev, "cover");
12611265
make_cover_letter(&rev, use_stdout, numbered, numbered_files,
1262-
origin, nr, list, head);
1266+
origin, nr, list, head, quiet);
12631267
total++;
12641268
start_number--;
12651269
}
@@ -1305,7 +1309,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
13051309
}
13061310

13071311
if (!use_stdout && reopen_stdout(numbered_files ? NULL : commit,
1308-
&rev))
1312+
&rev, quiet))
13091313
die(_("Failed to create output files"));
13101314
shown = log_tree_commit(&rev, commit);
13111315
free(commit->buffer);

0 commit comments

Comments
 (0)