interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t2011-checkout-invalid-head.sh

61 lines · 1423 bytes Raw Blame History
1#!/bin/sh
2
3test_description='checkout switching away from an invalid branch'
4
5GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
8. ./test-lib.sh
9
10test_expect_success 'setup' '
11 echo hello >world &&
12 git add world &&
13 git commit -m initial
14'
15
16test_expect_success 'checkout should not start branch from a tree' '
17 test_must_fail git checkout -b newbranch main^{tree}
18'
19
20test_expect_success REFFILES 'checkout main from invalid HEAD' '
21 echo $ZERO_OID >.git/HEAD &&
22 git checkout main --
23'
24
25test_expect_success REFFILES 'checkout notices failure to lock HEAD' '
26 test_when_finished "rm -f .git/HEAD.lock" &&
27 >.git/HEAD.lock &&
28 test_must_fail git checkout -b other
29'
30
31test_expect_success 'create ref directory/file conflict scenario' '
32 git update-ref refs/heads/outer/inner main &&
33 reset_to_df () {
34 git symbolic-ref HEAD refs/heads/outer
35 }
36'
37
38test_expect_success 'checkout away from d/f HEAD (unpacked, to branch)' '
39 reset_to_df &&
40 git checkout main
41'
42
43test_expect_success 'checkout away from d/f HEAD (unpacked, to detached)' '
44 reset_to_df &&
45 git checkout --detach main
46'
47
48test_expect_success 'pack refs' '
49 git pack-refs --all --prune
50'
51
52test_expect_success 'checkout away from d/f HEAD (packed, to branch)' '
53 reset_to_df &&
54 git checkout main
55'
56
57test_expect_success 'checkout away from d/f HEAD (packed, to detached)' '
58 reset_to_df &&
59 git checkout --detach main
60'
61test_done