Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 021f2f4

Browse files
committed
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 <[email protected]>
1 parent 68cb7b6 commit 021f2f4

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

builtin/log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ static int reopen_stdout(struct commit *commit, const char *subject,
684684
strbuf_addch(&filename, '/');
685685
}
686686

687-
get_patch_filename(commit, subject, rev->nr, rev->patch_suffix, &filename);
687+
get_patch_filename(&filename, commit, subject, rev);
688688

689689
if (!quiet)
690690
fprintf(realstdout, "%s\n", filename.buf + outdir_offset);

log-tree.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,12 @@ static unsigned int digits_in_number(unsigned int number)
299299
return result;
300300
}
301301

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)
304305
{
306+
const char *suffix = info->patch_suffix;
307+
int nr = info->nr;
305308
int suffix_len = strlen(suffix) + 1;
306309
int start_len = buf->len;
307310

@@ -387,8 +390,9 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
387390
mime_boundary_leader, opt->mime_boundary);
388391
extra_headers = subject_buffer;
389392

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);
392396
snprintf(buffer, sizeof(buffer) - 1,
393397
"\n--%s%s\n"
394398
"Content-Type: text/x-patch;"

log-tree.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
2121
void load_ref_decorations(int flags);
2222

2323
#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 *);
2627

2728
#endif

0 commit comments

Comments
 (0)