]> git.ipfire.org Git - thirdparty/git.git/commitdiff
shortlog: extract `shortlog_finish_setup()`
authorTaylor Blau <me@ttaylorr.com>
Mon, 24 Oct 2022 18:55:41 +0000 (14:55 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 24 Oct 2022 21:48:05 +0000 (14:48 -0700)
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>
builtin/log.c
builtin/shortlog.c
shortlog.h

index ee19dc5d450c57df89a864767a2b4f17d933781d..b4d542021752993efa048e3d0d8cbc80e95c5300 100644 (file)
@@ -1334,6 +1334,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
        log.in2 = 4;
        log.file = rev->diffopt.file;
        log.groups = SHORTLOG_GROUP_AUTHOR;
+       shortlog_finish_setup(&log);
        for (i = 0; i < nr; i++)
                shortlog_add_commit(&log, list[i]);
 
index f3b237c5ff08e07a9c37e12c63c34886aad8ac8b..808bae9baa4343e851deac3bccfe6beca9b7b66b 100644 (file)
@@ -381,6 +381,11 @@ void shortlog_init(struct shortlog *log)
        log->format.strdup_strings = 1;
 }
 
+void shortlog_finish_setup(struct shortlog *log)
+{
+       string_list_sort(&log->trailers);
+}
+
 int cmd_shortlog(int argc, const char **argv, const char *prefix)
 {
        struct shortlog log = { STRING_LIST_INIT_NODUP };
@@ -450,7 +455,7 @@ parse_done:
 
        if (!log.groups)
                log.groups = SHORTLOG_GROUP_AUTHOR;
-       string_list_sort(&log.trailers);
+       shortlog_finish_setup(&log);
 
        /* assume HEAD if from a tty */
        if (!nongit && !rev.pending.nr && isatty(0))
index 4850a8c30f9e3f429237bce73e31f3d85f6ed59a..28d04f951af73d8f9bdf58f6100a5eb3fe51b72c 100644 (file)
@@ -33,6 +33,7 @@ struct shortlog {
 };
 
 void shortlog_init(struct shortlog *log);
+void shortlog_finish_setup(struct shortlog *log);
 
 void shortlog_add_commit(struct shortlog *log, struct commit *commit);