Skip to content

Commit b1259ec

Browse files
hanwengitster
authored andcommitted
t1401-symbolic-ref: avoid direct filesystem access
Use symbolic-ref and rev-parse to inspect refs. Signed-off-by: Han-Wen Nienhuys <[email protected]> Reviewed-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9910cbb commit b1259ec

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

t/t1401-symbolic-ref.sh

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,23 @@ test_expect_success 'setup' '
1717
"$TAR" cf .git.tar .git/
1818
'
1919

20-
test_expect_success 'symbolic-ref writes HEAD' '
21-
git symbolic-ref HEAD refs/heads/foo &&
22-
echo ref: refs/heads/foo >expect &&
23-
test_cmp expect .git/HEAD
24-
'
25-
26-
test_expect_success 'symbolic-ref reads HEAD' '
27-
echo refs/heads/foo >expect &&
20+
test_expect_success 'symbolic-ref read/write roundtrip' '
21+
git symbolic-ref HEAD refs/heads/read-write-roundtrip &&
22+
echo refs/heads/read-write-roundtrip >expect &&
2823
git symbolic-ref HEAD >actual &&
2924
test_cmp expect actual
3025
'
3126

3227
test_expect_success 'symbolic-ref refuses non-ref for HEAD' '
3328
test_must_fail git symbolic-ref HEAD foo
3429
'
30+
3531
reset_to_sane
3632

3733
test_expect_success 'symbolic-ref refuses bare sha1' '
38-
echo content >file && git add file && git commit -m one &&
3934
test_must_fail git symbolic-ref HEAD $(git rev-parse HEAD)
4035
'
36+
4137
reset_to_sane
4238

4339
test_expect_success 'HEAD cannot be removed' '
@@ -49,16 +45,16 @@ reset_to_sane
4945
test_expect_success 'symbolic-ref can be deleted' '
5046
git symbolic-ref NOTHEAD refs/heads/foo &&
5147
git symbolic-ref -d NOTHEAD &&
52-
test_path_is_file .git/refs/heads/foo &&
53-
test_path_is_missing .git/NOTHEAD
48+
git rev-parse refs/heads/foo &&
49+
test_must_fail git symbolic-ref NOTHEAD
5450
'
5551
reset_to_sane
5652

5753
test_expect_success 'symbolic-ref can delete dangling symref' '
5854
git symbolic-ref NOTHEAD refs/heads/missing &&
5955
git symbolic-ref -d NOTHEAD &&
60-
test_path_is_missing .git/refs/heads/missing &&
61-
test_path_is_missing .git/NOTHEAD
56+
test_must_fail git rev-parse refs/heads/missing &&
57+
test_must_fail git symbolic-ref NOTHEAD
6258
'
6359
reset_to_sane
6460

0 commit comments

Comments
 (0)