Skip to content

Commit aca13c2

Browse files
committed
Merge branch 'en/merge-strategy-docs'
Documentation updates. * en/merge-strategy-docs: Update error message and code comment merge-strategies.txt: add coverage of the `ort` merge strategy git-rebase.txt: correct out-of-date and misleading text about renames merge-strategies.txt: fix simple capitalization error merge-strategies.txt: avoid giving special preference to patience algorithm merge-strategies.txt: do not imply using copy detection is desired merge-strategies.txt: update wording for the resolve strategy Documentation: edit awkward references to `git merge-recursive` directory-rename-detection.txt: small updates due to merge-ort optimizations git-rebase.txt: correct antiquated claims about --rebase-merges
2 parents 7d0daf3 + 81483fe commit aca13c2

File tree

6 files changed

+55
-42
lines changed

6 files changed

+55
-42
lines changed

Documentation/git-rebase.txt

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,7 @@ See also INCOMPATIBLE OPTIONS below.
340340

341341
-m::
342342
--merge::
343-
Use merging strategies to rebase. When the recursive (default) merge
344-
strategy is used, this allows rebase to be aware of renames on the
345-
upstream side. This is the default.
343+
Using merging strategies to rebase (default).
346344
+
347345
Note that a rebase merge works by replaying each commit from the working
348346
branch on top of the <upstream> branch. Because of this, when a merge
@@ -354,9 +352,8 @@ See also INCOMPATIBLE OPTIONS below.
354352

355353
-s <strategy>::
356354
--strategy=<strategy>::
357-
Use the given merge strategy.
358-
If there is no `-s` option 'git merge-recursive' is used
359-
instead. This implies --merge.
355+
Use the given merge strategy, instead of the default
356+
`recursive`. This implies `--merge`.
360357
+
361358
Because 'git rebase' replays each commit from the working branch
362359
on top of the <upstream> branch using the given strategy, using
@@ -530,7 +527,7 @@ The `--rebase-merges` mode is similar in spirit to the deprecated
530527
where commits can be reordered, inserted and dropped at will.
531528
+
532529
It is currently only possible to recreate the merge commits using the
533-
`recursive` merge strategy; Different merge strategies can be used only via
530+
`recursive` merge strategy; different merge strategies can be used only via
534531
explicit `exec git merge -s <strategy> [...]` commands.
535532
+
536533
See also REBASING MERGES and INCOMPATIBLE OPTIONS below.
@@ -1219,12 +1216,16 @@ successful merge so that the user can edit the message.
12191216
If a `merge` command fails for any reason other than merge conflicts (i.e.
12201217
when the merge operation did not even start), it is rescheduled immediately.
12211218

1222-
At this time, the `merge` command will *always* use the `recursive`
1223-
merge strategy for regular merges, and `octopus` for octopus merges,
1224-
with no way to choose a different one. To work around
1225-
this, an `exec` command can be used to call `git merge` explicitly,
1226-
using the fact that the labels are worktree-local refs (the ref
1227-
`refs/rewritten/onto` would correspond to the label `onto`, for example).
1219+
By default, the `merge` command will use the `recursive` merge
1220+
strategy for regular merges, and `octopus` for octopus merges. One
1221+
can specify a default strategy for all merges using the `--strategy`
1222+
argument when invoking rebase, or can override specific merges in the
1223+
interactive list of commands by using an `exec` command to call `git
1224+
merge` explicitly with a `--strategy` argument. Note that when
1225+
calling `git merge` explicitly like this, you can make use of the fact
1226+
that the labels are worktree-local refs (the ref `refs/rewritten/onto`
1227+
would correspond to the label `onto`, for example) in order to refer
1228+
to the branches you want to merge.
12281229

12291230
Note: the first command (`label onto`) labels the revision onto which
12301231
the commits are rebased; The name `onto` is just a convention, as a nod

Documentation/merge-options.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ endif::git-pull[]
144144
Use the given merge strategy; can be supplied more than
145145
once to specify them in the order they should be tried.
146146
If there is no `-s` option, a built-in list of strategies
147-
is used instead ('git merge-recursive' when merging a single
148-
head, 'git merge-octopus' otherwise).
147+
is used instead (`recursive` when merging a single head,
148+
`octopus` otherwise).
149149

150150
-X <option>::
151151
--strategy-option=<option>::

Documentation/merge-strategies.txt

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@ backend 'merge strategies' to be chosen with `-s` option. Some strategies
66
can also take their own options, which can be passed by giving `-X<option>`
77
arguments to `git merge` and/or `git pull`.
88

