git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] pretty: fix ref filtering for %(decorate) formats
@ 2023-10-08 20:23 Andy Koppe
  2023-10-09 18:24 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Koppe @ 2023-10-08 20:23 UTC (permalink / raw
  To: git; +Cc: Andy Koppe

Mark pretty formats containing "%(decorate" as requiring decoration in
userformat_find_requirements(), same as "%d" and "%D".

Without this, cmd_log_init_finish() didn't invoke load_ref_decorations()
with the decoration_filter it puts together, and hence filtering options
such as --decorate-refs were quietly ignored.

Amend one of the %(decorate) checks in t4205-log-pretty-formats.sh to
test this.

Signed-off-by: Andy Koppe <andy.koppe@gmail.com>
---
 pretty.c                      | 4 ++++
 t/t4205-log-pretty-formats.sh | 6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/pretty.c b/pretty.c
index 7f3abb676c..cf964b060c 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1961,6 +1961,10 @@ void userformat_find_requirements(const char *fmt, struct userformat_want *w)
 		case 'D':
 			w->decorate = 1;
 			break;
+		case '(':
+			if (starts_with(fmt + 1, "decorate"))
+				w->decorate = 1;
+			break;
 		}
 	}
 }
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 16626e4fe9..5aabc9f7d8 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -590,9 +590,9 @@ test_expect_success 'pretty format %decorate' '
 	git log --format="%(decorate:prefix=,suffix=)" -1 >actual2 &&
 	test_cmp expect2 actual2 &&
 
-	echo "[ HEAD -> foo; tag: bar; qux ]" >expect3 &&
-	git log --format="%(decorate:prefix=[ ,suffix= ],separator=%x3B )" \
-		-1 >actual3 &&
+	echo "[ bar; qux; foo ]" >expect3 &&
+	git log --format="%(decorate:prefix=[ ,suffix= ],separator=%x3B ,tag=)" \
+		--decorate-refs=refs/ -1 >actual3 &&
 	test_cmp expect3 actual3 &&
 
 	# Try with a typo (in "separator"), in which case the placeholder should
-- 
2.42.GIT


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] pretty: fix ref filtering for %(decorate) formats
  2023-10-08 20:23 [PATCH] pretty: fix ref filtering for %(decorate) formats Andy Koppe
@ 2023-10-09 18:24 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2023-10-09 18:24 UTC (permalink / raw
  To: Andy Koppe; +Cc: git

Andy Koppe <andy.koppe@gmail.com> writes:

> Mark pretty formats containing "%(decorate" as requiring decoration in
> userformat_find_requirements(), same as "%d" and "%D".

Ah, of course.  The patch makes sense.

> diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
> index 16626e4fe9..5aabc9f7d8 100755
> --- a/t/t4205-log-pretty-formats.sh
> +++ b/t/t4205-log-pretty-formats.sh
> @@ -590,9 +590,9 @@ test_expect_success 'pretty format %decorate' '
>  	git log --format="%(decorate:prefix=,suffix=)" -1 >actual2 &&
>  	test_cmp expect2 actual2 &&
>  
> -	echo "[ HEAD -> foo; tag: bar; qux ]" >expect3 &&
> -	git log --format="%(decorate:prefix=[ ,suffix= ],separator=%x3B )" \
> -		-1 >actual3 &&
> +	echo "[ bar; qux; foo ]" >expect3 &&
> +	git log --format="%(decorate:prefix=[ ,suffix= ],separator=%x3B ,tag=)" \
> +		--decorate-refs=refs/ -1 >actual3 &&
>  	test_cmp expect3 actual3 &&

The original test shares the same, but is the order of multiple
decorations expected to be stable?  I feel a bit uneasy to see a
test that insists multiple things come out in a hardcoded order.

It is not making anything _worse_, so let's take the patch as-is.

Thanks.

>  	# Try with a typo (in "separator"), in which case the placeholder should

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-10-09 18:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-08 20:23 [PATCH] pretty: fix ref filtering for %(decorate) formats Andy Koppe
2023-10-09 18:24 ` Junio C Hamano

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).