merge-tree: remove redundant code

real_merge() only ever returns "0" or "1" as it dies if the merge status is less than zero. Therefore the check for "result < 0" is redundant and the result variable is not needed. The return value of real_merge() is ignored because exit status of "git merge-tree --stdin" is "0" for both successful and conflicted merges (the status of each merge is written to stdout). The return type of real_merge() is not changed as it is used for the program's exit status when "--stdin" is not given. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Acked-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Phillip Wood committed Feb 18, 2025 at 16:24 UTC 1b0e5f4499a0c099d99b00a2a6a3edb45ae98660
1 file changed +2 -5
builtin/merge-tree.c
+2 -5
@@ -601,7 +601,6 @@ int cmd_merge_tree(int argc,
601 line_termination = '\0';
602 while (strbuf_getline_lf(&buf, stdin) != EOF) {
603 struct strbuf **split;
604 - int result;
604 const char *input_merge_base = NULL;
605
606 split = strbuf_split(&buf, ' ');
@@ -618,16 +617,14 @@ int cmd_merge_tree(int argc,
617 if (input_merge_base && split[2] && split[3] && !split[4]) {
618 strbuf_rtrim(split[2]);
619 strbuf_rtrim(split[3]);
621 - result = real_merge(&o, input_merge_base, split[2]->buf, split[3]->buf, prefix);
620 + real_merge(&o, input_merge_base, split[2]->buf, split[3]->buf, prefix);
621 } else if (!input_merge_base && !split[2]) {
623 - result = real_merge(&o, NULL, split[0]->buf, split[1]->buf, prefix);
622 + real_merge(&o, NULL, split[0]->buf, split[1]->buf, prefix);
623 } else {
624 die(_("malformed input line: '%s'."), buf.buf);
625 }
626 maybe_flush_or_die(stdout, "stdout");
627
629 - if (result < 0)
630 - die(_("merging cannot continue; got unclean result of %d"), result);
628 strbuf_list_free(split);
629 }
630 strbuf_release(&buf);