mingw: avoid fallback for {local,gm}time_r()
[git/debian.git] / t / t3403-rebase-skip.sh
bloba927774910bc058a9d661e59b1670f4fd043fc5f
1 #!/bin/sh
3 # Copyright (c) 2006 Eric Wong
6 test_description='git rebase --merge --skip tests'
8 . ./test-lib.sh
10 . "$TEST_DIRECTORY"/lib-rebase.sh
12 # we assume the default git am -3 --skip strategy is tested independently
13 # and always works :)
15 test_expect_success setup '
16 echo hello > hello &&
17 git add hello &&
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" &&
25 git tag goodbye &&
27 git checkout --detach &&
28 git checkout HEAD^ . &&
29 test_tick &&
30 git commit -m reverted-goodbye &&
31 git tag reverted-goodbye &&
32 git checkout goodbye &&
33 test_tick &&
34 GIT_AUTHOR_NAME="Another Author" \
35 GIT_AUTHOR_EMAIL="another.author@example.com" \
36 git commit --amend --no-edit -m amended-goodbye &&
37 test_tick &&
38 git tag amended-goodbye &&
40 git checkout -f skip-reference &&
41 echo moo > hello &&
42 git commit -a -m "we should skip this" &&
43 echo moo > cow &&
44 git add cow &&
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' '
60 git rebase --skip
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 &&
69 git add 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' '
82 git rebase --skip
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" &&
118 set_fake_editor &&
119 test_must_fail env FAKE_LINES="reword 1" git rebase -i \
120 --onto goodbye amended-goodbye^ amended-goodbye 2>err
121 ) &&
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" &&
131 set_fake_editor &&
132 test_must_fail env FAKE_LINES="edit 1" git rebase -i \
133 --onto goodbye amended-goodbye^ amended-goodbye 2>err
134 ) &&
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" &&
144 set_fake_editor &&
145 test_must_fail env FAKE_LINES="1 exec_git_cherry-pick_amended-goodbye" \
146 git rebase -i goodbye^ goodbye 2>err
147 ) &&
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" &&
157 set_fake_editor &&
158 test_must_fail env FAKE_LINES="1 exec_git_cherry-pick_goodbye_amended-goodbye" \
159 git rebase -i goodbye^^ goodbye 2>err
160 ) &&
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" &&
170 set_fake_editor &&
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" &&
179 set_fake_editor &&
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
190 test_done