ref-filter.c: pass empty-string as NULL to atom parsers
authorTaylor Blau <me@ttaylorr.com>
Mon, 2 Oct 2017 16:10:34 +0000 (09:10 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Oct 2017 01:41:57 +0000 (10:41 +0900)
commitbea4dbeafda3ddc4404f2e94dce0b66a4105399a
tree6efc5ff1eb48fffef29c26cdf7d166af51292826
parent4010f1d1b782eb7585e0e0abcefa794bd5ff29a0
ref-filter.c: pass empty-string as NULL to atom parsers

Peff points out that different atom parsers handle the empty
"sub-argument" list differently. An example of this is the format
"%(refname:)".

Since callers often use `string_list_split` (which splits the empty
string with any delimiter as a 1-ary string_list containing the empty
string), this makes handling empty sub-argument strings non-ergonomic.

Let's fix this by declaring that atom parser implementations must
not care about distinguishing between the empty string "%(refname:)"
and no sub-arguments "%(refname)".  Current code aborts, either with
"unrecognised arg" (e.g. "refname:") or "does not take args"
(e.g. "body:") as an error message.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Reviewed-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
ref-filter.c
t/t6300-for-each-ref.sh