]> git.ipfire.org Git - thirdparty/git.git/blob - t/t3432-rebase-fast-forward.sh
35bc94142d4765f655f4e3aae3c36b986b70729f
[thirdparty/git.git] / t / t3432-rebase-fast-forward.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2019 Denton Liu
4 #
5
6 test_description='ensure rebase fast-forwards commits when possible'
7
8 . ./test-lib.sh
9
10 test_expect_success setup '
11 test_commit A &&
12 test_commit B &&
13 test_commit C &&
14 test_commit D &&
15 git checkout -t -b side
16 '
17
18 test_rebase_same_head () {
19 status_n="$1" &&
20 shift &&
21 what_n="$1" &&
22 shift &&
23 cmp_n="$1" &&
24 shift &&
25 status_f="$1" &&
26 shift &&
27 what_f="$1" &&
28 shift &&
29 cmp_f="$1" &&
30 shift &&
31 test_rebase_same_head_ $status_n $what_n $cmp_n "" "$*" &&
32 test_rebase_same_head_ $status_f $what_f $cmp_f " --no-ff" "$*"
33 }
34
35 test_rebase_same_head_ () {
36 status="$1" &&
37 shift &&
38 what="$1" &&
39 shift &&
40 cmp="$1" &&
41 shift &&
42 flag="$1"
43 shift &&
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 &&
48 if test $what = work
49 then
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
54 then
55 test_i18ngrep 'is up to date' stdout &&
56 test_i18ngrep ! 'rebase forced' stdout
57 elif test $what = noop-force
58 then
59 test_i18ngrep 'is up to date, rebase forced' stdout
60 fi &&
61 newhead=\$(git rev-parse HEAD) &&
62 if test $cmp = same
63 then
64 test_cmp_rev \$oldhead \$newhead
65 elif test $cmp = diff
66 then
67 ! test_cmp_rev \$oldhead \$newhead
68 fi
69 "
70 }
71
72 changes='no changes'
73 test_rebase_same_head success work 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 --no-fork-point
79 test_rebase_same_head success work same success work same --fork-point master
80 test_rebase_same_head failure noop same success work diff --fork-point --onto B B
81 test_rebase_same_head failure work same success work diff --fork-point --onto B... B
82 test_rebase_same_head success work same success work same --fork-point --onto master... master
83
84 test_expect_success 'add work same to side' '
85 test_commit E
86 '
87
88 changes='our changes'
89 test_rebase_same_head success work same success work same
90 test_rebase_same_head success noop same success noop-force same master
91 test_rebase_same_head success noop same success noop-force diff --onto B B
92 test_rebase_same_head success noop same success noop-force diff --onto B... B
93 test_rebase_same_head success noop same success noop-force same --onto master... master
94 test_rebase_same_head success noop same success noop-force same --no-fork-point
95 test_rebase_same_head success work same success work same --fork-point master
96 test_rebase_same_head failure work same success work diff --fork-point --onto B B
97 test_rebase_same_head failure work same success work diff --fork-point --onto B... B
98 test_rebase_same_head success work same success work same --fork-point --onto master... master
99
100 test_expect_success 'add work same to upstream' '
101 git checkout master &&
102 test_commit F &&
103 git checkout side
104 '
105
106 changes='our and their changes'
107 test_rebase_same_head success noop same success noop-force diff --onto B B
108 test_rebase_same_head success noop same success noop-force diff --onto B... B
109 test_rebase_same_head success noop same success work diff --onto master... master
110 test_rebase_same_head failure work same success work diff --fork-point --onto B B
111 test_rebase_same_head failure work same success work diff --fork-point --onto B... B
112 test_rebase_same_head success noop same success work diff --fork-point --onto master... master
113
114 test_done