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"
39 git fetch -u origin "refs/heads/*:refs/heads/*" &&
40 test_config rebase.autostash true &&
41 git checkout -b rebased-feature-branch feature-branch
48 test_expect_success "rebase$type: dirty worktree, non-conflicting rebase" '
49 test_when_finished "rm -rf tmp" &&
53 git rebase$type unrelated-onto-branch &&
54 grep unrelated file4 &&
59 test_expect_success "rebase$type: dirty index, non-conflicting rebase" '
60 test_when_finished "rm -rf tmp" &&
65 git rebase$type unrelated-onto-branch &&
66 grep unrelated file4 &&
71 test_expect_success "rebase$type: conflicting rebase" '
72 test_when_finished "rm -rf tmp" &&
76 test_must_fail git rebase$type related-onto-branch &&
77 test_path_is_file $dotest/autostash &&
82 test_expect_success "rebase$type: --continue" '
83 test_when_finished "rm -rf tmp" &&
87 test_must_fail git rebase$type related-onto-branch &&
88 test_path_is_file $dotest/autostash &&
90 echo "conflicting-plus-goodbye" >file2 &&
92 git rebase --continue &&
93 test_path_is_missing $dotest/autostash &&
98 test_expect_success "rebase$type: --skip" '
99 test_when_finished "rm -rf tmp" &&
103 echo dirty >>file3 &&
104 test_must_fail git rebase$type related-onto-branch &&
105 test_path_is_file $dotest/autostash &&
106 ! grep dirty file3 &&
108 test_path_is_missing $dotest/autostash &&
113 test_expect_success "rebase$type: --abort" '
114 test_when_finished "rm -rf tmp" &&
117 echo dirty >>file3 &&
118 test_must_fail git rebase$type related-onto-branch &&
119 test_path_is_file $dotest/autostash &&
120 ! grep dirty file3 &&
121 git rebase --abort &&
122 test_path_is_missing $dotest/autostash &&
127 test_expect_success "rebase$type: non-conflicting rebase, conflicting stash" '
128 test_when_finished "rm -rf tmp" &&
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 &&
145 test_expect_success "rebase: fast-forward rebase" '
146 test_when_finished "rm -rf tmp" &&
149 echo dirty >>file1 &&
150 git rebase feature-branch &&
155 test_expect_success "rebase: noop rebase" '
156 test_when_finished "rm -rf tmp" &&
159 echo dirty >>file1 &&
160 git rebase feature-branch &&
165 testrebase "" .git/rebase-merge
166 testrebase " --merge" .git/rebase-merge
167 testrebase " --interactive" .git/rebase-merge