|
3 | 3 | # Copyright (c) 2006 Junio C Hamano
|
4 | 4 | #
|
5 | 5 |
|
6 |
| -test_description='git-checkout tests.' |
| 6 | +test_description='git-checkout tests. |
| 7 | +
|
| 8 | +Creates master, forks renamer and side branches from it. |
| 9 | +Test switching across them. |
| 10 | +
|
| 11 | + ! [master] Initial A one, A two |
| 12 | + * [renamer] Renamer R one->uno, M two |
| 13 | + ! [side] Side M one, D two, A three |
| 14 | + --- |
| 15 | + + [side] Side M one, D two, A three |
| 16 | + * [renamer] Renamer R one->uno, M two |
| 17 | + +*+ [master] Initial A one, A two |
| 18 | +
|
| 19 | +' |
7 | 20 |
|
8 | 21 | . ./test-lib.sh
|
9 | 22 |
|
@@ -129,4 +142,52 @@ test_expect_success 'checkout -m with merge conflict' '
|
129 | 142 | ! test -s current
|
130 | 143 | '
|
131 | 144 |
|
| 145 | +test_expect_success 'checkout to detach HEAD' ' |
| 146 | +
|
| 147 | + git checkout -f renamer && git clean && |
| 148 | + git checkout renamer^ && |
| 149 | + H=$(git rev-parse --verify HEAD) && |
| 150 | + M=$(git show-ref -s --verify refs/heads/master) && |
| 151 | + test "z$H" = "z$M" && |
| 152 | + if git symbolic-ref HEAD >/dev/null 2>&1 |
| 153 | + then |
| 154 | + echo "OOPS, HEAD is still symbolic???" |
| 155 | + false |
| 156 | + else |
| 157 | + : happy |
| 158 | + fi |
| 159 | +' |
| 160 | + |
| 161 | +test_expect_success 'checkout to detach HEAD with branchname^' ' |
| 162 | +
|
| 163 | + git checkout -f master && git clean && |
| 164 | + git checkout renamer^ && |
| 165 | + H=$(git rev-parse --verify HEAD) && |
| 166 | + M=$(git show-ref -s --verify refs/heads/master) && |
| 167 | + test "z$H" = "z$M" && |
| 168 | + if git symbolic-ref HEAD >/dev/null 2>&1 |
| 169 | + then |
| 170 | + echo "OOPS, HEAD is still symbolic???" |
| 171 | + false |
| 172 | + else |
| 173 | + : happy |
| 174 | + fi |
| 175 | +' |
| 176 | + |
| 177 | +test_expect_success 'checkout to detach HEAD with HEAD^0' ' |
| 178 | +
|
| 179 | + git checkout -f master && git clean && |
| 180 | + git checkout HEAD^0 && |
| 181 | + H=$(git rev-parse --verify HEAD) && |
| 182 | + M=$(git show-ref -s --verify refs/heads/master) && |
| 183 | + test "z$H" = "z$M" && |
| 184 | + if git symbolic-ref HEAD >/dev/null 2>&1 |
| 185 | + then |
| 186 | + echo "OOPS, HEAD is still symbolic???" |
| 187 | + false |
| 188 | + else |
| 189 | + : happy |
| 190 | + fi |
| 191 | +' |
| 192 | + |
132 | 193 | test_done
|
0 commit comments