@@ -619,6 +619,52 @@ test_expect_success 'stdin update/create/verify combination works' '
619619 test_must_fail git rev-parse --verify -q $c
620620'
621621
622+ test_expect_success ' stdin verify succeeds for correct value' '
623+ git rev-parse $m >expect &&
624+ echo "verify $m $m" >stdin &&
625+ git update-ref --stdin <stdin &&
626+ git rev-parse $m >actual &&
627+ test_cmp expect actual
628+ '
629+
630+ test_expect_success ' stdin verify succeeds for missing reference' '
631+ echo "verify refs/heads/missing $Z" >stdin &&
632+ git update-ref --stdin <stdin &&
633+ test_must_fail git rev-parse --verify -q refs/heads/missing
634+ '
635+
636+ test_expect_success ' stdin verify treats no value as missing' '
637+ echo "verify refs/heads/missing" >stdin &&
638+ git update-ref --stdin <stdin &&
639+ test_must_fail git rev-parse --verify -q refs/heads/missing
640+ '
641+
642+ test_expect_success ' stdin verify fails for wrong value' '
643+ git rev-parse $m >expect &&
644+ echo "verify $m $m~1" >stdin &&
645+ test_must_fail git update-ref --stdin <stdin &&
646+ git rev-parse $m >actual &&
647+ test_cmp expect actual
648+ '
649+
650+ test_expect_success ' stdin verify fails for mistaken null value' '
651+ git rev-parse $m >expect &&
652+ echo "verify $m $Z" >stdin &&
653+ test_must_fail git update-ref --stdin <stdin &&
654+ git rev-parse $m >actual &&
655+ test_cmp expect actual
656+ '
657+
658+ test_expect_success ' stdin verify fails for mistaken empty value' '
659+ M=$(git rev-parse $m) &&
660+ test_when_finished "git update-ref $m $M" &&
661+ git rev-parse $m >expect &&
662+ echo "verify $m" >stdin &&
663+ test_must_fail git update-ref --stdin <stdin &&
664+ git rev-parse $m >actual &&
665+ test_cmp expect actual
666+ '
667+
622668test_expect_success ' stdin update refs works with identity updates' '
623669 cat >stdin <<-EOF &&
624670 update $a $m $m
@@ -938,6 +984,52 @@ test_expect_success 'stdin -z update/create/verify combination works' '
938984 test_must_fail git rev-parse --verify -q $c
939985'
940986
987+ test_expect_success ' stdin -z verify succeeds for correct value' '
988+ git rev-parse $m >expect &&
989+ printf $F "verify $m" "$m" >stdin &&
990+ git update-ref -z --stdin <stdin &&
991+ git rev-parse $m >actual &&
992+ test_cmp expect actual
993+ '
994+
995+ test_expect_success ' stdin -z verify succeeds for missing reference' '
996+ printf $F "verify refs/heads/missing" "$Z" >stdin &&
997+ git update-ref -z --stdin <stdin &&
998+ test_must_fail git rev-parse --verify -q refs/heads/missing
999+ '
1000+
1001+ test_expect_success ' stdin -z verify treats no value as missing' '
1002+ printf $F "verify refs/heads/missing" "" >stdin &&
1003+ git update-ref -z --stdin <stdin &&
1004+ test_must_fail git rev-parse --verify -q refs/heads/missing
1005+ '
1006+
1007+ test_expect_success ' stdin -z verify fails for wrong value' '
1008+ git rev-parse $m >expect &&
1009+ printf $F "verify $m" "$m~1" >stdin &&
1010+ test_must_fail git update-ref -z --stdin <stdin &&
1011+ git rev-parse $m >actual &&
1012+ test_cmp expect actual
1013+ '
1014+
1015+ test_expect_success ' stdin -z verify fails for mistaken null value' '
1016+ git rev-parse $m >expect &&
1017+ printf $F "verify $m" "$Z" >stdin &&
1018+ test_must_fail git update-ref -z --stdin <stdin &&
1019+ git rev-parse $m >actual &&
1020+ test_cmp expect actual
1021+ '
1022+
1023+ test_expect_success ' stdin -z verify fails for mistaken empty value' '
1024+ M=$(git rev-parse $m) &&
1025+ test_when_finished "git update-ref $m $M" &&
1026+ git rev-parse $m >expect &&
1027+ printf $F "verify $m" "" >stdin &&
1028+ test_must_fail git update-ref -z --stdin <stdin &&
1029+ git rev-parse $m >actual &&
1030+ test_cmp expect actual
1031+ '
1032+
9411033test_expect_success ' stdin -z update refs works with identity updates' '
9421034 printf $F "update $a" "$m" "$m" "update $b" "$m" "$m" "update $c" "$Z" "" >stdin &&
9431035 git update-ref -z --stdin <stdin &&
0 commit comments