Git fork

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>

+11 -9
+11 -9
builtin/clean.c
··· 674 674 { 675 675 struct dir_struct dir = DIR_INIT; 676 676 struct strbuf confirm = STRBUF_INIT; 677 - struct strbuf **ignore_list; 678 - struct string_list_item *item; 679 677 struct pattern_list *pl; 680 678 int changed = -1, i; 681 679 682 680 for (;;) { 681 + struct string_list ignore_list = STRING_LIST_INIT_NODUP; 682 + struct string_list_item *item; 683 + 683 684 if (!del_list.nr) 684 685 break; 685 686 ··· 697 698 break; 698 699 699 700 pl = add_pattern_list(&dir, EXC_CMDL, "manual exclude"); 700 - ignore_list = strbuf_split_max(&confirm, ' ', 0); 701 701 702 - for (i = 0; ignore_list[i]; i++) { 703 - strbuf_trim(ignore_list[i]); 704 - if (!ignore_list[i]->len) 705 - continue; 702 + string_list_split_in_place_f(&ignore_list, confirm.buf, " ", -1, 703 + STRING_LIST_SPLIT_TRIM); 706 704 707 - add_pattern(ignore_list[i]->buf, "", 0, pl, -(i+1)); 705 + for (i = 0; i < ignore_list.nr; i++) { 706 + item = &ignore_list.items[i]; 707 + if (!*item->string) 708 + continue; 709 + add_pattern(item->string, "", 0, pl, -(i+1)); 708 710 } 709 711 710 712 changed = 0; ··· 725 727 clean_print_color(CLEAN_COLOR_RESET); 726 728 } 727 729 728 - strbuf_list_free(ignore_list); 730 + string_list_clear(&ignore_list, 0); 729 731 dir_clear(&dir); 730 732 } 731 733