Skip to content

Commit 4bb0936

Browse files
jrngitster
authored andcommitted
merge-file --diff3: add a label for ancestor
git merge-file --diff3 can be used to present conflicts hunks including text from the common ancestor. The added information is helpful for resolving a merge by hand, and merge tools can usually grok it because it looks like output from diff3 -m. However, ‘diff3’ includes a label for the merge base on the ||||||| line and some tools cannot parse conflict hunks without such a label. Write the base-name as passed in a -L option (or the name of the ancestor file by default) on that line. git rerere will not have trouble parsing this output, since instead of looking for a newline, it looks for whitespace after the ||||||| marker. Since rerere includes its own code for recreating conflict hunks, conflict identifiers are unaffected. No other code in git tries to parse conflict hunks. Requested-by: Stefan Monnier <monnier@iro.umontreal.ca> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent a4b5e91 commit 4bb0936

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

builtin/merge-file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
7777
argv[i]);
7878
}
7979

80+
xmp.ancestor = names[1];
8081
xmp.file1 = names[0];
8182
xmp.file2 = names[2];
8283
ret = xdl_merge(mmfs + 1, mmfs + 0, mmfs + 2, &xmp, &result);

t/t6023-merge-file.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ et nihil mihi deerit;
181181
182182
In loco pascuae ibi me collocavit;
183183
super aquam refectionis educavit me.
184-
|||||||
184+
||||||| new5.txt
185185
et nihil mihi deerit.
186186
In loco pascuae ibi me collocavit,
187187
super aquam refectionis educavit me;
@@ -225,7 +225,7 @@ et nihil mihi deerit;
225225
226226
In loco pascuae ibi me collocavit;
227227
super aquam refectionis educavit me.
228-
||||||||||
228+
|||||||||| new5.txt
229229
et nihil mihi deerit.
230230
In loco pascuae ibi me collocavit,
231231
super aquam refectionis educavit me;

0 commit comments

Comments
 (0)