fsck.c: add an fsck_set_msg_type() API that takes enums
[git/debian.git] / t / t3403-rebase-skip.sh
blobe26762d0b29400f687df390d0b8e4c52e6f3bba0
1 #!/bin/sh
3 # Copyright (c) 2006 Eric Wong
6 test_description='git rebase --merge --skip tests'
8 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
9 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
11 . ./test-lib.sh
13 . "$TEST_DIRECTORY"/lib-rebase.sh
15 # we assume the default git am -3 --skip strategy is tested independently
16 # and always works :)
18 test_expect_success setup '
19 echo hello > hello &&
20 git add hello &&
21 git commit -m "hello" &&
22 git branch skip-reference &&
24 echo world >> hello &&
25 git commit -a -m "hello world" &&
26 echo goodbye >> hello &&
27 git commit -a -m "goodbye" &&
28 git tag goodbye &&
30 git checkout --detach &&
31 git checkout HEAD^ . &&
32 test_tick &&
33 git commit -m reverted-goodbye &&
34 git tag reverted-goodbye &&
35 git checkout goodbye &&
36 test_tick &&
37 GIT_AUTHOR_NAME="Another Author" \
38 GIT_AUTHOR_EMAIL="another.author@example.com" \
39 git commit --amend --no-edit -m amended-goodbye &&
40 test_tick &&
41 git tag amended-goodbye &&
43 git checkout -f skip-reference &&
44 echo moo > hello &&
45 git commit -a -m "we should skip this" &&
46 echo moo > cow &&
47 git add cow &&
48 git commit -m "this should not be skipped" &&
49 git branch pre-rebase skip-reference &&
50 git branch skip-merge skip-reference
53 test_expect_success 'rebase with git am -3 (default)' '
54 test_must_fail git rebase main
57 test_expect_success 'rebase --skip can not be used with other options' '
58 test_must_fail git rebase -v --skip &&
59 test_must_fail git rebase --skip -v
62 test_expect_success 'rebase --skip with am -3' '
63 git rebase --skip
66 test_expect_success 'rebase moves back to skip-reference' '
67 test refs/heads/skip-reference = $(git symbolic-ref HEAD) &&
68 git branch post-rebase &&
69 git reset --hard pre-rebase &&
70 test_must_fail git rebase main &&
71 echo "hello" > hello &&
72 git add hello &&
73 git rebase --continue &&
74 test refs/heads/skip-reference = $(git symbolic-ref HEAD) &&
75 git reset --hard post-rebase
78 test_expect_success 'checkout skip-merge' 'git checkout -f skip-merge'
80 test_expect_success 'rebase with --merge' '
81 test_must_fail git rebase --merge main
84 test_expect_success 'rebase --skip with --merge' '
85 git rebase --skip
88 test_expect_success 'merge and reference trees equal' '
89 test -z "$(git diff-tree skip-merge skip-reference)"
92 test_expect_success 'moved back to branch correctly' '
93 test refs/heads/skip-merge = $(git symbolic-ref HEAD)
96 test_debug 'gitk --all & sleep 1'
98 test_expect_success 'correct advice upon picking empty commit' '
99 test_when_finished "git rebase --abort" &&
100 test_must_fail git rebase -i --onto goodbye \
101 amended-goodbye^ amended-goodbye 2>err &&
102 test_i18ngrep "previous cherry-pick is now empty" err &&
103 test_i18ngrep "git rebase --skip" err &&
104 test_must_fail git commit &&
105 test_i18ngrep "git rebase --skip" err
108 test_expect_success 'correct authorship when committing empty pick' '
109 test_when_finished "git rebase --abort" &&
110 test_must_fail git rebase -i --onto goodbye \
111 amended-goodbye^ amended-goodbye &&
112 git commit --allow-empty &&
113 git log --pretty=format:"%an <%ae>%n%ad%B" -1 amended-goodbye >expect &&
114 git log --pretty=format:"%an <%ae>%n%ad%B" -1 HEAD >actual &&
115 test_cmp expect actual
118 test_expect_success 'correct advice upon rewording empty commit' '
119 test_when_finished "git rebase --abort" &&
121 set_fake_editor &&
122 test_must_fail env FAKE_LINES="reword 1" git rebase -i \
123 --onto goodbye amended-goodbye^ amended-goodbye 2>err
124 ) &&
125 test_i18ngrep "previous cherry-pick is now empty" err &&
126 test_i18ngrep "git rebase --skip" err &&
127 test_must_fail git commit &&
128 test_i18ngrep "git rebase --skip" err
131 test_expect_success 'correct advice upon editing empty commit' '
132 test_when_finished "git rebase --abort" &&
134 set_fake_editor &&
135 test_must_fail env FAKE_LINES="edit 1" git rebase -i \
136 --onto goodbye amended-goodbye^ amended-goodbye 2>err
137 ) &&
138 test_i18ngrep "previous cherry-pick is now empty" err &&
139 test_i18ngrep "git rebase --skip" err &&
140 test_must_fail git commit &&
141 test_i18ngrep "git rebase --skip" err
144 test_expect_success 'correct advice upon cherry-picking an empty commit during a rebase' '
145 test_when_finished "git rebase --abort" &&
147 set_fake_editor &&
148 test_must_fail env FAKE_LINES="1 exec_git_cherry-pick_amended-goodbye" \
149 git rebase -i goodbye^ goodbye 2>err
150 ) &&
151 test_i18ngrep "previous cherry-pick is now empty" err &&
152 test_i18ngrep "git cherry-pick --skip" err &&
153 test_must_fail git commit 2>err &&
154 test_i18ngrep "git cherry-pick --skip" err
157 test_expect_success 'correct advice upon multi cherry-pick picking an empty commit during a rebase' '
158 test_when_finished "git rebase --abort" &&
160 set_fake_editor &&
161 test_must_fail env FAKE_LINES="1 exec_git_cherry-pick_goodbye_amended-goodbye" \
162 git rebase -i goodbye^^ goodbye 2>err
163 ) &&
164 test_i18ngrep "previous cherry-pick is now empty" err &&
165 test_i18ngrep "git cherry-pick --skip" err &&
166 test_must_fail git commit 2>err &&
167 test_i18ngrep "git cherry-pick --skip" err
170 test_expect_success 'fixup that empties commit fails' '
171 test_when_finished "git rebase --abort" &&
173 set_fake_editor &&
174 test_must_fail env FAKE_LINES="1 fixup 2" git rebase -i \
175 goodbye^ reverted-goodbye
179 test_expect_success 'squash that empties commit fails' '
180 test_when_finished "git rebase --abort" &&
182 set_fake_editor &&
183 test_must_fail env FAKE_LINES="1 squash 2" git rebase -i \
184 goodbye^ reverted-goodbye
188 # Must be the last test in this file
189 test_expect_success '$EDITOR and friends are unchanged' '
190 test_editor_unchanged
193 test_done