Git fork

rebase-update-refs: extract load_branch_decorations

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>

authored by

Nicolas Guichard and committed by
Junio C Hamano
68c9fcb0 e4d03b79

+23 -10
+21
log-tree.c
··· 248 248 } 249 249 } 250 250 251 + void load_branch_decorations(void) 252 + { 253 + if (!decoration_loaded) { 254 + struct string_list decorate_refs_exclude = STRING_LIST_INIT_NODUP; 255 + struct string_list decorate_refs_exclude_config = STRING_LIST_INIT_NODUP; 256 + struct string_list decorate_refs_include = STRING_LIST_INIT_NODUP; 257 + struct decoration_filter decoration_filter = { 258 + .include_ref_pattern = &decorate_refs_include, 259 + .exclude_ref_pattern = &decorate_refs_exclude, 260 + .exclude_ref_config_pattern = &decorate_refs_exclude_config, 261 + }; 262 + 263 + string_list_append(&decorate_refs_include, "refs/heads/"); 264 + load_ref_decorations(&decoration_filter, 0); 265 + 266 + string_list_clear(&decorate_refs_exclude, 0); 267 + string_list_clear(&decorate_refs_exclude_config, 0); 268 + string_list_clear(&decorate_refs_include, 0); 269 + } 270 + } 271 + 251 272 static void show_parents(struct commit *commit, int abbrev, FILE *file) 252 273 { 253 274 struct commit_list *p;
+1
log-tree.h
··· 33 33 int *need_8bit_cte_p, 34 34 int maybe_multipart); 35 35 void load_ref_decorations(struct decoration_filter *filter, int flags); 36 + void load_branch_decorations(void); 36 37 37 38 void fmt_output_commit(struct strbuf *, struct commit *, struct rev_info *); 38 39 void fmt_output_subject(struct strbuf *, const char *subject, struct rev_info *);
+1 -10
sequencer.c
··· 6403 6403 static int todo_list_add_update_ref_commands(struct todo_list *todo_list) 6404 6404 { 6405 6405 int i, res; 6406 - static struct string_list decorate_refs_exclude = STRING_LIST_INIT_NODUP; 6407 - static struct string_list decorate_refs_exclude_config = STRING_LIST_INIT_NODUP; 6408 - static struct string_list decorate_refs_include = STRING_LIST_INIT_NODUP; 6409 - struct decoration_filter decoration_filter = { 6410 - .include_ref_pattern = &decorate_refs_include, 6411 - .exclude_ref_pattern = &decorate_refs_exclude, 6412 - .exclude_ref_config_pattern = &decorate_refs_exclude_config, 6413 - }; 6414 6406 struct todo_add_branch_context ctx = { 6415 6407 .buf = &todo_list->buf, 6416 6408 .refs_to_oids = STRING_LIST_INIT_DUP, ··· 6419 6411 ctx.items_alloc = 2 * todo_list->nr + 1; 6420 6412 ALLOC_ARRAY(ctx.items, ctx.items_alloc); 6421 6413 6422 - string_list_append(&decorate_refs_include, "refs/heads/"); 6423 - load_ref_decorations(&decoration_filter, 0); 6414 + load_branch_decorations(); 6424 6415 6425 6416 for (i = 0; i < todo_list->nr; ) { 6426 6417 struct todo_item *item = &todo_list->items[i];