]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pretty: fix ref filtering for %(decorate) formats
authorAndy Koppe <andy.koppe@gmail.com>
Sun, 8 Oct 2023 20:23:07 +0000 (21:23 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 9 Oct 2023 18:25:13 +0000 (11:25 -0700)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pretty.c
t/t4205-log-pretty-formats.sh

index 7f3abb676c2e1707f3d897f1d82a774b1e1868f3..cf964b060cd128e2bc271c07ed8bb8b4c28bfe29 100644 (file)
--- 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;
                }
        }
 }
index 16626e4fe96f48098ecca8c64e8a33929e169f9d..5aabc9f7d8419acd599cab7d4abd2a91bdaf2c12 100755 (executable)
@@ -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