summaryrefslogtreecommitdiff
path: root/notes.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2012-11-04 08:07:09 +0100
committerJeff King <peff@peff.net>2012-11-08 11:34:42 -0500
commit031954d443668f6ea771e389c4137628d242c2d8 (patch)
treeb343866cad8c17f8856864bf2b056485930ae8a2 /notes.c
parent131352433621e89b2e8c58d8327b1d55bf0bc8d0 (diff)
downloadgit-031954d443668f6ea771e389c4137628d242c2d8.tar.gz
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>
Diffstat (limited to 'notes.c')
-rw-r--r--notes.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/notes.c b/notes.c
index 62f8f6f75b..63b2a09d47 100644
--- a/notes.c
+++ b/notes.c
@@ -951,10 +951,10 @@ void string_list_add_refs_from_colon_sep(struct string_list *list,
split = strbuf_split(&globbuf, ':');
for (i = 0; split[i]; i++) {
+ if (split[i]->len && split[i]->buf[split[i]->len-1] == ':')
+ strbuf_setlen(split[i], split[i]->len-1);
if (!split[i]->len)
continue;
- if (split[i]->buf[split[i]->len-1] == ':')
- strbuf_setlen(split[i], split[i]->len-1);
string_list_add_refs_by_glob(list, split[i]->buf);
}