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 0 " --apply" "$*" &&
32 test_rebase_same_head_
$status_f $what_f $cmp_f 0 " --apply --no-ff" "$*"
33 test_rebase_same_head_
$status_n $what_n $cmp_n 0 " --merge" "$*" &&
34 test_rebase_same_head_
$status_f $what_f $cmp_f 0 " --merge --no-ff" "$*"
35 test_rebase_same_head_
$status_n $what_n $cmp_n 1 " --merge" "$*" &&
36 test_rebase_same_head_
$status_f $what_f $cmp_f 1 " --merge --no-ff" "$*"
39 test_rebase_same_head_
() {
50 if test $abbreviate -eq 1
52 msg
="git rebase$flag $* (rebase.abbreviateCommands = true) with $changes is $what with $cmp HEAD"
54 msg
="git rebase$flag $* with $changes is $what with $cmp HEAD"
56 test_expect_
$status "$msg" "
57 if test $abbreviate -eq 1
59 test_config rebase.abbreviateCommands true
61 oldhead=\$(git rev-parse HEAD) &&
62 test_when_finished 'git reset --hard \$oldhead' &&
63 git reflog HEAD >expect &&
64 git rebase$flag $* >stdout &&
65 git reflog HEAD >actual &&
68 old=\$(wc -l <expect) &&
69 test_line_count '-gt' \$old actual
70 elif test $what = noop
72 test_cmp expect actual
74 newhead=\$(git rev-parse HEAD) &&
77 test_cmp_rev \$oldhead \$newhead
80 test_cmp_rev ! \$oldhead \$newhead
86 test_rebase_same_head success noop same success work same
87 test_rebase_same_head success noop same success work same master
88 test_rebase_same_head success noop same success work
diff --onto B B
89 test_rebase_same_head success noop same success work
diff --onto B... B
90 test_rebase_same_head success noop same success work same
--onto master... master
91 test_rebase_same_head success noop same success work same
--keep-base master
92 test_rebase_same_head success noop same success work same
--keep-base
93 test_rebase_same_head success noop same success work same
--no-fork-point
94 test_rebase_same_head success noop same success work same
--keep-base --no-fork-point
95 test_rebase_same_head success noop same success work same
--fork-point master
96 test_rebase_same_head success noop same success work
diff --fork-point --onto B B
97 test_rebase_same_head success noop same success work
diff --fork-point --onto B... B
98 test_rebase_same_head success noop same success work same
--fork-point --onto master... master
99 test_rebase_same_head success noop same success work same
--keep-base --keep-base master
101 test_expect_success
'add work same to side' '
105 changes
='our changes'
106 test_rebase_same_head success noop same success work same
107 test_rebase_same_head success noop same success work same master
108 test_rebase_same_head success noop same success work
diff --onto B B
109 test_rebase_same_head success noop same success work
diff --onto B... B
110 test_rebase_same_head success noop same success work same
--onto master... master
111 test_rebase_same_head success noop same success work same
--keep-base master
112 test_rebase_same_head success noop same success work same
--keep-base
113 test_rebase_same_head success noop same success work same
--no-fork-point
114 test_rebase_same_head success noop same success work same
--keep-base --no-fork-point
115 test_rebase_same_head success noop same success work same
--fork-point master
116 test_rebase_same_head success noop same success work
diff --fork-point --onto B B
117 test_rebase_same_head success noop same success work
diff --fork-point --onto B... B
118 test_rebase_same_head success noop same success work same
--fork-point --onto master... master
119 test_rebase_same_head success noop same success work same
--fork-point --keep-base master
121 test_expect_success
'add work same to upstream' '
122 git checkout master &&
127 changes
='our and their changes'
128 test_rebase_same_head success noop same success work
diff --onto B B
129 test_rebase_same_head success noop same success work
diff --onto B... B
130 test_rebase_same_head success noop same success work
diff --onto master... master
131 test_rebase_same_head success noop same success work
diff --keep-base master
132 test_rebase_same_head success noop same success work
diff --keep-base
133 test_rebase_same_head failure work same success work
diff --fork-point --onto B B
134 test_rebase_same_head failure work same success work
diff --fork-point --onto B... B
135 test_rebase_same_head success noop same success work
diff --fork-point --onto master... master
136 test_rebase_same_head success noop same success work
diff --fork-point --keep-base master