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