mirror of
https://github.com/git/git.git
synced 2024-11-24 02:17:02 +08:00
Merge branch 'tb/ref-filter-empty-modifier' into maint
In the "--format=..." option of the "git for-each-ref" command (and its friends, i.e. the listing mode of "git branch/tag"), "%(atom:)" (e.g. "%(refname:)", "%(body:)" used to error out. Instead, treat them as if the colon and an empty string that follows it were not there. * tb/ref-filter-empty-modifier: ref-filter.c: pass empty-string as NULL to atom parsers
This commit is contained in:
commit
d9e8586056
10
ref-filter.c
10
ref-filter.c
@ -415,8 +415,16 @@ static int parse_ref_filter_atom(const struct ref_format *format,
|
||||
REALLOC_ARRAY(used_atom, used_atom_cnt);
|
||||
used_atom[at].name = xmemdupz(atom, ep - atom);
|
||||
used_atom[at].type = valid_atom[i].cmp_type;
|
||||
if (arg)
|
||||
if (arg) {
|
||||
arg = used_atom[at].name + (arg - atom) + 1;
|
||||
if (!*arg) {
|
||||
/*
|
||||
* Treat empty sub-arguments list as NULL (i.e.,
|
||||
* "%(atom:)" is equivalent to "%(atom)").
|
||||
*/
|
||||
arg = NULL;
|
||||
}
|
||||
}
|
||||
memset(&used_atom[at].u, 0, sizeof(used_atom[at].u));
|
||||
if (valid_atom[i].parser)
|
||||
valid_atom[i].parser(format, &used_atom[at], arg);
|
||||
|
@ -51,6 +51,7 @@ test_atom() {
|
||||
}
|
||||
|
||||
test_atom head refname refs/heads/master
|
||||
test_atom head refname: refs/heads/master
|
||||
test_atom head refname:short master
|
||||
test_atom head refname:lstrip=1 heads/master
|
||||
test_atom head refname:lstrip=2 master
|
||||
|
Loading…
Reference in New Issue
Block a user