update documentation for new zdiff3 conflictStyle

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Elijah Newren 2021-12-01 00:05:07 +00:00 committed by Junio C Hamano
parent 4496526f80
commit ddfc44a898
9 changed files with 50 additions and 21 deletions

View File

@ -4,7 +4,14 @@ merge.conflictStyle::
shows a `<<<<<<<` conflict marker, changes made by one side, shows a `<<<<<<<` conflict marker, changes made by one side,
a `=======` marker, changes made by the other side, and then a `=======` marker, changes made by the other side, and then
a `>>>>>>>` marker. An alternate style, "diff3", adds a `|||||||` a `>>>>>>>` marker. An alternate style, "diff3", adds a `|||||||`
marker and the original text before the `=======` marker. marker and the original text before the `=======` marker. The
"merge" style tends to produce smaller conflict regions than diff3,
both because of the exclusion of the original text, and because
when a subset of lines match on the two sides they are just pulled
out of the conflict region. Another alternate style, "zdiff3", is
similar to diff3 but removes matching lines on the two sides from
the conflict region when those matching lines appear near either
the beginning or end of a conflict region.
merge.defaultToUpstream:: merge.defaultToUpstream::
If merge is called without any commit argument, merge the upstream If merge is called without any commit argument, merge the upstream

View File

@ -266,8 +266,7 @@ When switching branches with `--merge`, staged changes may be lost.
The same as `--merge` option above, but changes the way the The same as `--merge` option above, but changes the way the
conflicting hunks are presented, overriding the conflicting hunks are presented, overriding the
`merge.conflictStyle` configuration variable. Possible values are `merge.conflictStyle` configuration variable. Possible values are
"merge" (default) and "diff3" (in addition to what is shown by "merge" (default), "diff3", and "zdiff3".
"merge" style, shows the original contents).
-p:: -p::
--patch:: --patch::

View File

@ -70,6 +70,9 @@ OPTIONS
--diff3:: --diff3::
Show conflicts in "diff3" style. Show conflicts in "diff3" style.
--zdiff3::
Show conflicts in "zdiff3" style.
--ours:: --ours::
--theirs:: --theirs::
--union:: --union::

View File

@ -240,7 +240,8 @@ from the RCS suite to present such a conflicted hunk, like this:
------------ ------------
Here are lines that are either unchanged from the common Here are lines that are either unchanged from the common
ancestor, or cleanly resolved because only one side changed. ancestor, or cleanly resolved because only one side changed,
or cleanly resolved because both sides changed the same way.
<<<<<<< yours:sample.txt <<<<<<< yours:sample.txt
Conflict resolution is hard; Conflict resolution is hard;
let's go shopping. let's go shopping.
@ -261,16 +262,37 @@ side wants to say it is hard and you'd prefer to go shopping, while the
other side wants to claim it is easy. other side wants to claim it is easy.
An alternative style can be used by setting the "merge.conflictStyle" An alternative style can be used by setting the "merge.conflictStyle"
configuration variable to "diff3". In "diff3" style, the above conflict configuration variable to either "diff3" or "zdiff3". In "diff3"
may look like this: style, the above conflict may look like this:
------------ ------------
Here are lines that are either unchanged from the common Here are lines that are either unchanged from the common
ancestor, or cleanly resolved because only one side changed. ancestor, or cleanly resolved because only one side changed,
<<<<<<< yours:sample.txt
or cleanly resolved because both sides changed the same way.
Conflict resolution is hard;
let's go shopping.
||||||| base:sample.txt
or cleanly resolved because both sides changed identically.
Conflict resolution is hard.
=======
or cleanly resolved because both sides changed the same way.
Git makes conflict resolution easy.
>>>>>>> theirs:sample.txt
And here is another line that is cleanly resolved or unmodified.
------------
while in "zdiff3" style, it may look like this:
------------
Here are lines that are either unchanged from the common
ancestor, or cleanly resolved because only one side changed,
or cleanly resolved because both sides changed the same way.
<<<<<<< yours:sample.txt <<<<<<< yours:sample.txt
Conflict resolution is hard; Conflict resolution is hard;
let's go shopping. let's go shopping.
||||||| ||||||| base:sample.txt
or cleanly resolved because both sides changed identically.
Conflict resolution is hard. Conflict resolution is hard.
======= =======
Git makes conflict resolution easy. Git makes conflict resolution easy.

