Git fork

merge-tree: do not use strbuf_split*()

When reading merge instructions from the standard input, the program
reads from the standard input, splits the line into tokens at
whitespace, and trims each of them before using. We no longer need
to use strbuf just for trimming, as string_list_split*() family can
trim while splitting a string.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

+16 -14
+16 -14
builtin/merge-tree.c
··· 618 618 "--merge-base", "--stdin"); 619 619 line_termination = '\0'; 620 620 while (strbuf_getline_lf(&buf, stdin) != EOF) { 621 - struct strbuf **split; 621 + struct string_list split = STRING_LIST_INIT_NODUP; 622 622 const char *input_merge_base = NULL; 623 623 624 - split = strbuf_split(&buf, ' '); 625 - if (!split[0] || !split[1]) 624 + string_list_split_in_place_f(&split, buf.buf, " ", -1, 625 + STRING_LIST_SPLIT_TRIM); 626 + 627 + if (split.nr < 2) 626 628 die(_("malformed input line: '%s'."), buf.buf); 627 - strbuf_rtrim(split[0]); 628 - strbuf_rtrim(split[1]); 629 629 630 630 /* parse the merge-base */ 631 - if (!strcmp(split[1]->buf, "--")) { 632 - input_merge_base = split[0]->buf; 631 + if (!strcmp(split.items[1].string, "--")) { 632 + input_merge_base = split.items[0].string; 633 633 } 634 634 635 - if (input_merge_base && split[2] && split[3] && !split[4]) { 636 - strbuf_rtrim(split[2]); 637 - strbuf_rtrim(split[3]); 638 - real_merge(&o, input_merge_base, split[2]->buf, split[3]->buf, prefix); 639 - } else if (!input_merge_base && !split[2]) { 640 - real_merge(&o, NULL, split[0]->buf, split[1]->buf, prefix); 635 + if (input_merge_base && split.nr == 4) { 636 + real_merge(&o, input_merge_base, 637 + split.items[2].string, split.items[3].string, 638 + prefix); 639 + } else if (!input_merge_base && split.nr == 2) { 640 + real_merge(&o, NULL, 641 + split.items[0].string, split.items[1].string, 642 + prefix); 641 643 } else { 642 644 die(_("malformed input line: '%s'."), buf.buf); 643 645 } 644 646 maybe_flush_or_die(stdout, "stdout"); 645 647 646 - strbuf_list_free(split); 648 + string_list_clear(&split, 0); 647 649 } 648 650 strbuf_release(&buf); 649 651