use strpbrk(3) to search for characters from a given set
[git/debian.git] / t / t3432-rebase-fast-forward.sh
blob92f95b57da1424348b5fd898daf0c7722d4f20d2
1 #!/bin/sh
3 # Copyright (c) 2019 Denton Liu
6 test_description='ensure rebase fast-forwards commits when possible'
8 . ./test-lib.sh
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
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" "$*"
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
72 changes='no changes'
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' '
89 test_commit E
92 changes='our changes'
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 &&
110 test_commit F &&
111 git checkout side
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
125 test_done