Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
string_list_add_refs_from_colon_sep(): use string_list_split()
author
Michael Haggerty
<mhagger@alum.mit.edu>
Sun, 4 Nov 2012 07:07:10 +0000
(08:07 +0100)
committer
Jeff King
<peff@peff.net>
Thu, 8 Nov 2012 16:34:44 +0000
(11:34 -0500)
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>
notes.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
031954d
)
diff --git
a/notes.c
b/notes.c
index 63b2a09d47aed8028e4185870ccd816b375cf0dd..b823701d90fd59d2021779d26b05500a72d0bebe 100644
(file)
--- 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)
{
void string_list_add_refs_from_colon_sep(struct string_list *list,
const char *globs)
{
- struct str
buf globbuf = STRBUF_INIT
;
-
struct strbuf **split
;
+ struct str
ing_list split = STRING_LIST_INIT_NODUP
;
+
char *globs_copy = xstrdup(globs)
;
int i;
int i;
- str
buf_addstr(&globbuf, globs
);
- s
plit = strbuf_split(&globbuf, ':'
);
+ str
ing_list_split_in_place(&split, globs_copy, ':', -1
);
+ s
tring_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);
- str
buf_list_free(split
);
-
strbuf_release(&globbuf
);
+ str
ing_list_clear(&split, 0
);
+
free(globs_copy
);
}
static int notes_display_config(const char *k, const char *v, void *cb)
}
static int notes_display_config(const char *k, const char *v, void *cb)