get_patch_filename(): simplify function signature
Most functions that emit to a strbuf take the strbuf as their first parameter; make this function follow suit. The serial number of the patch being emitted (nr) and suffix used for patch filename (suffix) are both recorded in rev_info; drop these separate parameters and pass the rev_info directly. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Dec 21, 2012 at 23:26 UTC
021f2f4c1aed011c664844408325fe683a4046a8
3 files changed
+12
-7
builtin/log.c
+1
-1
@@ -684,7 +684,7 @@ static int reopen_stdout(struct commit *commit, const char *subject,
684
strbuf_addch(&filename, '/');
685
}
686
687
- get_patch_filename(commit, subject, rev->nr, rev->patch_suffix, &filename);
687
+ get_patch_filename(&filename, commit, subject, rev);
688
689
if (!quiet)
690
fprintf(realstdout, "%s\n", filename.buf + outdir_offset);
log-tree.c
+8
-4
@@ -299,9 +299,12 @@ static unsigned int digits_in_number(unsigned int number)
299
return result;
300
}
301
302
-void get_patch_filename(struct commit *commit, const char *subject, int nr,
303
- const char *suffix, struct strbuf *buf)
302
+void get_patch_filename(struct strbuf *buf,
303
+ struct commit *commit, const char *subject,
304
+ struct rev_info *info)
305
{
306
+ const char *suffix = info->patch_suffix;
307
+ int nr = info->nr;
308
int suffix_len = strlen(suffix) + 1;
309
int start_len = buf->len;
310
@@ -387,8 +390,9 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
390
mime_boundary_leader, opt->mime_boundary);
391
extra_headers = subject_buffer;
392
390
- get_patch_filename(opt->numbered_files ? NULL : commit, NULL,
391
- opt->nr, opt->patch_suffix, &filename);
393
+ get_patch_filename(&filename,
394
+ opt->numbered_files ? NULL : commit, NULL,
395
+ opt);
396
snprintf(buffer, sizeof(buffer) - 1,
397
"\n--%s%s\n"
398
"Content-Type: text/x-patch;"
log-tree.h
+3
-2
@@ -21,7 +21,8 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
21
void load_ref_decorations(int flags);
22
23
#define FORMAT_PATCH_NAME_MAX 64
24
-void get_patch_filename(struct commit *commit, const char *subject, int nr,
25
- const char *suffix, struct strbuf *buf);
24
+void get_patch_filename(struct strbuf *buf,
25
+ struct commit *commit, const char *subject,
26
+ struct rev_info *);
27
28
#endif