packfile.c: fix a typo in `each_file_in_pack_dir_fn()`'s declaration
[alt-git.git] / t / t3432-rebase-fast-forward.sh
blob7f1a5dd3deb10bef921654ef767a7cd53347bfd8
1 #!/bin/sh
3 # Copyright (c) 2019 Denton Liu
6 test_description='ensure rebase fast-forwards commits when possible'
8 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
9 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
11 TEST_PASSES_SANITIZE_LEAK=true
12 . ./test-lib.sh
14 test_expect_success setup '
15 test_commit A &&
16 test_commit B &&
17 test_commit C &&
18 test_commit D &&
19 git checkout -t -b side
22 test_rebase_same_head () {
23 status_n="$1" &&
24 shift &&
25 what_n="$1" &&
26 shift &&
27 cmp_n="$1" &&
28 shift &&
29 status_f="$1" &&
30 shift &&
31 what_f="$1" &&
32 shift &&
33 cmp_f="$1" &&
34 shift &&
35 test_rebase_same_head_ $status_n $what_n $cmp_n 0 " --apply" "$*" &&
36 test_rebase_same_head_ $status_f $what_f $cmp_f 0 " --apply --no-ff" "$*"
37 test_rebase_same_head_ $status_n $what_n $cmp_n 0 " --merge" "$*" &&
38 test_rebase_same_head_ $status_f $what_f $cmp_f 0 " --merge --no-ff" "$*"
39 test_rebase_same_head_ $status_n $what_n $cmp_n 1 " --merge" "$*" &&
40 test_rebase_same_head_ $status_f $what_f $cmp_f 1 " --merge --no-ff" "$*"
43 test_rebase_same_head_ () {
44 status="$1" &&
45 shift &&
46 what="$1" &&
47 shift &&
48 cmp="$1" &&
49 shift &&
50 abbreviate="$1" &&
51 shift &&
52 flag="$1"
53 shift &&
54 if test $abbreviate -eq 1
55 then
56 msg="git rebase$flag $* (rebase.abbreviateCommands = true) with $changes is $what with $cmp HEAD"
57 else
58 msg="git rebase$flag $* with $changes is $what with $cmp HEAD"
59 fi &&
60 test_expect_$status "$msg" "
61 if test $abbreviate -eq 1
62 then
63 test_config rebase.abbreviateCommands true
64 fi &&
65 oldhead=\$(git rev-parse HEAD) &&
66 test_when_finished 'git reset --hard \$oldhead' &&
67 git reflog HEAD >expect &&
68 git rebase$flag $* >stdout &&
69 git reflog HEAD >actual &&
70 if test $what = work
71 then
72 old=\$(wc -l <expect) &&
73 test_line_count '-gt' \$old actual
74 elif test $what = noop
75 then
76 test_cmp expect actual
77 fi &&
78 newhead=\$(git rev-parse HEAD) &&
79 if test $cmp = same
80 then
81 test_cmp_rev \$oldhead \$newhead
82 elif test $cmp = diff
83 then
84 test_cmp_rev ! \$oldhead \$newhead
89 changes='no changes'
90 test_rebase_same_head success noop same success work same
91 test_rebase_same_head success noop same success work same main
92 test_rebase_same_head success noop same success work diff --onto B B
93 test_rebase_same_head success noop same success work diff --onto B... B
94 test_rebase_same_head success noop same success work same --onto main... main
95 test_rebase_same_head success noop same success work same --keep-base main
96 test_rebase_same_head success noop same success work same --keep-base
97 test_rebase_same_head success noop same success work same --no-fork-point
98 test_rebase_same_head success noop same success work same --keep-base --no-fork-point
99 test_rebase_same_head success noop same success work same --fork-point main
100 test_rebase_same_head success noop same success work diff --fork-point --onto B B
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 same --fork-point --onto main... main
103 test_rebase_same_head success noop same success work same --keep-base --keep-base main
105 test_expect_success 'add work same to side' '
106 test_commit E
109 changes='our changes'
110 test_rebase_same_head success noop same success work same
111 test_rebase_same_head success noop same success work same main
112 test_rebase_same_head success noop same success work diff --onto B B
113 test_rebase_same_head success noop same success work diff --onto B... B
114 test_rebase_same_head success noop same success work same --onto main... main
115 test_rebase_same_head success noop same success work same --keep-base main
116 test_rebase_same_head success noop same success work same --keep-base
117 test_rebase_same_head success noop same success work same --no-fork-point
118 test_rebase_same_head success noop same success work same --keep-base --no-fork-point
119 test_rebase_same_head success noop same success work same --fork-point main
120 test_rebase_same_head success noop same success work diff --fork-point --onto B B
121 test_rebase_same_head success noop same success work diff --fork-point --onto B... B
122 test_rebase_same_head success noop same success work same --fork-point --onto main... main
123 test_rebase_same_head success noop same success work same --fork-point --keep-base main
125 test_expect_success 'add work same to upstream' '
126 git checkout main &&
127 test_commit F &&
128 git checkout side
131 changes='our and their changes'
132 test_rebase_same_head success noop same success work diff --onto B B
133 test_rebase_same_head success noop same success work diff --onto B... B
134 test_rebase_same_head success noop same success work diff --onto main... main
135 test_rebase_same_head success noop same success work diff --keep-base main
136 test_rebase_same_head success noop same success work diff --keep-base
137 test_rebase_same_head failure work same success work diff --fork-point --onto B B
138 test_rebase_same_head failure work same success work diff --fork-point --onto B... B
139 test_rebase_same_head success noop same success work diff --fork-point --onto main... main
140 test_rebase_same_head success noop same success work diff --fork-point --keep-base main
142 test_done