Skip to content

Commit 9b07c15

Browse files
committed
Merge branch 'pw/merge-tree-stdin-deadlock-fix'
"git merge-tree --stdin" has been improved (including a workaround for a deadlock). * pw/merge-tree-stdin-deadlock-fix: merge-tree: fix link formatting in html docs merge-tree: improve docs for --stdin merge-tree: only use basic merge config merge-tree: remove redundant code merge-tree --stdin: flush stdout to avoid deadlock
2 parents 37b34c4 + 6a9ae81 commit 9b07c15

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

Documentation/git-merge-tree.adoc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,17 @@ After the merge completes, a new toplevel tree object is created. See
4040
OPTIONS
4141
-------
4242
43+
--stdin::
44+
Read the commits to merge from the standard input rather than
45+
the command-line. See <<INPUT,INPUT FORMAT>> below for more
46+
information. Implies `-z`.
47+
4348
-z::
4449
Do not quote filenames in the <Conflicted file info> section,
4550
and end each filename with a NUL character rather than
4651
newline. Also begin the messages section with a NUL character
47-
instead of a newline. See <<OUTPUT>> below for more information.
52+
instead of a newline. See <<OUTPUT,OUTPUT>> below for more
53+
information.
4854
4955
--name-only::
5056
In the Conflicted file info section, instead of writing a list
@@ -116,8 +122,6 @@ This is an integer status followed by a NUL character. The integer status is:
116122

117123
0: merge had conflicts
118124
1: merge was clean
119-
<0: something prevented the merge from running (e.g. access to repository
120-
objects denied by filesystem)
121125

122126
[[OIDTLT]]
123127
OID of toplevel tree
@@ -235,6 +239,7 @@ with linkgit:git-merge[1]:
235239
* any messages that would have been printed to stdout (the
236240
<<IM,Informational messages>>)
237241

242+
[[INPUT]]
238243
INPUT FORMAT
239244
------------
240245
'git merge-tree --stdin' input format is fully text based. Each line

builtin/merge-tree.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "tree.h"
1919
#include "config.h"
2020
#include "strvec.h"
21+
#include "write-or-die.h"
2122

2223
static int line_termination = '\n';
2324

@@ -575,7 +576,7 @@ int cmd_merge_tree(int argc,
575576
};
576577

577578
/* Init merge options */
578-
init_ui_merge_options(&o.merge_options, the_repository);
579+
init_basic_merge_options(&o.merge_options, the_repository);
579580

580581
/* Parse arguments */
581582
original_argc = argc - 1; /* ignoring argv[0] */
@@ -600,7 +601,6 @@ int cmd_merge_tree(int argc,
600601
line_termination = '\0';
601602
while (strbuf_getline_lf(&buf, stdin) != EOF) {
602603
struct strbuf **split;
603-
int result;
604604
const char *input_merge_base = NULL;
605605

606606
split = strbuf_split(&buf, ' ');
@@ -617,15 +617,14 @@ int cmd_merge_tree(int argc,
617617
if (input_merge_base && split[2] && split[3] && !split[4]) {
618618
strbuf_rtrim(split[2]);
619619
strbuf_rtrim(split[3]);
620-
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);
621621
} else if (!input_merge_base && !split[2]) {
622-
result = real_merge(&o, NULL, split[0]->buf, split[1]->buf, prefix);
622+
real_merge(&o, NULL, split[0]->buf, split[1]->buf, prefix);
623623
} else {
624624
die(_("malformed input line: '%s'."), buf.buf);
625625
}
626+
maybe_flush_or_die(stdout, "stdout");
626627

627-
if (result < 0)
628-
die(_("merging cannot continue; got unclean result of %d"), result);
629628
strbuf_list_free(split);
630629
}
631630
strbuf_release(&buf);

0 commit comments

Comments
 (0)