summaryrefslogtreecommitdiff
path: root/notes.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2012-11-04 08:07:10 +0100
committerJeff King <peff@peff.net>2012-11-08 11:34:44 -0500
commit6fa23773d2fa257cf45fb20640d6286d13ded852 (patch)
tree7cdce071dfe93dca9d7252189e69d08857b5dced /notes.c
parent031954d443668f6ea771e389c4137628d242c2d8 (diff)
downloadgit-6fa23773d2fa257cf45fb20640d6286d13ded852.tar.gz
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>
Diffstat (limited to 'notes.c')
-rw-r--r--notes.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/notes.c b/notes.c
index 63b2a09d47..b823701d90 100644
--- a/notes.c
+++ b/notes.c
@@ -943,23 +943,18 @@ void string_list_add_refs_by_glob(struct string_list *list, const char *glob)
void string_list_add_refs_from_colon_sep(struct string_list *list,
const char *globs)
{
- struct strbuf globbuf = STRBUF_INIT;
- struct strbuf **split;
+ struct string_list split = STRING_LIST_INIT_NODUP;
+ char *globs_copy = xstrdup(globs);
int i;
- strbuf_addstr(&globbuf, globs);
- split = strbuf_split(&globbuf, ':');
+ string_list_split_in_place(&split, globs_copy, ':', -1);
+ string_list_remove_empty_items(&split, 0);
- 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;
- string_list_add_refs_by_glob(list, split[i]->buf);
- }
+ for (i = 0; i < split.nr; i++)
+ string_list_add_refs_by_glob(list, split.items[i].string);
- strbuf_list_free(split);
- strbuf_release(&globbuf);
+ string_list_clear(&split, 0);
+ free(globs_copy);
}
static int notes_display_config(const char *k, const char *v, void *cb)