git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / 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: Re: Simplify-by-decoration with decorate-refs-exclude
Date: Sat, 3 Aug 2019 08:51:38 +0200
Message-ID: <64bc5556-b098-7991-b7c2-3483277bb73c@web.de> (raw)
In-Reply-To: <xmqqh86zjmcg.fsf@gitster-ct.c.googlers.com>

Am 02.08.19 um 23:20 schrieb Junio C Hamano:
> René Scharfe <l.s.r@web.de> writes:
>
>> Having cmd_log_init_finish() call load_ref_decorations() before
>> setup_revisions() would indeed solve the issue as well.  But we need
>> to call the latter to check if --pretty=raw was given and avoid loading
>> decorations in that case, don't we?
>
> I was thinking about giving an instance of the decoration_filter to
> either rev_info or setup_revision_opt, and moving the call to
> load_ref_decorations() and the decision to make that call from
> cmd_log_init_finish() to setup_revisions().

Sure, but we'd need to move the code to handle the raw format as well, no?
Perhaps like this?  It depends on callers of parse_revision_opt() calling
setup_revisions() before using decorations.  And it may have other side
effects; I'm not comfortable with this change.

---
 builtin/log.c  | 10 +++++-----
 revision.c     | 17 ++++++++++++++++-
 revision.h     |  4 ++++
 t/t4202-log.sh | 15 +++++++++++++++
 4 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/builtin/log.c b/builtin/log.c
index 1cf9e37736..5a1544276f 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -203,6 +203,10 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
 			     PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN |
 			     PARSE_OPT_KEEP_DASHDASH);

+	rev->decoration_filter = &decoration_filter;
+	rev->decoration_given = decoration_given;
+	rev->decoration_style = decoration_style;
+
 	if (quiet)
 		rev->diffopt.output_format |= DIFF_FORMAT_NO_OUTPUT;
 	argc = setup_revisions(argc, argv, rev, opt);
@@ -245,16 +249,12 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
 		 * "log --pretty=raw" is special; ignore UI oriented
 		 * configuration variables such as decoration.
 		 */
-		if (!decoration_given)
-			decoration_style = 0;
 		if (!rev->abbrev_commit_given)
 			rev->abbrev_commit = 0;
 	}

-	if (decoration_style) {
+	if (rev->decoration_style)
 		rev->show_decorations = 1;
-		load_ref_decorations(&decoration_filter, decoration_style);
-	}

 	if (rev->line_level_traverse)
 		line_log_init(rev, line_cb.prefix, &line_cb.args);
diff --git a/revision.c b/revision.c
index 07412297f0..709d6a273c 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;
@@ -2716,6 +2715,22 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
 	if (revs->expand_tabs_in_log < 0)
 		revs->expand_tabs_in_log = revs->expand_tabs_in_log_default;

+	if (revs->pretty_given && revs->commit_format == CMIT_FMT_RAW) {
+		/*
+		 * "log --pretty=raw" is special; ignore UI oriented
+		 * configuration variables such as decoration.
+		 */
+		if (!revs->decoration_given)
+			revs->decoration_style = 0;
+	}
+
+	if (revs->decoration_style)
+		load_ref_decorations(revs->decoration_filter,
+				     revs->decoration_style);
+	else if (revs->simplify_by_decoration)
+		load_ref_decorations(revs->decoration_filter,
+				     DECORATE_SHORT_REFS);
+
 	return left;
 }

diff --git a/revision.h b/revision.h
index 4134dc6029..67ffe095a9 100644
--- a/revision.h
+++ b/revision.h
@@ -186,6 +186,7 @@ struct rev_info {
 			pretty_given:1,
 			abbrev_commit:1,
 			abbrev_commit_given:1,
+			decoration_given:1,
 			zero_commit:1,
 			use_terminator:1,
 			missing_newline:1,
@@ -269,6 +270,9 @@ struct rev_info {
 	/* line level range that we are chasing */
 	struct decoration line_log_data;

+	struct decoration_filter *decoration_filter;
+	int decoration_style;
+
 	/* copies of the parent lists, for --full-diff display */
 	struct saved_parents *saved_parents_slab;

diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index c20209324c..bb66d1d93c 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -837,6 +837,21 @@ test_expect_success 'decorate-refs and decorate-refs-exclude' '
 	test_cmp expect.decorate actual
 '

+test_expect_success 'decorate-refs-exclude and simplify-by-decoration' '
+	cat >expect.decorate <<-\EOF &&
+	Merge-tag-reach (HEAD -> master)
+	reach (tag: reach, reach)
+	seventh (tag: seventh)
+	Merge-branch-tangle
+	Merge-branch-side-early-part-into-tangle (tangle)
+	tangle-a (tag: tangle-a)
+	EOF
+	git log -n6 --decorate=short --pretty="tformat:%f%d" \
+		--decorate-refs-exclude="*octopus*" \
+		--simplify-by-decoration >actual &&
+	test_cmp expect.decorate actual
+'
+
 test_expect_success 'log.decorate config parsing' '
 	git log --oneline --decorate=full >expect.full &&
 	git log --oneline --decorate=short >expect.short &&
--
2.22.0

  parent reply index

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-02  8:47 É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 [this message]
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             ` [PATCH 2/2] log-tree: call load_ref_decorations() in get_name_decoration() René Scharfe

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=64bc5556-b098-7991-b7c2-3483277bb73c@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

git@vger.kernel.org list mirror (unofficial, one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git