diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-02-25 14:19:36 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-02-25 14:19:36 -0800 |
| commit | 9b07c152dfce52663795fe9b4e1ed5626bfda455 (patch) | |
| tree | ecfdef38185d587686dc4e0fca893a7399fd9549 | |
| parent | 37b34c4e99f0fed81b7523d6e674ca976f994afc (diff) | |
| parent | 6a9ae8101525360b8f79ed20d2f483616bd39c90 (diff) | |
| download | git-9b07c152dfce52663795fe9b4e1ed5626bfda455.tar.gz | |
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
| -rw-r--r-- | Documentation/git-merge-tree.adoc | 11 | ||||
| -rw-r--r-- | builtin/merge-tree.c | 11 |
2 files changed, 13 insertions, 9 deletions
diff --git a/Documentation/git-merge-tree.adoc b/Documentation/git-merge-tree.adoc index 0b6a8a19b1..cf0578f9b5 100644 --- a/Documentation/git-merge-tree.adoc +++ b/Documentation/git-merge-tree.adoc @@ -40,11 +40,17 @@ After the merge completes, a new toplevel tree object is created. See OPTIONS ------- +--stdin:: + Read the commits to merge from the standard input rather than + the command-line. See <<INPUT,INPUT FORMAT>> below for more + information. Implies `-z`. + -z:: Do not quote filenames in the <Conflicted file info> section, and end each filename with a NUL character rather than newline. Also begin the messages section with a NUL character - instead of a newline. See <<OUTPUT>> below for more information. + instead of a newline. See <<OUTPUT,OUTPUT>> below for more + information. --name-only:: 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: 0: merge had conflicts 1: merge was clean - <0: something prevented the merge from running (e.g. access to repository - objects denied by filesystem) [[OIDTLT]] OID of toplevel tree @@ -235,6 +239,7 @@ with linkgit:git-merge[1]: * any messages that would have been printed to stdout (the <<IM,Informational messages>>) +[[INPUT]] INPUT FORMAT ------------ 'git merge-tree --stdin' input format is fully text based. Each line diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c index 9a6c8b4e4c..3ec7127b3a 100644 --- a/builtin/merge-tree.c +++ b/builtin/merge-tree.c @@ -18,6 +18,7 @@ #include "tree.h" #include "config.h" #include "strvec.h" +#include "write-or-die.h" static int line_termination = '\n'; @@ -575,7 +576,7 @@ int cmd_merge_tree(int argc, }; /* Init merge options */ - init_ui_merge_options(&o.merge_options, the_repository); + init_basic_merge_options(&o.merge_options, the_repository); /* Parse arguments */ original_argc = argc - 1; /* ignoring argv[0] */ @@ -600,7 +601,6 @@ int cmd_merge_tree(int argc, line_termination = '\0'; while (strbuf_getline_lf(&buf, stdin) != EOF) { struct strbuf **split; - int result; const char *input_merge_base = NULL; split = strbuf_split(&buf, ' '); @@ -617,15 +617,14 @@ int cmd_merge_tree(int argc, if (input_merge_base && split[2] && split[3] && !split[4]) { strbuf_rtrim(split[2]); strbuf_rtrim(split[3]); - result = real_merge(&o, input_merge_base, split[2]->buf, split[3]->buf, prefix); + real_merge(&o, input_merge_base, split[2]->buf, split[3]->buf, prefix); } else if (!input_merge_base && !split[2]) { - result = real_merge(&o, NULL, split[0]->buf, split[1]->buf, prefix); + real_merge(&o, NULL, split[0]->buf, split[1]->buf, prefix); } else { die(_("malformed input line: '%s'."), buf.buf); } + maybe_flush_or_die(stdout, "stdout"); - if (result < 0) - die(_("merging cannot continue; got unclean result of %d"), result); strbuf_list_free(split); } strbuf_release(&buf); |
