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 &&
33 git checkout -f skip-reference &&
35 git commit -a -m "we should skip this" &&
38 git commit -m "this should not be skipped" &&
39 git branch pre-rebase skip-reference &&
40 git branch skip-merge skip-reference
43 test_expect_success 'rebase with git am -3 (default)' '
44 test_must_fail git rebase master
47 test_expect_success 'rebase --skip can not be used with other options' '
48 test_must_fail git rebase -v --skip &&
49 test_must_fail git rebase --skip -v
52 test_expect_success 'rebase --skip with am -3' '
56 test_expect_success 'rebase moves back to skip-reference' '
57 test refs/heads/skip-reference = $(git symbolic-ref HEAD) &&
58 git branch post-rebase &&
59 git reset --hard pre-rebase &&
60 test_must_fail git rebase master &&
61 echo "hello" > hello &&
63 git rebase --continue &&
64 test refs/heads/skip-reference = $(git symbolic-ref HEAD) &&
65 git reset --hard post-rebase
68 test_expect_success 'checkout skip-merge' 'git checkout -f skip-merge'
70 test_expect_success 'rebase with --merge' '
71 test_must_fail git rebase --merge master
74 test_expect_success 'rebase --skip with --merge' '
78 test_expect_success 'merge and reference trees equal' '
79 test -z "$(git diff-tree skip-merge skip-reference)"
82 test_expect_success 'moved back to branch correctly' '
83 test refs/heads/skip-merge = $(git symbolic-ref HEAD)
86 test_debug 'gitk --all & sleep 1'
88 test_expect_success 'fixup that empties commit fails' '
89 test_when_finished "git rebase --abort" &&
92 test_must_fail env FAKE_LINES="1 fixup 2" git rebase -i \
93 goodbye^ reverted-goodbye
97 test_expect_success 'squash that empties commit fails' '
98 test_when_finished "git rebase --abort" &&
101 test_must_fail env FAKE_LINES="1 squash 2" git rebase -i \
102 goodbye^ reverted-goodbye
106 # Must be the last test in this file
107 test_expect_success '$EDITOR and friends are unchanged' '
108 test_editor_unchanged