summaryrefslogtreecommitdiff
path: root/t/t1403-show-ref.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t1403-show-ref.sh')
-rwxr-xr-xt/t1403-show-ref.sh78
1 files changed, 54 insertions, 24 deletions
diff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh
index 7e10bcf..5d955c3 100755
--- a/t/t1403-show-ref.sh
+++ b/t/t1403-show-ref.sh
@@ -26,26 +26,22 @@ test_expect_success 'show-ref' '
git show-ref refs/tags/A >actual &&
test_cmp expect actual &&
- >expect &&
-
test_must_fail git show-ref D >actual &&
- test_cmp expect actual
+ test_must_be_empty actual
'
test_expect_success 'show-ref -q' '
- >expect &&
-
git show-ref -q A >actual &&
- test_cmp expect actual &&
+ test_must_be_empty actual &&
git show-ref -q tags/A >actual &&
- test_cmp expect actual &&
+ test_must_be_empty actual &&
git show-ref -q refs/tags/A >actual &&
- test_cmp expect actual &&
+ test_must_be_empty actual &&
test_must_fail git show-ref -q D >actual &&
- test_cmp expect actual
+ test_must_be_empty actual
'
test_expect_success 'show-ref --verify' '
@@ -54,32 +50,28 @@ test_expect_success 'show-ref --verify' '
git show-ref --verify refs/tags/A >actual &&
test_cmp expect actual &&
- >expect &&
-
test_must_fail git show-ref --verify A >actual &&
- test_cmp expect actual &&
+ test_must_be_empty actual &&
test_must_fail git show-ref --verify tags/A >actual &&
- test_cmp expect actual &&
+ test_must_be_empty actual &&
test_must_fail git show-ref --verify D >actual &&
- test_cmp expect actual
+ test_must_be_empty actual
'
test_expect_success 'show-ref --verify -q' '
- >expect &&
-
git show-ref --verify -q refs/tags/A >actual &&
- test_cmp expect actual &&
+ test_must_be_empty actual &&
test_must_fail git show-ref --verify -q A >actual &&
- test_cmp expect actual &&
+ test_must_be_empty actual &&
test_must_fail git show-ref --verify -q tags/A >actual &&
- test_cmp expect actual &&
+ test_must_be_empty actual &&
test_must_fail git show-ref --verify -q D >actual &&
- test_cmp expect actual
+ test_must_be_empty actual
'
test_expect_success 'show-ref -d' '
@@ -97,6 +89,9 @@ test_expect_success 'show-ref -d' '
git show-ref -d refs/tags/A refs/tags/C >actual &&
test_cmp expect actual &&
+ git show-ref --verify -d refs/tags/A refs/tags/C >actual &&
+ test_cmp expect actual &&
+
echo $(git rev-parse refs/heads/master) refs/heads/master >expect &&
git show-ref -d master >actual &&
test_cmp expect actual &&
@@ -110,13 +105,17 @@ test_expect_success 'show-ref -d' '
git show-ref -d --verify refs/heads/master >actual &&
test_cmp expect actual &&
- >expect &&
-
test_must_fail git show-ref -d --verify master >actual &&
- test_cmp expect actual &&
+ test_must_be_empty actual &&
test_must_fail git show-ref -d --verify heads/master >actual &&
- test_cmp expect actual
+ test_must_be_empty actual &&
+
+ test_must_fail git show-ref --verify -d A C >actual &&
+ test_must_be_empty actual &&
+
+ test_must_fail git show-ref --verify -d tags/A tags/C >actual &&
+ test_must_be_empty actual
'
@@ -164,4 +163,35 @@ test_expect_success 'show-ref --heads, --tags, --head, pattern' '
test_cmp expect actual
'
+test_expect_success 'show-ref --verify HEAD' '
+ echo $(git rev-parse HEAD) HEAD >expect &&
+ git show-ref --verify HEAD >actual &&
+ test_cmp expect actual &&
+
+ git show-ref --verify -q HEAD >actual &&
+ test_must_be_empty actual
+'
+
+test_expect_success 'show-ref --verify with dangling ref' '
+ sha1_file() {
+ echo "$*" | sed "s#..#.git/objects/&/#"
+ } &&
+
+ remove_object() {
+ file=$(sha1_file "$*") &&
+ test -e "$file" &&
+ rm -f "$file"
+ } &&
+
+ test_when_finished "rm -rf dangling" &&
+ (
+ git init dangling &&
+ cd dangling &&
+ test_commit dangling &&
+ sha=$(git rev-parse refs/tags/dangling) &&
+ remove_object $sha &&
+ test_must_fail git show-ref --verify refs/tags/dangling
+ )
+'
+
test_done