Skip to content

Commit 4ce498b

Browse files
committed
Merge branch 'en/zdiff3'
"Zealous diff3" style of merge conflict presentation has been added. * en/zdiff3: update documentation for new zdiff3 conflictStyle xdiff: implement a zealous diff3, or "zdiff3"
2 parents 62329d3 + ddfc44a commit 4ce498b

File tree

15 files changed

+205
-30
lines changed

15 files changed

+205
-30
lines changed

Documentation/config/merge.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ merge.conflictStyle::
44
shows a `<<<<<<<` conflict marker, changes made by one side,
55
a `=======` marker, changes made by the other side, and then
66
a `>>>>>>>` marker. An alternate style, "diff3", adds a `|||||||`
7-
marker and the original text before the `=======` marker.
7+
marker and the original text before the `=======` marker. The
8+
"merge" style tends to produce smaller conflict regions than diff3,
9+
both because of the exclusion of the original text, and because
10+
when a subset of lines match on the two sides they are just pulled
11+
out of the conflict region. Another alternate style, "zdiff3", is
12+
similar to diff3 but removes matching lines on the two sides from
13+
the conflict region when those matching lines appear near either
14+
the beginning or end of a conflict region.
815

916
merge.defaultToUpstream::
1017
If merge is called without any commit argument, merge the upstream

Documentation/git-checkout.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,7 @@ When switching branches with `--merge`, staged changes may be lost.
266266
The same as `--merge` option above, but changes the way the
267267
conflicting hunks are presented, overriding the
268268
`merge.conflictStyle` configuration variable. Possible values are
269-
"merge" (default) and "diff3" (in addition to what is shown by
270-
"merge" style, shows the original contents).
269+
"merge" (default), "diff3", and "zdiff3".
271270

272271
-p::
273272
--patch::

Documentation/git-merge-file.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ OPTIONS
7070
--diff3::
7171
Show conflicts in "diff3" style.
7272

73+
--zdiff3::
74+
Show conflicts in "zdiff3" style.
75+
7376
--ours::
7477
--theirs::
7578
--union::

Documentation/git-merge.txt

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ from the RCS suite to present such a conflicted hunk, like this:
240240

241241
------------
242242
Here are lines that are either unchanged from the common
243-
ancestor, or cleanly resolved because only one side changed.
243+
ancestor, or cleanly resolved because only one side changed,
244+
or cleanly resolved because both sides changed the same way.
244245
<<<<<<< yours:sample.txt
245246
Conflict resolution is hard;
246247
let's go shopping.
@@ -261,16 +262,37 @@ side wants to say it is hard and you'd prefer to go shopping, while the
261262
other side wants to claim it is easy.
262263

263264
An alternative style can be used by setting the "merge.conflictStyle"
264-
configuration variable to "diff3". In "diff3" style, the above conflict
265-
may look like this:
265+
configuration variable to either "diff3" or "zdiff3". In "diff3"
266+
style, the above conflict may look like this:
266267

267268
------------
268269
Here are lines that are either unchanged from the common
269-
ancestor, or cleanly resolved because only one side changed.
270+
ancestor, or cleanly resolved because only one side changed,
270271
<<<<<<< yours:sample.txt
272+
or cleanly resolved because both sides changed the same way.
271273
Conflict resolution is hard;
272274
let's go shopping.
273-
|||||||
275+
||||||| base:sample.txt
276+
or cleanly resolved because both sides changed identically.
277+
Conflict resolution is hard.
278+
=======
279+
or cleanly resolved because both sides changed the same way.
280+
Git makes conflict resolution easy.
281+
>>>>>>> theirs:sample.txt
282+
And here is another line that is cleanly resolved or unmodified.
283+
------------
284+
285+
while in "zdiff3" style, it may look like this:
286+
287+
------------
288+
Here are lines that are either unchanged from the common
289+
ancestor, or cleanly resolved because only one side changed,
290+
or cleanly resolved because both sides changed the same way.
291+
<<<<<<< yours:sample.txt
292+
Conflict resolution is hard;
293+
let's go shopping.
294+
||||||| base:sample.txt
295+
or cleanly resolved because both sides changed identically.
274296
Conflict resolution is hard.
275297
=======
276298
Git makes conflict resolution easy.

