Merge branch 'hv/ref-filter-trailers-atom-parsing-fix'
The parser for "git for-each-ref --format=..." was too loose when parsing the "%(trailers...)" atom, and forgot that "trailers" and "trailers:<modifiers>" are the only two allowed forms, which has been corrected. * hv/ref-filter-trailers-atom-parsing-fix: ref-filter: 'contents:trailers' show error if `:` is missing t6300: unify %(trailers) and %(contents:trailers) testsmaint
commit
e17723842b
|
|
@ -345,9 +345,11 @@ static int contents_atom_parser(const struct ref_format *format, struct used_ato
|
||||||
atom->u.contents.option = C_SIG;
|
atom->u.contents.option = C_SIG;
|
||||||
else if (!strcmp(arg, "subject"))
|
else if (!strcmp(arg, "subject"))
|
||||||
atom->u.contents.option = C_SUB;
|
atom->u.contents.option = C_SUB;
|
||||||
else if (skip_prefix(arg, "trailers", &arg)) {
|
else if (!strcmp(arg, "trailers")) {
|
||||||
skip_prefix(arg, ":", &arg);
|
if (trailers_atom_parser(format, atom, NULL, err))
|
||||||
if (trailers_atom_parser(format, atom, *arg ? arg : NULL, err))
|
return -1;
|
||||||
|
} else if (skip_prefix(arg, "trailers:", &arg)) {
|
||||||
|
if (trailers_atom_parser(format, atom, arg, err))
|
||||||
return -1;
|
return -1;
|
||||||
} else if (skip_prefix(arg, "lines=", &arg)) {
|
} else if (skip_prefix(arg, "lines=", &arg)) {
|
||||||
atom->u.contents.option = C_LINES;
|
atom->u.contents.option = C_LINES;
|
||||||
|
|
|
||||||
|
|
@ -776,61 +776,40 @@ test_expect_success 'set up trailers for next test' '
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '%(trailers:unfold) unfolds trailers' '
|
test_expect_success '%(trailers:unfold) unfolds trailers' '
|
||||||
git for-each-ref --format="%(trailers:unfold)" refs/heads/master >actual &&
|
|
||||||
{
|
{
|
||||||
unfold <trailers
|
unfold <trailers
|
||||||
echo
|
echo
|
||||||
} >expect &&
|
} >expect &&
|
||||||
|
git for-each-ref --format="%(trailers:unfold)" refs/heads/master >actual &&
|
||||||
|
test_cmp expect actual &&
|
||||||
|
git for-each-ref --format="%(contents:trailers:unfold)" refs/heads/master >actual &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '%(trailers:only) shows only "key: value" trailers' '
|
test_expect_success '%(trailers:only) shows only "key: value" trailers' '
|
||||||
git for-each-ref --format="%(trailers:only)" refs/heads/master >actual &&
|
|
||||||
{
|
{
|
||||||
grep -v patch.description <trailers &&
|
grep -v patch.description <trailers &&
|
||||||
echo
|
echo
|
||||||
} >expect &&
|
} >expect &&
|
||||||
|
git for-each-ref --format="%(trailers:only)" refs/heads/master >actual &&
|
||||||
|
test_cmp expect actual &&
|
||||||
|
git for-each-ref --format="%(contents:trailers:only)" refs/heads/master >actual &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '%(trailers:only) and %(trailers:unfold) work together' '
|
test_expect_success '%(trailers:only) and %(trailers:unfold) work together' '
|
||||||
|
{
|
||||||
|
grep -v patch.description <trailers | unfold &&
|
||||||
|
echo
|
||||||
|
} >expect &&
|
||||||
git for-each-ref --format="%(trailers:only,unfold)" refs/heads/master >actual &&
|
git for-each-ref --format="%(trailers:only,unfold)" refs/heads/master >actual &&
|
||||||
git for-each-ref --format="%(trailers:unfold,only)" refs/heads/master >reverse &&
|
test_cmp expect actual &&
|
||||||
test_cmp actual reverse &&
|
git for-each-ref --format="%(trailers:unfold,only)" refs/heads/master >actual &&
|
||||||
{
|
test_cmp actual actual &&
|
||||||
grep -v patch.description <trailers | unfold &&
|
|
||||||
echo
|
|
||||||
} >expect &&
|
|
||||||
test_cmp expect actual
|
|
||||||
'
|
|
||||||
|
|
||||||
test_expect_success '%(contents:trailers:unfold) unfolds trailers' '
|
|
||||||
git for-each-ref --format="%(contents:trailers:unfold)" refs/heads/master >actual &&
|
|
||||||
{
|
|
||||||
unfold <trailers
|
|
||||||
echo
|
|
||||||
} >expect &&
|
|
||||||
test_cmp expect actual
|
|
||||||
'
|
|
||||||
|
|
||||||
test_expect_success '%(contents:trailers:only) shows only "key: value" trailers' '
|
|
||||||
git for-each-ref --format="%(contents:trailers:only)" refs/heads/master >actual &&
|
|
||||||
{
|
|
||||||
grep -v patch.description <trailers &&
|
|
||||||
echo
|
|
||||||
} >expect &&
|
|
||||||
test_cmp expect actual
|
|
||||||
'
|
|
||||||
|
|
||||||
test_expect_success '%(contents:trailers:only) and %(contents:trailers:unfold) work together' '
|
|
||||||
git for-each-ref --format="%(contents:trailers:only,unfold)" refs/heads/master >actual &&
|
git for-each-ref --format="%(contents:trailers:only,unfold)" refs/heads/master >actual &&
|
||||||
git for-each-ref --format="%(contents:trailers:unfold,only)" refs/heads/master >reverse &&
|
test_cmp expect actual &&
|
||||||
test_cmp actual reverse &&
|
git for-each-ref --format="%(contents:trailers:unfold,only)" refs/heads/master >actual &&
|
||||||
{
|
test_cmp actual actual
|
||||||
grep -v patch.description <trailers | unfold &&
|
|
||||||
echo
|
|
||||||
} >expect &&
|
|
||||||
test_cmp expect actual
|
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '%(trailers) rejects unknown trailers arguments' '
|
test_expect_success '%(trailers) rejects unknown trailers arguments' '
|
||||||
|
|
@ -839,15 +818,16 @@ test_expect_success '%(trailers) rejects unknown trailers arguments' '
|
||||||
fatal: unknown %(trailers) argument: unsupported
|
fatal: unknown %(trailers) argument: unsupported
|
||||||
EOF
|
EOF
|
||||||
test_must_fail git for-each-ref --format="%(trailers:unsupported)" 2>actual &&
|
test_must_fail git for-each-ref --format="%(trailers:unsupported)" 2>actual &&
|
||||||
|
test_i18ncmp expect actual &&
|
||||||
|
test_must_fail git for-each-ref --format="%(contents:trailers:unsupported)" 2>actual &&
|
||||||
test_i18ncmp expect actual
|
test_i18ncmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '%(contents:trailers) rejects unknown trailers arguments' '
|
test_expect_success 'if arguments, %(contents:trailers) shows error if colon is missing' '
|
||||||
# error message cannot be checked under i18n
|
|
||||||
cat >expect <<-EOF &&
|
cat >expect <<-EOF &&
|
||||||
fatal: unknown %(trailers) argument: unsupported
|
fatal: unrecognized %(contents) argument: trailersonly
|
||||||
EOF
|
EOF
|
||||||
test_must_fail git for-each-ref --format="%(contents:trailers:unsupported)" 2>actual &&
|
test_must_fail git for-each-ref --format="%(contents:trailersonly)" 2>actual &&
|
||||||
test_i18ncmp expect actual
|
test_i18ncmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue