Skip to content

Commit 2b09d16

Browse files
ak2gitster
authored andcommitted
pretty: fix ref filtering for %(decorate) formats
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1e63b34 commit 2b09d16

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

pretty.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1961,6 +1961,10 @@ void userformat_find_requirements(const char *fmt, struct userformat_want *w)
19611961
case 'D':
19621962
w->decorate = 1;
19631963
break;
1964+
case '(':
1965+
if (starts_with(fmt + 1, "decorate"))
1966+
w->decorate = 1;
1967+
break;
19641968
}
19651969
}
19661970
}

t/t4205-log-pretty-formats.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,9 +590,9 @@ test_expect_success 'pretty format %decorate' '
590590
git log --format="%(decorate:prefix=,suffix=)" -1 >actual2 &&
591591
test_cmp expect2 actual2 &&
592592
593-
echo "[ HEAD -> foo; tag: bar; qux ]" >expect3 &&
594-
git log --format="%(decorate:prefix=[ ,suffix= ],separator=%x3B )" \
595-
-1 >actual3 &&
593+
echo "[ bar; qux; foo ]" >expect3 &&
594+
git log --format="%(decorate:prefix=[ ,suffix= ],separator=%x3B ,tag=)" \
595+
--decorate-refs=refs/ -1 >actual3 &&
596596
test_cmp expect3 actual3 &&
597597
598598
# Try with a typo (in "separator"), in which case the placeholder should

0 commit comments

Comments
 (0)