Skip to content

Commit ec2956d

Browse files
Nate Casegitster
authored andcommitted
format-patch: Respect --quiet option
Hide the patch filename output from 'git format-patch' when --quiet is used. The man pages suggested that this should have already worked. Signed-off-by: Nate Case <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e986ceb commit ec2956d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

builtin-log.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ static FILE *realstdout = NULL;
573573
static const char *output_directory = NULL;
574574
static int outdir_offset;
575575

576-
static int reopen_stdout(const char *oneline, int nr, int total)
576+
static int reopen_stdout(const char *oneline, int nr, struct rev_info *rev)
577577
{
578578
char filename[PATH_MAX];
579579
int len = 0;
@@ -598,7 +598,9 @@ static int reopen_stdout(const char *oneline, int nr, int total)
598598
strcpy(filename + len, fmt_patch_suffix);
599599
}
600600

601-
fprintf(realstdout, "%s\n", filename + outdir_offset);
601+
if (!DIFF_OPT_TST(&rev->diffopt, QUIET))
602+
fprintf(realstdout, "%s\n", filename + outdir_offset);
603+
602604
if (freopen(filename, "w", stdout) == NULL)
603605
return error("Cannot open patch file %s",filename);
604606

@@ -687,7 +689,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
687689
die("Cover letter needs email format");
688690

689691
if (!use_stdout && reopen_stdout(numbered_files ?
690-
NULL : "cover-letter", 0, rev->total))
692+
NULL : "cover-letter", 0, rev))
691693
return;
692694

693695
head_sha1 = sha1_to_hex(head->object.sha1);
@@ -1106,7 +1108,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
11061108
}
11071109
if (!use_stdout && reopen_stdout(numbered_files ? NULL :
11081110
get_oneline_for_filename(commit, keep_subject),
1109-
rev.nr, rev.total))
1111+
rev.nr, &rev))
11101112
die("Failed to create output files");
11111113
shown = log_tree_commit(&rev, commit);
11121114
free(commit->buffer);

0 commit comments

Comments
 (0)