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 <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Taylor Blau committed
Oct 24, 2022 at 14:55 UTC
10538e2a627b8ab14f977c868f2975a2acb4ed4d
3 files changed
+8
-1
builtin/log.c
+1
@@ -1334,6 +1334,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
1334
log.in2 = 4;
1335
log.file = rev->diffopt.file;
1336
log.groups = SHORTLOG_GROUP_AUTHOR;
1337
+ shortlog_finish_setup(&log);
1338
for (i = 0; i < nr; i++)
1339
shortlog_add_commit(&log, list[i]);
1340
builtin/shortlog.c
+6
-1
@@ -381,6 +381,11 @@ void shortlog_init(struct shortlog *log)
381
log->format.strdup_strings = 1;
382
}
383
384
+void shortlog_finish_setup(struct shortlog *log)
385
+{
386
+ string_list_sort(&log->trailers);
387
+}
388
+
389
int cmd_shortlog(int argc, const char **argv, const char *prefix)
390
{
391
struct shortlog log = { STRING_LIST_INIT_NODUP };
@@ -450,7 +455,7 @@ parse_done:
455
456
if (!log.groups)
457
log.groups = SHORTLOG_GROUP_AUTHOR;
453
- string_list_sort(&log.trailers);
458
+ shortlog_finish_setup(&log);
459
460
/* assume HEAD if from a tty */
461
if (!nongit && !rev.pending.nr && isatty(0))
shortlog.h
+1
@@ -33,6 +33,7 @@ struct shortlog {
33
};
34
35
void shortlog_init(struct shortlog *log);
36
+void shortlog_finish_setup(struct shortlog *log);
37
38
void shortlog_add_commit(struct shortlog *log, struct commit *commit);
39