get_patch_filename(): split into two functions

The function switched between two operating modes depending on the
NULL-ness of its two parameters, as a hacky way to share small part
of implementation, sacrificing cleanliness of the API.

Implement "fmt_output_subject()" function that takes a subject
string and gives the name for the output file, and on top of it,
implement "fmt_output_commit()" function that takes a commit and
gives the name for the output file.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano
2012-12-21 22:06:01 -08:00
parent 38ec23ac89
commit d28b5d47ab
3 changed files with 27 additions and 21 deletions

View File

@ -686,8 +686,10 @@ static int reopen_stdout(struct commit *commit, const char *subject,
if (rev->numbered_files)
strbuf_addf(&filename, "%d", rev->nr);
else if (commit)
fmt_output_commit(&filename, commit, rev);
else
get_patch_filename(&filename, commit, subject, rev);
fmt_output_subject(&filename, subject, rev);
if (!quiet)
fprintf(realstdout, "%s\n", filename.buf + outdir_offset);