connected: always use partial clone optimization
[git] / t / t3403-rebase-skip.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2006 Eric Wong
4 #
5
6 test_description='git rebase --merge --skip tests'
7
8 . ./test-lib.sh
9
10 . "$TEST_DIRECTORY"/lib-rebase.sh
11
12 # we assume the default git am -3 --skip strategy is tested independently
13 # and always works :)
14
15 test_expect_success setup '
16         echo hello > hello &&
17         git add hello &&
18         git commit -m "hello" &&
19         git branch skip-reference &&
20
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 &&
26
27         git checkout --detach &&
28         git checkout HEAD^ . &&
29         test_tick &&
30         git commit -m reverted-goodbye &&
31         git tag reverted-goodbye &&
32
33         git checkout -f skip-reference &&
34         echo moo > hello &&
35         git commit -a -m "we should skip this" &&
36         echo moo > cow &&
37         git add cow &&
38         git commit -m "this should not be skipped" &&
39         git branch pre-rebase skip-reference &&
40         git branch skip-merge skip-reference
41         '
42
43 test_expect_success 'rebase with git am -3 (default)' '
44         test_must_fail git rebase master
45 '
46
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
50 '
51
52 test_expect_success 'rebase --skip with am -3' '
53         git rebase --skip
54         '
55
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 &&
62         git add hello &&
63         git rebase --continue &&
64         test refs/heads/skip-reference = $(git symbolic-ref HEAD) &&
65         git reset --hard post-rebase
66 '
67
68 test_expect_success 'checkout skip-merge' 'git checkout -f skip-merge'
69
70 test_expect_success 'rebase with --merge' '
71         test_must_fail git rebase --merge master
72 '
73
74 test_expect_success 'rebase --skip with --merge' '
75         git rebase --skip
76 '
77
78 test_expect_success 'merge and reference trees equal' '
79         test -z "$(git diff-tree skip-merge skip-reference)"
80 '
81
82 test_expect_success 'moved back to branch correctly' '
83         test refs/heads/skip-merge = $(git symbolic-ref HEAD)
84 '
85
86 test_debug 'gitk --all & sleep 1'
87
88 test_expect_success 'fixup that empties commit fails' '
89         test_when_finished "git rebase --abort" &&
90         (
91                 set_fake_editor &&
92                 test_must_fail env FAKE_LINES="1 fixup 2" git rebase -i \
93                         goodbye^ reverted-goodbye
94         )
95 '
96
97 test_expect_success 'squash that empties commit fails' '
98         test_when_finished "git rebase --abort" &&
99         (
100                 set_fake_editor &&
101                 test_must_fail env FAKE_LINES="1 squash 2" git rebase -i \
102                         goodbye^ reverted-goodbye
103         )
104 '
105
106 # Must be the last test in this file
107 test_expect_success '$EDITOR and friends are unchanged' '
108         test_editor_unchanged
109 '
110
111 test_done