9-
resolve::
10-
This can only resolve two heads (i.e. the current branch
11-
and another branch you pulled from) using a 3-way merge
12-
algorithm. It tries to carefully detect criss-cross
13-
merge ambiguities and is considered generally safe and
14-
fast.
15-
169
recursive::
1710
This can only resolve two heads using a 3-way merge
1811
algorithm. When there is more than one common
@@ -23,9 +16,9 @@ recursive::
2316
causing mismerges by tests done on actual merge commits
2417
taken from Linux 2.6 kernel development history.
2518
Additionally this can detect and handle merges involving
26-
renames, but currently cannot make use of detected
27-
copies. This is the default merge strategy when pulling
28-
or merging one branch.
19+
renames. It does not make use of detected copies. This
20+
is the default merge strategy when pulling or merging one
21+
branch.
2922
+
3023
The 'recursive' strategy can take the following options:
3124

@@ -44,17 +37,14 @@ theirs;;
4437
no 'theirs' merge strategy to confuse this merge option with.
4538

4639
patience;;
47-
With this option, 'merge-recursive' spends a little extra time
48-
to avoid mismerges that sometimes occur due to unimportant
49-
matching lines (e.g., braces from distinct functions). Use
50-
this when the branches to be merged have diverged wildly.
51-
See also linkgit:git-diff[1] `--patience`.
40+
Deprecated synonym for `diff-algorithm=patience`.
5241

5342
diff-algorithm=[patience|minimal|histogram|myers];;
54-
Tells 'merge-recursive' to use a different diff algorithm, which
55-
can help avoid mismerges that occur due to unimportant matching
56-
lines (such as braces from distinct functions). See also
57-
linkgit:git-diff[1] `--diff-algorithm`.
43+
Use a different diff algorithm while merging, which can help
44+
avoid mismerges that occur due to unimportant matching lines
45+
(such as braces from distinct functions). See also
46+
linkgit:git-diff[1] `--diff-algorithm`. Defaults to the
47+
`diff.algorithm` config setting.
5848

5949
ignore-space-change;;
6050
ignore-all-space;;
@@ -105,6 +95,26 @@ subtree[=<path>];;
10595
is prefixed (or stripped from the beginning) to make the shape of
10696
two trees to match.
10797

98+
ort::
99+
This is meant as a drop-in replacement for the `recursive`
100+
algorithm (as reflected in its acronym -- "Ostensibly
101+
Recursive's Twin"), and will likely replace it in the future.
102+
It fixes corner cases that the `recursive` strategy handles
103+
suboptimally, and is significantly faster in large
104+
repositories -- especially when many renames are involved.
105+
+
106+
The `ort` strategy takes all the same options as `recursive`.
107+
However, it ignores three of those options: `no-renames`,
108+
`patience` and `diff-algorithm`. It always runs with rename
109+
detection (it handles it much faster than `recursive` does), and
110+
it specifically uses `diff-algorithm=histogram`.
111+
112+
resolve::
113+
This can only resolve two heads (i.e. the current branch
114+
and another branch you pulled from) using a 3-way merge
115+
algorithm. It tries to carefully detect criss-cross
116+
merge ambiguities. It does not handle renames.
117+
108118
octopus::
109119
This resolves cases with more than two heads, but refuses to do
110120
a complex merge that needs manual resolution. It is

Documentation/technical/directory-rename-detection.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ Directory rename detection
22
==========================
33

44
Rename detection logic in diffcore-rename that checks for renames of
5-
individual files is aggregated and analyzed in merge-recursive for cases
6-
where combinations of renames indicate that a full directory has been
7-
renamed.
5+
individual files is also aggregated there and then analyzed in either
6+
merge-ort or merge-recursive for cases where combinations of renames
7+
indicate that a full directory has been renamed.
88

99
Scope of abilities
1010
------------------
@@ -88,9 +88,11 @@ directory rename detection support in:
8888
Folks have requested in the past that `git diff` detect directory
8989
renames and somehow simplify its output. It is not clear whether this
9090
would be desirable or how the output should be simplified, so this was
91-
simply not implemented. Further, to implement this, directory rename
92-
detection logic would need to move from merge-recursive to
93-
diffcore-rename.
91+
simply not implemented. Also, while diffcore-rename has most of the
92+
logic for detecting directory renames, some of the logic is still found
93+
within merge-ort and merge-recursive. Fully supporting directory
94+
rename detection in diffs would require copying or moving the remaining
95+
bits of logic to the diff machinery.
9496

9597
* am
9698

builtin/merge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
739739

740740
for (x = 0; x < xopts_nr; x++)
741741
if (parse_merge_opt(&o, xopts[x]))
742-
die(_("Unknown option for merge-recursive: -X%s"), xopts[x]);
742+
die(_("unknown strategy option: -X%s"), xopts[x]);
743743

744744
o.branch1 = head_arg;
745745
o.branch2 = merge_remote_util(remoteheads->item)->name;

sequencer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2065,7 +2065,7 @@ static int do_pick_commit(struct repository *r,
20652065
/*
20662066
* We do not intend to commit immediately. We just want to
20672067
* merge the differences in, so let's compute the tree
2068-
* that represents the "current" state for merge-recursive
2068+
* that represents the "current" state for the merge machinery
20692069
* to work on.
20702070
*/
20712071
if (write_index_as_tree(&head, r->index, r->index_file, 0, NULL))

0 commit comments

Comments
 (0)