Skip to content

Commit 68c9fcb

Browse files
nicolas-guichardgitster
authored andcommitted
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 <[email protected]> Acked-by: Phillip Wood <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e4d03b7 commit 68c9fcb

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

log-tree.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,27 @@ void load_ref_decorations(struct decoration_filter *filter, int flags)
248248
}
249249
}
250250

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+
251272
static void show_parents(struct commit *commit, int abbrev, FILE *file)
252273
{
253274
struct commit_list *p;

log-tree.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
3333
int *need_8bit_cte_p,
3434
int maybe_multipart);
3535
void load_ref_decorations(struct decoration_filter *filter, int flags);
36+
void load_branch_decorations(void);
3637

3738
void fmt_output_commit(struct strbuf *, struct commit *, struct rev_info *);
3839
void fmt_output_subject(struct strbuf *, const char *subject, struct rev_info *);

sequencer.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6403,14 +6403,6 @@ static int add_decorations_to_list(const struct commit *commit,
64036403
static int todo_list_add_update_ref_commands(struct todo_list *todo_list)
64046404
{
64056405
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-
};
64146406
struct todo_add_branch_context ctx = {
64156407
.buf = &todo_list->buf,
64166408
.refs_to_oids = STRING_LIST_INIT_DUP,
@@ -6419,8 +6411,7 @@ static int todo_list_add_update_ref_commands(struct todo_list *todo_list)
64196411
ctx.items_alloc = 2 * todo_list->nr + 1;
64206412
ALLOC_ARRAY(ctx.items, ctx.items_alloc);
64216413

6422-
string_list_append(&decorate_refs_include, "refs/heads/");
6423-
load_ref_decorations(&decoration_filter, 0);
6414+
load_branch_decorations();
64246415

64256416
for (i = 0; i < todo_list->nr; ) {
64266417
struct todo_item *item = &todo_list->items[i];

0 commit comments

Comments
 (0)