Skip to content

Commit 10538e2

Browse files
ttaylorrgitster
authored andcommitted
shortlog: extract shortlog_finish_setup()
Extract a function which finishes setting up the shortlog struct for use. The caller in `make_cover_letter()` does not care about trailer sorting, so it isn't strictly necessary to add a call there in this patch. But the next patch will add additional functionality to the new `shortlog_finish_setup()` function, which the caller in `make_cover_letter()` will care about. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3dc95e0 commit 10538e2

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

builtin/log.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
13341334
log.in2 = 4;
13351335
log.file = rev->diffopt.file;
13361336
log.groups = SHORTLOG_GROUP_AUTHOR;
1337+
shortlog_finish_setup(&log);
13371338
for (i = 0; i < nr; i++)
13381339
shortlog_add_commit(&log, list[i]);
13391340

builtin/shortlog.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,11 @@ void shortlog_init(struct shortlog *log)
381381
log->format.strdup_strings = 1;
382382
}
383383

384+
void shortlog_finish_setup(struct shortlog *log)
385+
{
386+
string_list_sort(&log->trailers);
387+
}
388+
384389
int cmd_shortlog(int argc, const char **argv, const char *prefix)
385390
{
386391
struct shortlog log = { STRING_LIST_INIT_NODUP };
@@ -450,7 +455,7 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
450455

451456
if (!log.groups)
452457
log.groups = SHORTLOG_GROUP_AUTHOR;
453-
string_list_sort(&log.trailers);
458+
shortlog_finish_setup(&log);
454459

455460
/* assume HEAD if from a tty */
456461
if (!nongit && !rev.pending.nr && isatty(0))

shortlog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct shortlog {
3333
};
3434

3535
void shortlog_init(struct shortlog *log);
36+
void shortlog_finish_setup(struct shortlog *log);
3637

3738
void shortlog_add_commit(struct shortlog *log, struct commit *commit);
3839

0 commit comments

Comments
 (0)