Browse Source
"git rebase --keep-base <upstream>" tries to find the original base of the topic being rebased and rebase on top of that same base, which is useful when running the "git rebase -i" (and its limited variant "git rebase -x"). The command also has learned to fast-forward in more cases where it can instead of replaying to recreate identical commits. * dl/rebase-i-keep-base: rebase: teach rebase --keep-base rebase tests: test linear branch topology rebase: fast-forward --fork-point in more cases rebase: fast-forward --onto in more cases rebase: refactor can_fast_forward into goto tower t3432: test for --no-ff's interaction with fast-forward t3432: distinguish "noop-same" v.s. "work-same" in "same head" tests t3432: test rebase fast-forward behavior t3431: add rebase --fork-point testsmaint
Junio C Hamano
5 years ago
9 changed files with 360 additions and 28 deletions
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
#!/bin/sh |
||||
# |
||||
# Copyright (c) 2019 Denton Liu |
||||
# |
||||
|
||||
test_description='git rebase --fork-point test' |
||||
|
||||
. ./test-lib.sh |
||||
|
||||
# A---B---D---E (master) |
||||
# \ |
||||
# C*---F---G (side) |
||||
# |
||||
# C was formerly part of master but master was rewound to remove C |
||||
# |
||||
test_expect_success setup ' |
||||
test_commit A && |
||||
test_commit B && |
||||
test_commit C && |
||||
git branch -t side && |
||||
git reset --hard HEAD^ && |
||||
test_commit D && |
||||
test_commit E && |
||||
git checkout side && |
||||
test_commit F && |
||||
test_commit G |
||||
' |
||||
|
||||
test_rebase () { |
||||
expected="$1" && |
||||
shift && |
||||
test_expect_success "git rebase $*" " |
||||
git checkout master && |
||||
git reset --hard E && |
||||
git checkout side && |
||||
git reset --hard G && |
||||
git rebase $* && |
||||
test_write_lines $expected >expect && |
||||
git log --pretty=%s >actual && |
||||
test_cmp expect actual |
||||
" |
||||
} |
||||
|
||||
test_rebase 'G F E D B A' |
||||
test_rebase 'G F D B A' --onto D |
||||
test_rebase 'G F B A' --keep-base |
||||
test_rebase 'G F C E D B A' --no-fork-point |
||||
test_rebase 'G F C D B A' --no-fork-point --onto D |
||||
test_rebase 'G F C B A' --no-fork-point --keep-base |
||||
test_rebase 'G F E D B A' --fork-point refs/heads/master |
||||
test_rebase 'G F D B A' --fork-point --onto D refs/heads/master |
||||
test_rebase 'G F B A' --fork-point --keep-base refs/heads/master |
||||
test_rebase 'G F C E D B A' refs/heads/master |
||||
test_rebase 'G F C D B A' --onto D refs/heads/master |
||||
test_rebase 'G F C B A' --keep-base refs/heads/master |
||||
|
||||
test_done |
@ -0,0 +1,125 @@
@@ -0,0 +1,125 @@
|
||||
#!/bin/sh |
||||
# |
||||
# Copyright (c) 2019 Denton Liu |
||||
# |
||||
|
||||
test_description='ensure rebase fast-forwards commits when possible' |
||||
|
||||
. ./test-lib.sh |
||||
|
||||
test_expect_success setup ' |
||||
test_commit A && |
||||
test_commit B && |
||||
test_commit C && |
||||
test_commit D && |
||||
git checkout -t -b side |
||||
' |
||||
|
||||
test_rebase_same_head () { |
||||
status_n="$1" && |
||||
shift && |
||||
what_n="$1" && |
||||
shift && |
||||
cmp_n="$1" && |
||||
shift && |
||||
status_f="$1" && |
||||
shift && |
||||
what_f="$1" && |
||||
shift && |
||||
cmp_f="$1" && |
||||
shift && |
||||
test_rebase_same_head_ $status_n $what_n $cmp_n "" "$*" && |
||||
test_rebase_same_head_ $status_f $what_f $cmp_f " --no-ff" "$*" |
||||
} |
||||
|
||||
test_rebase_same_head_ () { |
||||
status="$1" && |
||||
shift && |
||||
what="$1" && |
||||
shift && |
||||
cmp="$1" && |
||||
shift && |
||||
flag="$1" |
||||
shift && |
||||
test_expect_$status "git rebase$flag $* with $changes is $what with $cmp HEAD" " |
||||
oldhead=\$(git rev-parse HEAD) && |
||||
test_when_finished 'git reset --hard \$oldhead' && |
||||
git rebase$flag $* >stdout && |
||||
if test $what = work |
||||
then |
||||
# Must check this case first, for 'is up to |
||||
# date, rebase forced[...]rewinding head' cases |
||||
test_i18ngrep 'rewinding head' stdout |
||||
elif test $what = noop |
||||
then |
||||
test_i18ngrep 'is up to date' stdout && |
||||
test_i18ngrep ! 'rebase forced' stdout |
||||
elif test $what = noop-force |
||||
then |
||||
test_i18ngrep 'is up to date, rebase forced' stdout |
||||
fi && |
||||
newhead=\$(git rev-parse HEAD) && |
||||
if test $cmp = same |
||||
then |
||||
test_cmp_rev \$oldhead \$newhead |
||||
elif test $cmp = diff |
||||
then |
||||
! test_cmp_rev \$oldhead \$newhead |
||||
fi |
||||
" |
||||
} |
||||
|
||||
changes='no changes' |
||||
test_rebase_same_head success noop same success work same |
||||
test_rebase_same_head success noop same success noop-force same master |
||||
test_rebase_same_head success noop same success noop-force diff --onto B B |
||||
test_rebase_same_head success noop same success noop-force diff --onto B... B |
||||
test_rebase_same_head success noop same success noop-force same --onto master... master |
||||
test_rebase_same_head success noop same success noop-force same --keep-base master |
||||
test_rebase_same_head success noop same success noop-force same --keep-base |
||||
test_rebase_same_head success noop same success noop-force same --no-fork-point |
||||
test_rebase_same_head success noop same success noop-force same --keep-base --no-fork-point |
||||
test_rebase_same_head success noop same success work same --fork-point master |
||||
test_rebase_same_head success noop same success work diff --fork-point --onto B B |
||||
test_rebase_same_head success noop same success work diff --fork-point --onto B... B |
||||
test_rebase_same_head success noop same success work same --fork-point --onto master... master |
||||
test_rebase_same_head success noop same success work same --keep-base --keep-base master |
||||
|
||||
test_expect_success 'add work same to side' ' |
||||
test_commit E |
||||
' |
||||
|
||||
changes='our changes' |
||||
test_rebase_same_head success noop same success work same |
||||
test_rebase_same_head success noop same success noop-force same master |
||||
test_rebase_same_head success noop same success noop-force diff --onto B B |
||||
test_rebase_same_head success noop same success noop-force diff --onto B... B |
||||
test_rebase_same_head success noop same success noop-force same --onto master... master |
||||
test_rebase_same_head success noop same success noop-force same --keep-base master |
||||
test_rebase_same_head success noop same success noop-force same --keep-base |
||||
test_rebase_same_head success noop same success noop-force same --no-fork-point |
||||
test_rebase_same_head success noop same success noop-force same --keep-base --no-fork-point |
||||
test_rebase_same_head success noop same success work same --fork-point master |
||||
test_rebase_same_head success noop same success work diff --fork-point --onto B B |
||||
test_rebase_same_head success noop same success work diff --fork-point --onto B... B |
||||
test_rebase_same_head success noop same success work same --fork-point --onto master... master |
||||
test_rebase_same_head success noop same success work same --fork-point --keep-base master |
||||
|
||||
test_expect_success 'add work same to upstream' ' |
||||
git checkout master && |
||||
test_commit F && |
||||
git checkout side |
||||
' |
||||
|
||||
changes='our and their changes' |
||||
test_rebase_same_head success noop same success noop-force diff --onto B B |
||||
test_rebase_same_head success noop same success noop-force diff --onto B... B |
||||
test_rebase_same_head success noop same success work diff --onto master... master |
||||
test_rebase_same_head success noop same success work diff --keep-base master |
||||
test_rebase_same_head success noop same success work diff --keep-base |
||||
test_rebase_same_head failure work same success work diff --fork-point --onto B B |
||||
test_rebase_same_head failure work same success work diff --fork-point --onto B... B |
||||
test_rebase_same_head success noop same success work diff --fork-point --onto master... master |
||||
test_rebase_same_head success noop same success work diff --fork-point --keep-base master |
||||
|
||||
test_done |
Loading…
Reference in new issue