notes: fix handling of colon-separated values
The substrings output by strbuf_split() include the ':' delimiters. When processing GIT_NOTES_DISPLAY_REF and GIT_NOTES_REWRITE_REF, strip off the delimiter character *before* checking whether the substring is empty rather than after, so that empty strings within the list are also skipped. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Acked-by: Johan Herland <johan@herland.net> Signed-off-by: Jeff King <peff@peff.net>
Michael Haggerty committed
Nov 4, 2012 at 08:07 UTC
031954d443668f6ea771e389c4137628d242c2d8
1 file changed
+2
-2
notes.c
+2
-2
@@ -951,10 +951,10 @@ void string_list_add_refs_from_colon_sep(struct string_list *list,
951
split = strbuf_split(&globbuf, ':');
952
953
for (i = 0; split[i]; i++) {
954
+ if (split[i]->len && split[i]->buf[split[i]->len-1] == ':')
955
+ strbuf_setlen(split[i], split[i]->len-1);
956
if (!split[i]->len)
957
continue;
956
- if (split[i]->buf[split[i]->len-1] == ':')
957
- strbuf_setlen(split[i], split[i]->len-1);
958
string_list_add_refs_by_glob(list, split[i]->buf);
959
}
960