]> git.ipfire.org Git - thirdparty/git.git/commitdiff
log-tree: call load_ref_decorations() in get_name_decoration()
authorRené Scharfe <l.s.r@web.de>
Sun, 8 Sep 2019 17:58:51 +0000 (19:58 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 9 Sep 2019 18:16:40 +0000 (11:16 -0700)
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>
log-tree.c
pretty.c
revision.c
t/t4202-log.sh

index 1e56df62a79c0d221fa55ba351b6b16f8027d12b..2d5710e707fae2f3c768eeefffa05bb2ce39813b 100644 (file)
@@ -77,6 +77,7 @@ void add_name_decoration(enum decoration_type type, const char *name, struct obj
 
 const struct name_decoration *get_name_decoration(const struct object *obj)
 {
+       load_ref_decorations(NULL, DECORATE_SHORT_REFS);
        return lookup_decoration(&name_decoration, obj);
 }
 
index e4ed14effe1aabdef50155b932a96e6648ff4707..b32f0369531c6f14799329890880600e714e6b4b 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -1239,11 +1239,9 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
                strbuf_addstr(sb, get_revision_mark(NULL, commit));
                return 1;
        case 'd':
-               load_ref_decorations(NULL, DECORATE_SHORT_REFS);
                format_decorations(sb, commit, c->auto_color);
                return 1;
        case 'D':
-               load_ref_decorations(NULL, DECORATE_SHORT_REFS);
                format_decorations_extended(sb, commit, c->auto_color, "", ", ", "");
                return 1;
        case 'S':               /* tag/branch like --source */
index 07412297f0248aae886eeb77c3a1cab13c93039c..1df3061e95d7d47ec01aa91ed4cf5820fa10002c 100644 (file)
@@ -2063,7 +2063,6 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
                revs->simplify_by_decoration = 1;
                revs->limited = 1;
                revs->prune = 1;
-               load_ref_decorations(NULL, DECORATE_SHORT_REFS);
        } else if (!strcmp(arg, "--date-order")) {
                revs->sort_order = REV_SORT_BY_COMMIT_DATE;
                revs->topo_order = 1;
index 01c95d1375cb7cf98cbfdd800d4b9575ef2ab54c..bb66d1d93cf87c4ce00a3dbf4dd4bc9e45b7a518 100755 (executable)
@@ -837,7 +837,7 @@ test_expect_success 'decorate-refs and decorate-refs-exclude' '
        test_cmp expect.decorate actual
 '
 
-test_expect_failure 'decorate-refs-exclude and simplify-by-decoration' '
+test_expect_success 'decorate-refs-exclude and simplify-by-decoration' '
        cat >expect.decorate <<-\EOF &&
        Merge-tag-reach (HEAD -> master)
        reach (tag: reach, reach)