clean: do not use strbuf_split*() [part 2]
builtin/clean.c:filter_by_patterns_cmd() interactively reads a line that has exclude patterns from the user and splits the line into a list of patterns. It uses the strbuf_split() so that each split piece can then trimmed. There is no need to use strbuf anymore, thanks to the recent enhancement to string_list_split*() family that allows us to trim the pieces split into a string_list. Signed-off-by: Junio C Hamano <gitster@pobox.com>main
parent
4985f72ea5
commit
4f60672f6f
|
|
@ -674,12 +674,13 @@ static int filter_by_patterns_cmd(void)
|
||||||
{
|
{
|
||||||
struct dir_struct dir = DIR_INIT;
|
struct dir_struct dir = DIR_INIT;
|
||||||
struct strbuf confirm = STRBUF_INIT;
|
struct strbuf confirm = STRBUF_INIT;
|
||||||
struct strbuf **ignore_list;
|
|
||||||
struct string_list_item *item;
|
|
||||||
struct pattern_list *pl;
|
struct pattern_list *pl;
|
||||||
int changed = -1, i;
|
int changed = -1, i;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
struct string_list ignore_list = STRING_LIST_INIT_NODUP;
|
||||||
|
struct string_list_item *item;
|
||||||
|
|
||||||
if (!del_list.nr)
|
if (!del_list.nr)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -697,14 +698,15 @@ static int filter_by_patterns_cmd(void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
pl = add_pattern_list(&dir, EXC_CMDL, "manual exclude");
|
pl = add_pattern_list(&dir, EXC_CMDL, "manual exclude");
|
||||||
ignore_list = strbuf_split_max(&confirm, ' ', 0);
|
|
||||||
|
|
||||||
for (i = 0; ignore_list[i]; i++) {
|
string_list_split_in_place_f(&ignore_list, confirm.buf, " ", -1,
|
||||||
strbuf_trim(ignore_list[i]);
|
STRING_LIST_SPLIT_TRIM);
|
||||||
if (!ignore_list[i]->len)
|
|
||||||
|
for (i = 0; i < ignore_list.nr; i++) {
|
||||||
|
item = &ignore_list.items[i];
|
||||||
|
if (!*item->string)
|
||||||
continue;
|
continue;
|
||||||
|
add_pattern(item->string, "", 0, pl, -(i+1));
|
||||||
add_pattern(ignore_list[i]->buf, "", 0, pl, -(i+1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
changed = 0;
|
changed = 0;
|
||||||
|
|
@ -725,7 +727,7 @@ static int filter_by_patterns_cmd(void)
|
||||||
clean_print_color(CLEAN_COLOR_RESET);
|
clean_print_color(CLEAN_COLOR_RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
strbuf_list_free(ignore_list);
|
string_list_clear(&ignore_list, 0);
|
||||||
dir_clear(&dir);
|
dir_clear(&dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue