string_list_add_refs_from_colon_sep(): use string_list_split()

It makes for simpler code than strbuf_split(). 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 6fa23773d2fa257cf45fb20640d6286d13ded852
1 file changed +8 -13
notes.c
+8 -13
@@ -943,23 +943,18 @@ void string_list_add_refs_by_glob(struct string_list *list, const char *glob)
943 void string_list_add_refs_from_colon_sep(struct string_list *list,
944 const char *globs)
945 {
946 - struct strbuf globbuf = STRBUF_INIT;
947 - struct strbuf **split;
946 + struct string_list split = STRING_LIST_INIT_NODUP;
947 + char *globs_copy = xstrdup(globs);
948 int i;
949
950 - strbuf_addstr(&globbuf, globs);
951 - split = strbuf_split(&globbuf, ':');
950 + string_list_split_in_place(&split, globs_copy, ':', -1);
951 + string_list_remove_empty_items(&split, 0);
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;
958 - string_list_add_refs_by_glob(list, split[i]->buf);
959 - }
953 + for (i = 0; i < split.nr; i++)
954 + string_list_add_refs_by_glob(list, split.items[i].string);
955
961 - strbuf_list_free(split);
962 - strbuf_release(&globbuf);
956 + string_list_clear(&split, 0);
957 + free(globs_copy);
958 }
959
960 static int notes_display_config(const char *k, const char *v, void *cb)