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 <andy.koppe@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Andy Koppe committed Oct 8, 2023 at 21:23 UTC 2b09d16abac5c0cf389098a58f113f2053357dee
2 files changed +7 -3
pretty.c
+4
@@ -1961,6 +1961,10 @@ void userformat_find_requirements(const char *fmt, struct userformat_want *w)
1961 case 'D':
1962 w->decorate = 1;
1963 break;
1964 + case '(':
1965 + if (starts_with(fmt + 1, "decorate"))
1966 + w->decorate = 1;
1967 + break;
1968 }
1969 }
1970 }
t/t4205-log-pretty-formats.sh
+3 -3
@@ -590,9 +590,9 @@ test_expect_success 'pretty format %decorate' '
590 git log --format="%(decorate:prefix=,suffix=)" -1 >actual2 &&
591 test_cmp expect2 actual2 &&
592
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 &&
596 test_cmp expect3 actual3 &&
597
598 # Try with a typo (in "separator"), in which case the placeholder should