3 # Copyright (c) 2006 Eric Wong
6 test_description
='git rebase --merge --skip tests'
10 .
"$TEST_DIRECTORY"/lib-rebase.sh
12 # we assume the default git am -3 --skip strategy is tested independently
15 test_expect_success setup
'
18 git commit -m "hello" &&
19 git branch skip-reference &&
21 echo world >> hello &&
22 git commit -a -m "hello world" &&
23 echo goodbye >> hello &&
24 git commit -a -m "goodbye" &&
27 git checkout --detach &&
28 git checkout HEAD^ . &&
30 git commit -m reverted-goodbye &&
31 git tag reverted-goodbye &&
32 git checkout goodbye &&
34 GIT_AUTHOR_NAME="Another Author" \
35 GIT_AUTHOR_EMAIL="another.author@example.com" \
36 git commit --amend --no-edit -m amended-goodbye &&
38 git tag amended-goodbye &&
40 git checkout -f skip-reference &&
42 git commit -a -m "we should skip this" &&
45 git commit -m "this should not be skipped" &&
46 git branch pre-rebase skip-reference &&
47 git branch skip-merge skip-reference
50 test_expect_success
'rebase with git am -3 (default)' '
51 test_must_fail git rebase master
54 test_expect_success
'rebase --skip can not be used with other options' '
55 test_must_fail git rebase -v --skip &&
56 test_must_fail git rebase --skip -v
59 test_expect_success
'rebase --skip with am -3' '
63 test_expect_success
'rebase moves back to skip-reference' '
64 test refs/heads/skip-reference = $(git symbolic-ref HEAD) &&
65 git branch post-rebase &&
66 git reset --hard pre-rebase &&
67 test_must_fail git rebase master &&
68 echo "hello" > hello &&
70 git rebase --continue &&
71 test refs/heads/skip-reference = $(git symbolic-ref HEAD) &&
72 git reset --hard post-rebase
75 test_expect_success
'checkout skip-merge' 'git checkout -f skip-merge'
77 test_expect_success
'rebase with --merge' '
78 test_must_fail git rebase --merge master
81 test_expect_success
'rebase --skip with --merge' '
85 test_expect_success
'merge and reference trees equal' '
86 test -z "$(git diff-tree skip-merge skip-reference)"
89 test_expect_success
'moved back to branch correctly' '
90 test refs/heads/skip-merge = $(git symbolic-ref HEAD)
93 test_debug
'gitk --all & sleep 1'
95 test_expect_success
'correct advice upon picking empty commit' '
96 test_when_finished "git rebase --abort" &&
97 test_must_fail git rebase -i --onto goodbye \
98 amended-goodbye^ amended-goodbye 2>err &&
99 test_i18ngrep "previous cherry-pick is now empty" err &&
100 test_i18ngrep "git rebase --skip" err &&
101 test_must_fail git commit &&
102 test_i18ngrep "git rebase --skip" err
105 test_expect_success
'correct authorship when committing empty pick' '
106 test_when_finished "git rebase --abort" &&
107 test_must_fail git rebase -i --onto goodbye \
108 amended-goodbye^ amended-goodbye &&
109 git commit --allow-empty &&
110 git log --pretty=format:"%an <%ae>%n%ad%B" -1 amended-goodbye >expect &&
111 git log --pretty=format:"%an <%ae>%n%ad%B" -1 HEAD >actual &&
112 test_cmp expect actual
115 test_expect_success
'correct advice upon rewording empty commit' '
116 test_when_finished "git rebase --abort" &&
119 test_must_fail env FAKE_LINES="reword 1" git rebase -i \
120 --onto goodbye amended-goodbye^ amended-goodbye 2>err
122 test_i18ngrep "previous cherry-pick is now empty" err &&
123 test_i18ngrep "git rebase --skip" err &&
124 test_must_fail git commit &&
125 test_i18ngrep "git rebase --skip" err
128 test_expect_success
'correct advice upon editing empty commit' '
129 test_when_finished "git rebase --abort" &&
132 test_must_fail env FAKE_LINES="edit 1" git rebase -i \
133 --onto goodbye amended-goodbye^ amended-goodbye 2>err
135 test_i18ngrep "previous cherry-pick is now empty" err &&
136 test_i18ngrep "git rebase --skip" err &&
137 test_must_fail git commit &&
138 test_i18ngrep "git rebase --skip" err
141 test_expect_success
'correct advice upon cherry-picking an empty commit during a rebase' '
142 test_when_finished "git rebase --abort" &&
145 test_must_fail env FAKE_LINES="1 exec_git_cherry-pick_amended-goodbye" \
146 git rebase -i goodbye^ goodbye 2>err
148 test_i18ngrep "previous cherry-pick is now empty" err &&
149 test_i18ngrep "git cherry-pick --skip" err &&
150 test_must_fail git commit 2>err &&
151 test_i18ngrep "git cherry-pick --skip" err
154 test_expect_success
'correct advice upon multi cherry-pick picking an empty commit during a rebase' '
155 test_when_finished "git rebase --abort" &&
158 test_must_fail env FAKE_LINES="1 exec_git_cherry-pick_goodbye_amended-goodbye" \
159 git rebase -i goodbye^^ goodbye 2>err
161 test_i18ngrep "previous cherry-pick is now empty" err &&
162 test_i18ngrep "git cherry-pick --skip" err &&
163 test_must_fail git commit 2>err &&
164 test_i18ngrep "git cherry-pick --skip" err
167 test_expect_success
'fixup that empties commit fails' '
168 test_when_finished "git rebase --abort" &&
171 test_must_fail env FAKE_LINES="1 fixup 2" git rebase -i \
172 goodbye^ reverted-goodbye
176 test_expect_success
'squash that empties commit fails' '
177 test_when_finished "git rebase --abort" &&
180 test_must_fail env FAKE_LINES="1 squash 2" git rebase -i \
181 goodbye^ reverted-goodbye
185 # Must be the last test in this file
186 test_expect_success
'$EDITOR and friends are unchanged' '
187 test_editor_unchanged