Skip to content

Commit 2ac0d62

Browse files
newrengitster
authored andcommitted
rebase: change the default backend from "am" to "merge"
The am-backend drops information and thus limits what we can do: * lack of full tree information from the original commits means we cannot do directory rename detection and warn users that they might want to move some of their new files that they placed in old directories to prevent their becoming orphaned.[1] * reduction in context from only having a few lines beyond those changed means that when context lines are non-unique we can apply patches incorrectly.[2] * lack of access to original commits means that conflict marker annotation has less information available. * the am backend has safety problems with an ill-timed interrupt. Also, the merge/interactive backend have far more abilities, appear to currently have a slight performance advantage[3] and have room for more optimizations than the am backend[4] (and work is underway to take advantage of some of those possibilities). [1] https://lore.kernel.org/git/[email protected]/ [2] https://lore.kernel.org/git/CABPp-BGiu2nVMQY_t-rnFR5GQUz_ipyEE8oDocKeO+h+t4Mn4A@mail.gmail.com/ [3] https://public-inbox.org/git/CABPp-BF=ev03WgODk6TMQmuNoatg2kiEe5DR__gJ0OTVqHSnfQ@mail.gmail.com/ [4] https://lore.kernel.org/git/CABPp-BGh7yW69QwxQb13K0HM38NKmQif3A6C6UULEKYnkEJ5vA@mail.gmail.com/ Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8295ed6 commit 2ac0d62

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

Documentation/git-rebase.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ See also INCOMPATIBLE OPTIONS below.
315315
--merge::
316316
Use merging strategies to rebase. When the recursive (default) merge
317317
strategy is used, this allows rebase to be aware of renames on the
318-
upstream side.
318+
upstream side. This is the default.
319319
+
320320
Note that a rebase merge works by replaying each commit from the working
321321
branch on top of the <upstream> branch. Because of this, when a merge
@@ -683,6 +683,17 @@ accident of implementation rather than by design. Both backends
683683
should have the same behavior, though it is not clear which one is
684684
correct.
685685

686+
Interruptability
687+
~~~~~~~~~~~~~~~~
688+
689+
The am backend has safety problems with an ill-timed interrupt; if the
690+
user presses Ctrl-C at the wrong time to try to abort the rebase, the
691+
rebase can enter a state where it cannot be aborted with a subsequent
692+
`git rebase --abort`. The interactive backend does not appear to
693+
suffer from the same shortcoming. (See
694+
https://lore.kernel.org/git/[email protected]/ for
695+
details.)
696+
686697
Miscellaneous differences
687698
~~~~~~~~~~~~~~~~~~~~~~~~~
688699

builtin/rebase.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ struct rebase_options {
101101
#define REBASE_OPTIONS_INIT { \
102102
.type = REBASE_UNSPECIFIED, \
103103
.empty = EMPTY_UNSPECIFIED, \
104-
.default_backend = "am", \
104+
.default_backend = "merge", \
105105
.flags = REBASE_NO_QUIET, \
106106
.git_am_opts = ARGV_ARRAY_INIT, \
107107
.git_format_patch_opt = STRBUF_INIT \
@@ -1917,7 +1917,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
19171917

19181918
if (options.type == REBASE_UNSPECIFIED) {
19191919
if (!strcmp(options.default_backend, "merge"))
1920-
options.type = REBASE_MERGE;
1920+
imply_interactive(&options, "--merge");
19211921
else if (!strcmp(options.default_backend, "am"))
19221922
options.type = REBASE_AM;
19231923
else

t/t5520-pull.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ test_expect_success '--rebase with conflicts shows advice' '
340340
test_tick &&
341341
git commit -m "Create conflict" seq.txt &&
342342
test_must_fail git pull --rebase . seq 2>err >out &&
343-
test_i18ngrep "Resolve all conflicts manually" out
343+
test_i18ngrep "Resolve all conflicts manually" err
344344
'
345345

346346
test_expect_success 'failed --rebase shows advice' '
@@ -354,7 +354,7 @@ test_expect_success 'failed --rebase shows advice' '
354354
git checkout -f -b fails-to-rebase HEAD^ &&
355355
test_commit v2-without-cr file "2" file2-lf &&
356356
test_must_fail git pull --rebase . diverging 2>err >out &&
357-
test_i18ngrep "Resolve all conflicts manually" out
357+
test_i18ngrep "Resolve all conflicts manually" err
358358
'
359359

360360
test_expect_success '--rebase fails with multiple branches' '
@@ -774,8 +774,10 @@ test_expect_success 'git pull --rebase does not reapply old patches' '
774774
(
775775
cd dst &&
776776
test_must_fail git pull --rebase &&
777-
find .git/rebase-apply -name "000*" >patches &&
778-
test_line_count = 1 patches
777+
cat .git/rebase-merge/done .git/rebase-merge/git-rebase-todo >work &&
778+
grep -v -e \# -e ^$ work >patches &&
779+
test_line_count = 1 patches &&
780+
rm -f work
779781
)
780782
'
781783

t/t9106-git-svn-commit-diff-clobber.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ test_expect_success 'multiple dcommit from git svn will not clobber svn' "
9292

9393

9494
test_expect_success 'check that rebase really failed' '
95-
test -d .git/rebase-apply
95+
git status >output &&
96+
grep currently.rebasing output
9697
'
9798

9899
test_expect_success 'resolve, continue the rebase and dcommit' "

0 commit comments

Comments
 (0)