log-tree: call load_ref_decorations() in get_name_decoration()
Load a default set of ref name decorations at the first lookup. This frees direct and indirect callers from doing so. They can still do it if they want to use a filter or are interested in full decorations instead of the default short ones -- the first load_ref_decorations() call wins. This means that the load in builtin/log.c::cmd_log_init_finish() is respected even if --simplify-by-decoration is given, as the previously dominating earlier load in handle_revision_opt() is gone. So a filter given with --decorate-refs-exclude is used for simplification in that case, as expected. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Sep 8, 2019 at 19:58 UTC
0cc7380d8846c30ce0d5d6310b2cb5994f269133
4 files changed
+2
-4
log-tree.c
+1
@@ -77,6 +77,7 @@ void add_name_decoration(enum decoration_type type, const char *name, struct obj
77
78
const struct name_decoration *get_name_decoration(const struct object *obj)
79
{
80
+ load_ref_decorations(NULL, DECORATE_SHORT_REFS);
81
return lookup_decoration(&name_decoration, obj);
82
}
83
pretty.c
-2
@@ -1239,11 +1239,9 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
1239
strbuf_addstr(sb, get_revision_mark(NULL, commit));
1240
return 1;
1241
case 'd':
1242
- load_ref_decorations(NULL, DECORATE_SHORT_REFS);
1242
format_decorations(sb, commit, c->auto_color);
1243
return 1;
1244
case 'D':
1246
- load_ref_decorations(NULL, DECORATE_SHORT_REFS);
1245
format_decorations_extended(sb, commit, c->auto_color, "", ", ", "");
1246
return 1;
1247
case 'S': /* tag/branch like --source */
revision.c
-1
@@ -2063,7 +2063,6 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
2063
revs->simplify_by_decoration = 1;
2064
revs->limited = 1;
2065
revs->prune = 1;
2066
- load_ref_decorations(NULL, DECORATE_SHORT_REFS);
2066
} else if (!strcmp(arg, "--date-order")) {
2067
revs->sort_order = REV_SORT_BY_COMMIT_DATE;
2068
revs->topo_order = 1;
t/t4202-log.sh
+1
-1
@@ -837,7 +837,7 @@ test_expect_success 'decorate-refs and decorate-refs-exclude' '
837
test_cmp expect.decorate actual
838
'
839
840
-test_expect_failure 'decorate-refs-exclude and simplify-by-decoration' '
840
+test_expect_success 'decorate-refs-exclude and simplify-by-decoration' '
841
cat >expect.decorate <<-\EOF &&
842
Merge-tag-reach (HEAD -> master)
843
reach (tag: reach, reach)