]> git.ipfire.org Git - thirdparty/git.git/commitdiff
rebase-update-refs: extract load_branch_decorations
authorNicolas Guichard <nicolas@guichard.eu>
Wed, 9 Oct 2024 07:58:19 +0000 (07:58 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 9 Oct 2024 17:52:45 +0000 (10:52 -0700)
Extract load_branch_decorations from todo_list_add_update_ref_commands so
it can be re-used in make_script_with_merges.

Since it can now be called multiple times, use non-static lists and place
it next to load_ref_decorations to re-use the decoration_loaded guard.

Signed-off-by: Nicolas Guichard <nicolas@guichard.eu>
Acked-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
log-tree.c
log-tree.h
sequencer.c

index c65ebd2920207e8b3906fa3009df8466f133e8c8..bf6d2ae40c855409bade8afaaf97ccf1cb4789d7 100644 (file)
@@ -248,6 +248,27 @@ void load_ref_decorations(struct decoration_filter *filter, int flags)
        }
 }
 
+void load_branch_decorations(void)
+{
+       if (!decoration_loaded) {
+               struct string_list decorate_refs_exclude = STRING_LIST_INIT_NODUP;
+               struct string_list decorate_refs_exclude_config = STRING_LIST_INIT_NODUP;
+               struct string_list decorate_refs_include = STRING_LIST_INIT_NODUP;
+               struct decoration_filter decoration_filter = {
+                       .include_ref_pattern = &decorate_refs_include,
+                       .exclude_ref_pattern = &decorate_refs_exclude,
+                       .exclude_ref_config_pattern = &decorate_refs_exclude_config,
+               };
+
+               string_list_append(&decorate_refs_include, "refs/heads/");
+               load_ref_decorations(&decoration_filter, 0);
+
+               string_list_clear(&decorate_refs_exclude, 0);
+               string_list_clear(&decorate_refs_exclude_config, 0);
+               string_list_clear(&decorate_refs_include, 0);
+       }
+}
+
 static void show_parents(struct commit *commit, int abbrev, FILE *file)
 {
        struct commit_list *p;
index 94978e2c838ce98bdd442006b942cce38e2ef6c8..ebe491c543cfab55fa03aaa382501f72a2b0119e 100644 (file)
@@ -33,6 +33,7 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
                             int *need_8bit_cte_p,
                             int maybe_multipart);
 void load_ref_decorations(struct decoration_filter *filter, int flags);
+void load_branch_decorations(void);
 
 void fmt_output_commit(struct strbuf *, struct commit *, struct rev_info *);
 void fmt_output_subject(struct strbuf *, const char *subject, struct rev_info *);
index 8d01cd50ac943cbd6fce52e6243b0ee6c253b7c0..97959036b50498a43ee4867e526496b8e6698fd8 100644 (file)
@@ -6403,14 +6403,6 @@ static int add_decorations_to_list(const struct commit *commit,
 static int todo_list_add_update_ref_commands(struct todo_list *todo_list)
 {
        int i, res;
-       static struct string_list decorate_refs_exclude = STRING_LIST_INIT_NODUP;
-       static struct string_list decorate_refs_exclude_config = STRING_LIST_INIT_NODUP;
-       static struct string_list decorate_refs_include = STRING_LIST_INIT_NODUP;
-       struct decoration_filter decoration_filter = {
-               .include_ref_pattern = &decorate_refs_include,
-               .exclude_ref_pattern = &decorate_refs_exclude,
-               .exclude_ref_config_pattern = &decorate_refs_exclude_config,
-       };
        struct todo_add_branch_context ctx = {
                .buf = &todo_list->buf,
                .refs_to_oids = STRING_LIST_INIT_DUP,
@@ -6419,8 +6411,7 @@ static int todo_list_add_update_ref_commands(struct todo_list *todo_list)
        ctx.items_alloc = 2 * todo_list->nr + 1;
        ALLOC_ARRAY(ctx.items, ctx.items_alloc);
 
-       string_list_append(&decorate_refs_include, "refs/heads/");
-       load_ref_decorations(&decoration_filter, 0);
+       load_branch_decorations();
 
        for (i = 0; i < todo_list->nr; ) {
                struct todo_item *item = &todo_list->items[i];