]>
Commit | Line | Data |
---|---|---|
afe5d3d5 JK |
1 | #!/bin/sh |
2 | ||
3 | test_description='basic symbolic-ref tests' | |
4 | . ./test-lib.sh | |
5 | ||
6 | # If the tests munging HEAD fail, they can break detection of | |
7 | # the git repo, meaning that further tests will operate on | |
8 | # the surrounding git repo instead of the trash directory. | |
9 | reset_to_sane() { | |
10 | echo ref: refs/heads/foo >.git/HEAD | |
11 | } | |
12 | ||
13 | test_expect_success 'symbolic-ref writes HEAD' ' | |
14 | git symbolic-ref HEAD refs/heads/foo && | |
15 | echo ref: refs/heads/foo >expect && | |
16 | test_cmp expect .git/HEAD | |
17 | ' | |
18 | ||
19 | test_expect_success 'symbolic-ref reads HEAD' ' | |
20 | echo refs/heads/foo >expect && | |
21 | git symbolic-ref HEAD >actual && | |
22 | test_cmp expect actual | |
23 | ' | |
24 | ||
25 | test_expect_success 'symbolic-ref refuses non-ref for HEAD' ' | |
26 | test_must_fail git symbolic-ref HEAD foo | |
27 | ' | |
28 | reset_to_sane | |
29 | ||
afe5d3d5 | 30 | test_expect_success 'symbolic-ref refuses bare sha1' ' |
a48fcd83 | 31 | echo content >file && git add file && git commit -m one && |
afe5d3d5 JK |
32 | test_must_fail git symbolic-ref HEAD `git rev-parse HEAD` |
33 | ' | |
34 | reset_to_sane | |
35 | ||
36 | test_done |