aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-01-31 13:14:59 -0800
committerJunio C Hamano <gitster@pobox.com>2017-01-31 13:14:59 -0800
commita49260b17d39434bbdf5d55991c90aa2f42ea64c (patch)
tree40d85972a11124346ed90413d36f06b46f9fd4db /t
parent0eade20cd93dfe09044cbe8b64dcc9945f113d42 (diff)
parent0d583ff02d1a6551863acf3bf87e6f19eef8c5ab (diff)
downloadgit-a49260b17d39434bbdf5d55991c90aa2f42ea64c.tar.gz
git-a49260b17d39434bbdf5d55991c90aa2f42ea64c.tar.xz
Merge branch 'vp/show-ref-verify-head'
"git show-ref HEAD" used with "--verify" because the user is not interested in seeing refs/remotes/origin/HEAD, and used with "--head" because the user does not want HEAD to be filtered out, i.e. "git show-ref --head --verify HEAD", did not work as expected. * vp/show-ref-verify-head: show-ref: remove a stale comment show-ref: remove dead `if (verify)' check show-ref: detect dangling refs under --verify as well show-ref: move --quiet handling into show_one() show-ref: allow -d to work with --verify show-ref: accept HEAD with --verify
Diffstat (limited to 't')
-rwxr-xr-xt/t1403-show-ref.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh
index 7e10bcfe3..30354fd26 100755
--- a/t/t1403-show-ref.sh
+++ b/t/t1403-show-ref.sh
@@ -97,6 +97,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 &&
@@ -116,6 +119,12 @@ test_expect_success 'show-ref -d' '
test_cmp expect actual &&
test_must_fail git show-ref -d --verify heads/master >actual &&
+ test_cmp expect actual &&
+
+ test_must_fail git show-ref --verify -d A C >actual &&
+ test_cmp expect actual &&
+
+ test_must_fail git show-ref --verify -d tags/A tags/C >actual &&
test_cmp expect actual
'
@@ -164,4 +173,37 @@ 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 &&
+
+ >expect &&
+
+ git show-ref --verify -q HEAD >actual &&
+ test_cmp expect 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