diff options
Diffstat (limited to 't/t1401-symbolic-ref.sh')
-rwxr-xr-x | t/t1401-symbolic-ref.sh | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/t/t1401-symbolic-ref.sh b/t/t1401-symbolic-ref.sh index a4ebb0b65f..132a1b885a 100755 --- a/t/t1401-symbolic-ref.sh +++ b/t/t1401-symbolic-ref.sh @@ -7,17 +7,19 @@ test_description='basic symbolic-ref tests' # the git repo, meaning that further tests will operate on # the surrounding git repo instead of the trash directory. reset_to_sane() { - echo ref: refs/heads/foo >.git/HEAD + rm -rf .git && + "$TAR" xf .git.tar } -test_expect_success 'symbolic-ref writes HEAD' ' +test_expect_success 'setup' ' git symbolic-ref HEAD refs/heads/foo && - echo ref: refs/heads/foo >expect && - test_cmp expect .git/HEAD + test_commit file && + "$TAR" cf .git.tar .git/ ' -test_expect_success 'symbolic-ref reads HEAD' ' - echo refs/heads/foo >expect && +test_expect_success 'symbolic-ref read/write roundtrip' ' + git symbolic-ref HEAD refs/heads/read-write-roundtrip && + echo refs/heads/read-write-roundtrip >expect && git symbolic-ref HEAD >actual && test_cmp expect actual ' @@ -25,12 +27,13 @@ test_expect_success 'symbolic-ref reads HEAD' ' test_expect_success 'symbolic-ref refuses non-ref for HEAD' ' test_must_fail git symbolic-ref HEAD foo ' + reset_to_sane test_expect_success 'symbolic-ref refuses bare sha1' ' - echo content >file && git add file && git commit -m one && test_must_fail git symbolic-ref HEAD $(git rev-parse HEAD) ' + reset_to_sane test_expect_success 'HEAD cannot be removed' ' @@ -42,16 +45,16 @@ reset_to_sane test_expect_success 'symbolic-ref can be deleted' ' git symbolic-ref NOTHEAD refs/heads/foo && git symbolic-ref -d NOTHEAD && - test_path_is_file .git/refs/heads/foo && - test_path_is_missing .git/NOTHEAD + git rev-parse refs/heads/foo && + test_must_fail git symbolic-ref NOTHEAD ' reset_to_sane test_expect_success 'symbolic-ref can delete dangling symref' ' git symbolic-ref NOTHEAD refs/heads/missing && git symbolic-ref -d NOTHEAD && - test_path_is_missing .git/refs/heads/missing && - test_path_is_missing .git/NOTHEAD + test_must_fail git rev-parse refs/heads/missing && + test_must_fail git symbolic-ref NOTHEAD ' reset_to_sane |