View File

@ -714,9 +714,9 @@ information about the rebased commits and their parents (and instead
generates new fake commits based off limited information in the generates new fake commits based off limited information in the
generated patches), those commits cannot be identified; instead it has generated patches), those commits cannot be identified; instead it has
to fall back to a commit summary. Also, when merge.conflictStyle is to fall back to a commit summary. Also, when merge.conflictStyle is
set to diff3, the apply backend will use "constructed merge base" to set to diff3 or zdiff3, the apply backend will use "constructed merge
label the content from the merge base, and thus provide no information base" to label the content from the merge base, and thus provide no
about the merge base commit whatsoever. information about the merge base commit whatsoever.
The merge backend works with the full commits on both sides of history The merge backend works with the full commits on both sides of history
and thus has no such limitations. and thus has no such limitations.

View File

@ -92,8 +92,7 @@ in linkgit:git-checkout[1] for details.
The same as `--merge` option above, but changes the way the The same as `--merge` option above, but changes the way the
conflicting hunks are presented, overriding the conflicting hunks are presented, overriding the
`merge.conflictStyle` configuration variable. Possible values `merge.conflictStyle` configuration variable. Possible values
are "merge" (default) and "diff3" (in addition to what is are "merge" (default), "diff3", and "zdiff3".
shown by "merge" style, shows the original contents).
--ignore-unmerged:: --ignore-unmerged::
When restoring files on the working tree from the index, do When restoring files on the working tree from the index, do

View File

@ -137,8 +137,7 @@ should result in deletion of the path).
The same as `--merge` option above, but changes the way the The same as `--merge` option above, but changes the way the
conflicting hunks are presented, overriding the conflicting hunks are presented, overriding the
`merge.conflictStyle` configuration variable. Possible values are `merge.conflictStyle` configuration variable. Possible values are
"merge" (default) and "diff3" (in addition to what is shown by "merge" (default), "diff3", and "zdiff3".
"merge" style, shows the original contents).
-q:: -q::
--quiet:: --quiet::

View File

@ -14,9 +14,9 @@ conflicts before writing them to the rerere database.
Different conflict styles and branch names are normalized by stripping Different conflict styles and branch names are normalized by stripping
the labels from the conflict markers, and removing the common ancestor the labels from the conflict markers, and removing the common ancestor
version from the `diff3` conflict style. Branches that are merged version from the `diff3` or `zdiff3` conflict styles. Branches that
in different order are normalized by sorting the conflict hunks. More are merged in different order are normalized by sorting the conflict
on each of those steps in the following sections. hunks. More on each of those steps in the following sections.
Once these two normalization operations are applied, a conflict ID is Once these two normalization operations are applied, a conflict ID is
calculated based on the normalized conflict, which is later used by calculated based on the normalized conflict, which is later used by
@ -42,8 +42,8 @@ get a conflict like the following:
>>>>>>> AC >>>>>>> AC
Doing the analogous with AC2 (forking a branch ABAC2 off of branch AB Doing the analogous with AC2 (forking a branch ABAC2 off of branch AB
and then merging branch AC2 into it), using the diff3 conflict style, and then merging branch AC2 into it), using the diff3 or zdiff3
we get a conflict like the following: conflict style, we get a conflict like the following:
<<<<<<< HEAD <<<<<<< HEAD
B B

View File

@ -1517,7 +1517,7 @@ static struct option *add_common_options(struct checkout_opts *opts,
OPT_BOOL(0, "progress", &opts->show_progress, N_("force progress reporting")), OPT_BOOL(0, "progress", &opts->show_progress, N_("force progress reporting")),
OPT_BOOL('m', "merge", &opts->merge, N_("perform a 3-way merge with the new branch")), OPT_BOOL('m', "merge", &opts->merge, N_("perform a 3-way merge with the new branch")),
OPT_STRING(0, "conflict", &opts->conflict_style, N_("style"), OPT_STRING(0, "conflict", &opts->conflict_style, N_("style"),
N_("conflict style (merge or diff3)")), N_("conflict style (merge, diff3, or zdiff3)")),
OPT_END() OPT_END()
}; };
struct option *newopts = parse_options_concat(prevopts, options); struct option *newopts = parse_options_concat(prevopts, options);