3 # Copyright (c) 2019 Denton Liu
6 test_description
='ensure rebase fast-forwards commits when possible'
10 test_expect_success setup
'
15 git checkout -t -b side
18 test_rebase_same_head
() {
31 test_rebase_same_head_
$status_n $what_n $cmp_n "" "$*" &&
32 test_rebase_same_head_
$status_f $what_f $cmp_f " --no-ff" "$*"
35 test_rebase_same_head_
() {
44 test_expect_
$status "git rebase$flag $* with $changes is $what with $cmp HEAD" "
45 oldhead=\$(git rev-parse HEAD) &&
46 test_when_finished 'git reset --hard \$oldhead' &&
47 git rebase$flag $* >stdout &&
50 # Must check this case first, for 'is up to
51 # date, rebase forced[...]rewinding head' cases
52 test_i18ngrep 'rewinding head' stdout
53 elif test $what = noop
55 test_i18ngrep 'is up to date' stdout &&
56 test_i18ngrep ! 'rebase forced' stdout
57 elif test $what = noop-force
59 test_i18ngrep 'is up to date, rebase forced' stdout
61 newhead=\$(git rev-parse HEAD) &&
64 test_cmp_rev \$oldhead \$newhead
67 test_cmp_rev ! \$oldhead \$newhead
73 test_rebase_same_head success noop same success work same
74 test_rebase_same_head success noop same success noop-force same master
75 test_rebase_same_head success noop same success noop-force
diff --onto B B
76 test_rebase_same_head success noop same success noop-force
diff --onto B... B
77 test_rebase_same_head success noop same success noop-force same
--onto master... master
78 test_rebase_same_head success noop same success noop-force same
--keep-base master
79 test_rebase_same_head success noop same success noop-force same
--keep-base
80 test_rebase_same_head success noop same success noop-force same
--no-fork-point
81 test_rebase_same_head success noop same success noop-force same
--keep-base --no-fork-point
82 test_rebase_same_head success noop same success work same
--fork-point master
83 test_rebase_same_head success noop same success work
diff --fork-point --onto B B
84 test_rebase_same_head success noop same success work
diff --fork-point --onto B... B
85 test_rebase_same_head success noop same success work same
--fork-point --onto master... master
86 test_rebase_same_head success noop same success work same
--keep-base --keep-base master
88 test_expect_success
'add work same to side' '
93 test_rebase_same_head success noop same success work same
94 test_rebase_same_head success noop same success noop-force same master
95 test_rebase_same_head success noop same success noop-force
diff --onto B B
96 test_rebase_same_head success noop same success noop-force
diff --onto B... B
97 test_rebase_same_head success noop same success noop-force same
--onto master... master
98 test_rebase_same_head success noop same success noop-force same
--keep-base master
99 test_rebase_same_head success noop same success noop-force same
--keep-base
100 test_rebase_same_head success noop same success noop-force same
--no-fork-point
101 test_rebase_same_head success noop same success noop-force same
--keep-base --no-fork-point
102 test_rebase_same_head success noop same success work same
--fork-point master
103 test_rebase_same_head success noop same success work
diff --fork-point --onto B B
104 test_rebase_same_head success noop same success work
diff --fork-point --onto B... B
105 test_rebase_same_head success noop same success work same
--fork-point --onto master... master
106 test_rebase_same_head success noop same success work same
--fork-point --keep-base master
108 test_expect_success
'add work same to upstream' '
109 git checkout master &&
114 changes
='our and their changes'
115 test_rebase_same_head success noop same success noop-force
diff --onto B B
116 test_rebase_same_head success noop same success noop-force
diff --onto B... B
117 test_rebase_same_head success noop same success work
diff --onto master... master
118 test_rebase_same_head success noop same success work
diff --keep-base master
119 test_rebase_same_head success noop same success work
diff --keep-base
120 test_rebase_same_head failure work same success work
diff --fork-point --onto B B
121 test_rebase_same_head failure work same success work
diff --fork-point --onto B... B
122 test_rebase_same_head success noop same success work
diff --fork-point --onto master... master
123 test_rebase_same_head success noop same success work
diff --fork-point --keep-base master