Skip to content

Commit

Permalink
format-patch: don't pass on the --quiet flag
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Carlos Martín Nieto authored and Junio C Hamano committed Apr 12, 2011
1 parent ff46a49 commit 250087f
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions builtin/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ static FILE *realstdout = NULL;
static const char *output_directory = NULL;
static int outdir_offset;

static int reopen_stdout(struct commit *commit, struct rev_info *rev)
static int reopen_stdout(struct commit *commit, struct rev_info *rev, int quiet)
{
struct strbuf filename = STRBUF_INIT;
int suffix_len = strlen(fmt_patch_suffix) + 1;
Expand All @@ -639,7 +639,7 @@ static int reopen_stdout(struct commit *commit, struct rev_info *rev)

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

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

if (freopen(filename.buf, "w", stdout) == NULL)
Expand Down Expand Up @@ -718,7 +718,8 @@ static void print_signature(void)
static void make_cover_letter(struct rev_info *rev, int use_stdout,
int numbered, int numbered_files,
struct commit *origin,
int nr, struct commit **list, struct commit *head)
int nr, struct commit **list, struct commit *head,
int quiet)
{
const char *committer;
const char *subject_start = NULL;
Expand Down Expand Up @@ -754,7 +755,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
sha1_to_hex(head->object.sha1), committer, committer);
}

if (!use_stdout && reopen_stdout(commit, rev))
if (!use_stdout && reopen_stdout(commit, rev, quiet))
return;

if (commit) {
Expand Down Expand Up @@ -995,6 +996,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
char *add_signoff = NULL;
struct strbuf buf = STRBUF_INIT;
int use_patch_format = 0;
int quiet = 0;
const struct option builtin_format_patch_options[] = {
{ OPTION_CALLBACK, 'n', "numbered", &numbered, NULL,
"use [PATCH n/m] even with a single patch",
Expand Down Expand Up @@ -1050,6 +1052,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
PARSE_OPT_OPTARG, thread_callback },
OPT_STRING(0, "signature", &signature, "signature",
"add a signature"),
OPT_BOOLEAN(0, "quiet", &quiet,
"don't print the patch filenames"),
OPT_END()
};

Expand Down Expand Up @@ -1259,7 +1263,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
if (thread)
gen_message_id(&rev, "cover");
make_cover_letter(&rev, use_stdout, numbered, numbered_files,
origin, nr, list, head);
origin, nr, list, head, quiet);
total++;
start_number--;
}
Expand Down Expand Up @@ -1305,7 +1309,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
}

if (!use_stdout && reopen_stdout(numbered_files ? NULL : commit,
&rev))
&rev, quiet))
die(_("Failed to create output files"));
shown = log_tree_commit(&rev, commit);
free(commit->buffer);
Expand Down

0 comments on commit 250087f

Please sign in to comment.