git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Étienne SERVAIS" <etienne.servais@voucoux.fr>,
	git@vger.kernel.org, "Rafael Ascensão" <rafa.almas@gmail.com>
Subject: [PATCH 2/2] log-tree: call load_ref_decorations() in get_name_decoration()
Date: Sun, 8 Sep 2019 19:58:51 +0200	[thread overview]
Message-ID: <c0e01bd5-667e-1f29-f355-dd0eda8c8e6e@web.de> (raw)
In-Reply-To: <xmqqwofuia0x.fsf@gitster-ct.c.googlers.com>

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>
---
 log-tree.c     | 1 +
 pretty.c       | 2 --
 revision.c     | 1 -
 t/t4202-log.sh | 2 +-
 4 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/log-tree.c b/log-tree.c
index 1e56df62a7..2d5710e707 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -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);
 }

diff --git a/pretty.c b/pretty.c
index e4ed14effe..b32f036953 100644
--- 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 */
diff --git a/revision.c b/revision.c
index 07412297f0..1df3061e95 100644
--- a/revision.c
+++ b/revision.c
@@ -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;
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 01c95d1375..bb66d1d93c 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -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)
--
2.23.0

      parent reply	other threads:[~2019-09-08 17:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-02  8:47 Simplify-by-decoration with decorate-refs-exclude Étienne SERVAIS
2019-08-02 16:52 ` René Scharfe
2019-08-02 19:14   ` Junio C Hamano
2019-08-02 20:36     ` René Scharfe
2019-08-02 21:20       ` Junio C Hamano
2019-08-02 23:21         ` Jeff King
2019-08-03  6:51         ` René Scharfe
2019-08-03 14:44           ` Junio C Hamano
2019-09-08 17:58             ` [PATCH 1/2] log: test --decorate-refs-exclude with --simplify-by-decoration René Scharfe
2019-09-09 18:17               ` Junio C Hamano
2019-09-08 17:58             ` René Scharfe [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c0e01bd5-667e-1f29-f355-dd0eda8c8e6e@web.de \
    --to=l.s.r@web.de \
    --cc=etienne.servais@voucoux.fr \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=rafa.almas@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).