Documentation/git-rebase.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -714,9 +714,9 @@ information about the rebased commits and their parents (and instead
714714
generates new fake commits based off limited information in the
715715
generated patches), those commits cannot be identified; instead it has
716716
to fall back to a commit summary. Also, when merge.conflictStyle is
717-
set to diff3, the apply backend will use "constructed merge base" to
718-
label the content from the merge base, and thus provide no information
719-
about the merge base commit whatsoever.
717+
set to diff3 or zdiff3, the apply backend will use "constructed merge
718+
base" to label the content from the merge base, and thus provide no
719+
information about the merge base commit whatsoever.
720720

721721
The merge backend works with the full commits on both sides of history
722722
and thus has no such limitations.

Documentation/git-restore.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ in linkgit:git-checkout[1] for details.
9292
The same as `--merge` option above, but changes the way the
9393
conflicting hunks are presented, overriding the
9494
`merge.conflictStyle` configuration variable. Possible values
95-
are "merge" (default) and "diff3" (in addition to what is
96-
shown by "merge" style, shows the original contents).
95+
are "merge" (default), "diff3", and "zdiff3".
9796

9897
--ignore-unmerged::
9998
When restoring files on the working tree from the index, do

Documentation/git-switch.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ should result in deletion of the path).
137137
The same as `--merge` option above, but changes the way the
138138
conflicting hunks are presented, overriding the
139139
`merge.conflictStyle` configuration variable. Possible values are
140-
"merge" (default) and "diff3" (in addition to what is shown by
141-
"merge" style, shows the original contents).
140+
"merge" (default), "diff3", and "zdiff3".
142141

143142
-q::
144143
--quiet::

Documentation/technical/rerere.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ conflicts before writing them to the rerere database.
1414

1515
Different conflict styles and branch names are normalized by stripping
1616
the labels from the conflict markers, and removing the common ancestor
17-
version from the `diff3` conflict style. Branches that are merged
18-
in different order are normalized by sorting the conflict hunks. More
19-
on each of those steps in the following sections.
17+
version from the `diff3` or `zdiff3` conflict styles. Branches that
18+
are merged in different order are normalized by sorting the conflict
19+
hunks. More on each of those steps in the following sections.
2020

2121
Once these two normalization operations are applied, a conflict ID is
2222
calculated based on the normalized conflict, which is later used by
@@ -42,8 +42,8 @@ get a conflict like the following:
4242
>>>>>>> AC
4343

4444
Doing the analogous with AC2 (forking a branch ABAC2 off of branch AB
45-
and then merging branch AC2 into it), using the diff3 conflict style,
46-
we get a conflict like the following:
45+
and then merging branch AC2 into it), using the diff3 or zdiff3
46+
conflict style, we get a conflict like the following:
4747

4848
<<<<<<< HEAD
4949
B

builtin/checkout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,7 @@ static struct option *add_common_options(struct checkout_opts *opts,
15361536
OPT_BOOL(0, "progress", &opts->show_progress, N_("force progress reporting")),
15371537
OPT_BOOL('m', "merge", &opts->merge, N_("perform a 3-way merge with the new branch")),
15381538
OPT_STRING(0, "conflict", &opts->conflict_style, N_("style"),
1539-
N_("conflict style (merge or diff3)")),
1539+
N_("conflict style (merge, diff3, or zdiff3)")),
15401540
OPT_END()
15411541
};
15421542
struct option *newopts = parse_options_concat(prevopts, options);

builtin/merge-file.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
3434
struct option options[] = {
3535
OPT_BOOL('p', "stdout", &to_stdout, N_("send results to standard output")),
3636
OPT_SET_INT(0, "diff3", &xmp.style, N_("use a diff3 based merge"), XDL_MERGE_DIFF3),
37+
OPT_SET_INT(0, "zdiff3", &xmp.style, N_("use a zealous diff3 based merge"),
38+
XDL_MERGE_ZEALOUS_DIFF3),
3739
OPT_SET_INT(0, "ours", &xmp.favor, N_("for conflicts, use our version"),
3840
XDL_MERGE_FAVOR_OURS),
3941
OPT_SET_INT(0, "theirs", &xmp.favor, N_("for conflicts, use their version"),

0 commit comments

Comments
 (0)