3 # Copyright (c) 2013 Ramkumar Ramachandra
6 test_description
='git rebase --autostash tests'
9 test_expect_success setup
'
10 echo hello-world >file0 &&
13 git commit -m "initial commit" &&
14 git checkout -b feature-branch &&
15 echo another-hello >file1 &&
16 echo goodbye >file2 &&
19 git commit -m "second commit" &&
20 echo final-goodbye >file3 &&
23 git commit -m "third commit" &&
24 git checkout -b unrelated-onto-branch master &&
25 echo unrelated >file4 &&
28 git commit -m "unrelated commit" &&
29 git checkout -b related-onto-branch master &&
30 echo conflicting-change >file2 &&
33 git commit -m "related commit"
40 test_expect_success
"rebase$type: dirty worktree, non-conflicting rebase" '
41 test_config rebase.autostash true &&
43 git checkout -b rebased-feature-branch feature-branch &&
44 test_when_finished git branch -D rebased-feature-branch &&
46 git rebase$type unrelated-onto-branch &&
47 grep unrelated file4 &&
49 git checkout feature-branch
52 test_expect_success
"rebase$type: dirty index, non-conflicting rebase" '
53 test_config rebase.autostash true &&
55 git checkout -b rebased-feature-branch feature-branch &&
56 test_when_finished git branch -D rebased-feature-branch &&
59 git rebase$type unrelated-onto-branch &&
60 grep unrelated file4 &&
62 git checkout feature-branch
65 test_expect_success
"rebase$type: conflicting rebase" '
66 test_config rebase.autostash true &&
68 git checkout -b rebased-feature-branch feature-branch &&
69 test_when_finished git branch -D rebased-feature-branch &&
71 test_must_fail git rebase$type related-onto-branch &&
72 test_path_is_file $dotest/autostash &&
76 git checkout feature-branch
79 test_expect_success
"rebase$type: --continue" '
80 test_config rebase.autostash true &&
82 git checkout -b rebased-feature-branch feature-branch &&
83 test_when_finished git branch -D rebased-feature-branch &&
85 test_must_fail git rebase$type related-onto-branch &&
86 test_path_is_file $dotest/autostash &&
88 echo "conflicting-plus-goodbye" >file2 &&
90 git rebase --continue &&
91 test_path_is_missing $dotest/autostash &&
93 git checkout feature-branch
96 test_expect_success
"rebase$type: --skip" '
97 test_config rebase.autostash true &&
99 git checkout -b rebased-feature-branch feature-branch &&
100 test_when_finished git branch -D rebased-feature-branch &&
101 echo dirty >>file3 &&
102 test_must_fail git rebase$type related-onto-branch &&
103 test_path_is_file $dotest/autostash &&
104 ! grep dirty file3 &&
106 test_path_is_missing $dotest/autostash &&
108 git checkout feature-branch
111 test_expect_success
"rebase$type: --abort" '
112 test_config rebase.autostash true &&
114 git checkout -b rebased-feature-branch feature-branch &&
115 test_when_finished git branch -D rebased-feature-branch &&
116 echo dirty >>file3 &&
117 test_must_fail git rebase$type related-onto-branch &&
118 test_path_is_file $dotest/autostash &&
119 ! grep dirty file3 &&
120 git rebase --abort &&
121 test_path_is_missing $dotest/autostash &&
123 git checkout feature-branch
126 test_expect_success
"rebase$type: non-conflicting rebase, conflicting stash" '
127 test_config rebase.autostash true &&
129 git checkout -b rebased-feature-branch feature-branch &&
130 test_when_finished git branch -D rebased-feature-branch &&
133 git rebase$type unrelated-onto-branch &&
134 test_path_is_missing $dotest &&
136 grep unrelated file4 &&
137 ! grep dirty file4 &&
138 git checkout feature-branch &&
144 test_expect_success
"rebase: fast-forward rebase" '
145 test_config rebase.autostash true &&
147 git checkout -b behind-feature-branch feature-branch~1 &&
148 test_when_finished git branch -D behind-feature-branch &&
149 echo dirty >>file1 &&
150 git rebase feature-branch &&
152 git checkout feature-branch
155 test_expect_success
"rebase: noop rebase" '
156 test_config rebase.autostash true &&
158 git checkout -b same-feature-branch feature-branch &&
159 test_when_finished git branch -D same-feature-branch &&
160 echo dirty >>file1 &&
161 git rebase feature-branch &&
163 git checkout feature-branch
166 testrebase
"" .git
/rebase-apply
167 testrebase
" --merge" .git
/rebase-merge
168 testrebase
" --interactive" .git
/rebase-merge