Merge branch 'ng/rebase-merges-branch-name-as-label'

"git rebase --rebase-merges" now uses branch names as labels when
able.

* ng/rebase-merges-branch-name-as-label:
  rebase-merges: try and use branch names as labels
  rebase-update-refs: extract load_branch_decorations
  load_branch_decorations: fix memory leak with non-static filters
This commit is contained in:
Taylor Blau
2024-10-18 13:56:22 -04:00
5 changed files with 53 additions and 26 deletions

View File

@ -232,6 +232,11 @@ void load_ref_decorations(struct decoration_filter *filter, int flags)
for_each_string_list_item(item, filter->exclude_ref_config_pattern) {
normalize_glob_ref(item, NULL, item->string);
}
/* normalize_glob_ref duplicates the strings */
filter->exclude_ref_pattern->strdup_strings = 1;
filter->include_ref_pattern->strdup_strings = 1;
filter->exclude_ref_config_pattern->strdup_strings = 1;
}
decoration_loaded = 1;
decoration_flags = flags;
@ -243,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;