@@ -81,6 +81,31 @@ Whereas for a conflicted merge, the output is by default of the form:
8181
8282These are discussed individually below.
8383
84+ However, there is an exception. If `--stdin` is passed, then there is
85+ an extra section at the beginning, a NUL character at the end, and then
86+ all the sections repeat for each line of input. Thus, if the first merge
87+ is conflicted and the second is clean, the output would be of the form:
88+
89+ <Merge status>
90+ <OID of toplevel tree>
91+ <Conflicted file info>
92+ <Informational messages>
93+ NUL
94+ <Merge status>
95+ <OID of toplevel tree>
96+ NUL
97+
98+ [[MS]]
99+ Merge status
100+ ~~~~~~~~~~~~
101+
102+ This is an integer status followed by a NUL character. The integer status is:
103+
104+ 0: merge had conflicts
105+ 1: merge was clean
106+ <0: something prevented the merge from running (e.g. access to repository
107+ objects denied by filesystem)
108+
84109[[OIDTLT]]
85110OID of toplevel tree
86111~~~~~~~~~~~~~~~~~~~~
@@ -108,26 +133,61 @@ character instead of a newline character.
108133Informational messages
109134~~~~~~~~~~~~~~~~~~~~~~
110135
111- This always starts with a blank line (or NUL if `-z` is passed) to
112- separate it from the previous sections, and then has free-form
113- messages about the merge, such as:
136+ This section provides informational messages, typically about
137+ conflicts. The format of the section varies significantly depending
138+ on whether `-z` is passed.
139+
140+ If `-z` is passed:
141+
142+ The output format is zero or more conflict informational records, each
143+ of the form:
144+
145+ <list-of-paths><conflict-type>NUL<conflict-message>NUL
146+
147+ where <list-of-paths> is of the form
148+
149+ <number-of-paths>NUL<path1>NUL<path2>NUL...<pathN>NUL
150+
151+ and includes paths (or branch names) affected by the conflict or
152+ informational message in <conflict-message>. Also, <conflict-type> is a
153+ stable string explaining the type of conflict, such as
154+
155+ * "Auto-merging"
156+ * "CONFLICT (rename/delete)"
157+ * "CONFLICT (submodule lacks merge base)"
158+ * "CONFLICT (binary)"
159+
160+ and <conflict-message> is a more detailed message about the conflict which often
161+ (but not always) embeds the <stable-short-type-description> within it. These
162+ strings may change in future Git versions. Some examples:
114163
115164 * "Auto-merging <file>"
116165 * "CONFLICT (rename/delete): <oldfile> renamed...but deleted in..."
117- * "Failed to merge submodule <submodule> (<reason> )"
166+ * "Failed to merge submodule <submodule> (no merge base )"
118167 * "Warning: cannot merge binary files: <filename>"
119168
120- Note that these free-form messages will never have a NUL character
121- in or between them, even if -z is passed. It is simply a large block
122- of text taking up the remainder of the output.
169+ If `-z` is NOT passed:
170+
171+ This section starts with a blank line to separate it from the previous
172+ sections, and then only contains the <conflict-message> information
173+ from the previous section (separated by newlines). These are
174+ non-stable strings that should not be parsed by scripts, and are just
175+ meant for human consumption. Also, note that while <conflict-message>
176+ strings usually do not contain embedded newlines, they sometimes do.
177+ (However, the free-form messages will never have an embedded NUL
178+ character). So, the entire block of information is meant for human
179+ readers as an agglomeration of all conflict messages.
123180
124181EXIT STATUS
125182-----------
126183
127184For a successful, non-conflicted merge, the exit status is 0. When the
128185merge has conflicts, the exit status is 1. If the merge is not able to
129186complete (or start) due to some kind of error, the exit status is
130- something other than 0 or 1 (and the output is unspecified).
187+ something other than 0 or 1 (and the output is unspecified). When
188+ --stdin is passed, the return status is 0 for both successful and
189+ conflicted merges, and something other than 0 or 1 if it cannot complete
190+ all the requested merges.
131191
132192USAGE NOTES
133193-----------
0 commit comments