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 " --apply" "$*" &&
32 test_rebase_same_head_ $status_f $what_f $cmp_f " --apply --no-ff" "$*"
33 test_rebase_same_head_ $status_n $what_n $cmp_n " --merge" "$*" &&
34 test_rebase_same_head_ $status_f $what_f $cmp_f " --merge --no-ff" "$*"
37 test_rebase_same_head_ () {
46 test_expect_$status "git rebase$flag $* with $changes is $what with $cmp HEAD" "
47 oldhead=\$(git rev-parse HEAD) &&
48 test_when_finished 'git reset --hard \$oldhead' &&
49 cp .git/logs/HEAD expect &&
50 git rebase$flag $* >stdout &&
53 old=\$(wc -l <expect) &&
54 test_line_count '-gt' \$old .git/logs/HEAD
55 elif test $what = noop
57 test_cmp expect .git/logs/HEAD
59 newhead=\$(git rev-parse HEAD) &&
62 test_cmp_rev \$oldhead \$newhead
65 test_cmp_rev ! \$oldhead \$newhead
71 test_rebase_same_head success noop same success work same
72 test_rebase_same_head success noop same success work same master
73 test_rebase_same_head success noop same success work diff --onto B B
74 test_rebase_same_head success noop same success work diff --onto B... B
75 test_rebase_same_head success noop same success work same --onto master... master
76 test_rebase_same_head success noop same success work same --keep-base master
77 test_rebase_same_head success noop same success work same --keep-base
78 test_rebase_same_head success noop same success work same --no-fork-point
79 test_rebase_same_head success noop same success work same --keep-base --no-fork-point
80 test_rebase_same_head success noop same success work same --fork-point master
81 test_rebase_same_head success noop same success work diff --fork-point --onto B B
82 test_rebase_same_head success noop same success work diff --fork-point --onto B... B
83 test_rebase_same_head success noop same success work same --fork-point --onto master... master
84 test_rebase_same_head success noop same success work same --keep-base --keep-base master
86 test_expect_success 'add work same to side' '
91 test_rebase_same_head success noop same success work same
92 test_rebase_same_head success noop same success work same master
93 test_rebase_same_head success noop same success work diff --onto B B
94 test_rebase_same_head success noop same success work diff --onto B... B
95 test_rebase_same_head success noop same success work same --onto master... master
96 test_rebase_same_head success noop same success work same --keep-base master
97 test_rebase_same_head success noop same success work same --keep-base
98 test_rebase_same_head success noop same success work same --no-fork-point
99 test_rebase_same_head success noop same success work same --keep-base --no-fork-point
100 test_rebase_same_head success noop same success work same --fork-point master
101 test_rebase_same_head success noop same success work diff --fork-point --onto B B
102 test_rebase_same_head success noop same success work diff --fork-point --onto B... B
103 test_rebase_same_head success noop same success work same --fork-point --onto master... master
104 test_rebase_same_head success noop same success work same --fork-point --keep-base master
106 test_expect_success 'add work same to upstream' '
107 git checkout master &&
112 changes='our and their changes'
113 test_rebase_same_head success noop same success work diff --onto B B
114 test_rebase_same_head success noop same success work diff --onto B... B
115 test_rebase_same_head success noop same success work diff --onto master... master
116 test_rebase_same_head success noop same success work diff --keep-base master
117 test_rebase_same_head success noop same success work diff --keep-base
118 test_rebase_same_head failure work same success work diff --fork-point --onto B B
119 test_rebase_same_head failure work same success work diff --fork-point --onto B... B
120 test_rebase_same_head success noop same success work diff --fork-point --onto master... master
121 test_rebase_same_head success noop same success work diff --fork-point --keep-base master