format_command $type "update refs/heads/ref1" "$old_head" "$head" >stdin &&
format_command $type "update refs/heads/ref2" "$(test_oid 001)" "$head" >>stdin &&
- git update-ref $type --stdin --batch-updates <stdin >stdout &&
+ git update-ref $type --stdin --batch-updates <stdin >stdout 2>err &&
echo $old_head >expect &&
git rev-parse refs/heads/ref1 >actual &&
test_cmp expect actual &&
echo $head >expect &&
git rev-parse refs/heads/ref2 >actual &&
test_cmp expect actual &&
- test_grep -q "invalid new value provided" stdout
+ test_grep "rejected refs/heads/ref2 $(test_oid 001) $head invalid new value provided" stdout &&
+ test_grep "trying to write ref ${SQ}refs/heads/ref2${SQ} with nonexistent object" err
)
'
format_command $type "update refs/heads/ref1" "$old_head" "$head" >stdin &&
format_command $type "update refs/heads/ref2" "$head_tree" "$head" >>stdin &&
- git update-ref $type --stdin --batch-updates <stdin >stdout &&
+ git update-ref $type --stdin --batch-updates <stdin >stdout 2>err &&
echo $old_head >expect &&
git rev-parse refs/heads/ref1 >actual &&
test_cmp expect actual &&
echo $head >expect &&
git rev-parse refs/heads/ref2 >actual &&
test_cmp expect actual &&
- test_grep -q "invalid new value provided" stdout
+ test_grep "rejected refs/heads/ref2 $head_tree $head invalid new value provided" stdout &&
+ test_grep "trying to write non-commit object $head_tree to branch ${SQ}refs/heads/ref2${SQ}" err
)
'
format_command $type "update refs/heads/ref1" "$old_head" "$head" >stdin &&
format_command $type "update refs/heads/ref2" "$old_head" "$head" >>stdin &&
- git update-ref $type --stdin --batch-updates <stdin >stdout &&
+ git update-ref $type --stdin --batch-updates <stdin >stdout 2>err &&
echo $old_head >expect &&
git rev-parse refs/heads/ref1 >actual &&
test_cmp expect actual &&
test_must_fail git rev-parse refs/heads/ref2 &&
- test_grep -q "reference does not exist" stdout
+ test_grep "rejected refs/heads/ref2 $old_head $head reference does not exist" stdout &&
+ test_grep "cannot lock ref ${SQ}refs/heads/ref2${SQ}: unable to resolve reference ${SQ}refs/heads/ref2${SQ}" err
)
'
format_command $type "update refs/heads/ref1" "$old_head" "$head" >stdin &&
format_command $type "update refs/heads/ref2" "$old_head" "$head" >>stdin &&
- git update-ref $type --no-deref --stdin --batch-updates <stdin >stdout &&
+ git update-ref $type --no-deref --stdin --batch-updates <stdin >stdout 2>err &&
echo $old_head >expect &&
git rev-parse refs/heads/ref1 >actual &&
test_cmp expect actual &&
echo $head >expect &&
test_must_fail git rev-parse refs/heads/ref2 &&
- test_grep -q "reference does not exist" stdout
+ test_grep "rejected refs/heads/ref2 $old_head $head reference does not exist" stdout &&
+ test_grep "cannot lock ref ${SQ}refs/heads/ref2${SQ}: reference is missing but expected $head" err
)
'
format_command $type "update refs/heads/ref1" "$old_head" "$head" >stdin &&
format_command $type "symref-update refs/heads/ref2" "$old_head" "ref" "refs/heads/nonexistent" >>stdin &&
- git update-ref $type --no-deref --stdin --batch-updates <stdin >stdout &&
+ git update-ref $type --no-deref --stdin --batch-updates <stdin >stdout 2>err &&
echo $old_head >expect &&
git rev-parse refs/heads/ref1 >actual &&
test_cmp expect actual &&
echo $head >expect &&
git rev-parse refs/heads/ref2 >actual &&
test_cmp expect actual &&
- test_grep -q "expected symref but found regular ref" stdout
+ test_grep "rejected refs/heads/ref2 $ZERO_OID $ZERO_OID expected symref but found regular ref" stdout &&
+ test_grep "cannot lock ref ${SQ}refs/heads/ref2${SQ}: expected symref with target ${SQ}refs/heads/nonexistent${SQ}: but is a regular ref" err
)
'
format_command $type "update refs/heads/ref1" "$old_head" "$head" >stdin &&
format_command $type "update refs/heads/ref2" "$old_head" "$Z" >>stdin &&
- git update-ref $type --stdin --batch-updates <stdin >stdout &&
+ git update-ref $type --stdin --batch-updates <stdin >stdout 2>err &&
echo $old_head >expect &&
git rev-parse refs/heads/ref1 >actual &&
test_cmp expect actual &&
echo $head >expect &&
git rev-parse refs/heads/ref2 >actual &&
test_cmp expect actual &&
- test_grep -q "reference already exists" stdout
+ test_grep "rejected refs/heads/ref2 $old_head $ZERO_OID reference already exists" stdout &&
+ test_grep "cannot lock ref ${SQ}refs/heads/ref2${SQ}: reference already exists" err
)
'
format_command $type "update refs/heads/ref1" "$old_head" "$head" >stdin &&
format_command $type "update refs/heads/ref2" "$head" "$old_head" >>stdin &&
- git update-ref $type --stdin --batch-updates <stdin >stdout &&
+ git update-ref $type --stdin --batch-updates <stdin >stdout 2>err &&
echo $old_head >expect &&
git rev-parse refs/heads/ref1 >actual &&
test_cmp expect actual &&
echo $head >expect &&
git rev-parse refs/heads/ref2 >actual &&
test_cmp expect actual &&
- test_grep -q "incorrect old value provided" stdout
+ test_grep "rejected refs/heads/ref2 $head $old_head incorrect old value provided" stdout &&
+ test_grep "cannot lock ref ${SQ}refs/heads/ref2${SQ}: is at $head but expected $old_head" err
)
'
git update-ref refs/heads/ref/foo $head &&
format_command $type "update refs/heads/ref/foo" "$old_head" "$head" >stdin &&
- format_command $type "update refs/heads/ref" "$old_head" "" >>stdin &&
- git update-ref $type --stdin --batch-updates <stdin >stdout &&
+ format_command $type "update refs/heads/ref" "$old_head" "$ZERO_OID" >>stdin &&
+ git update-ref $type --stdin --batch-updates <stdin >stdout 2>err &&
echo $old_head >expect &&
git rev-parse refs/heads/ref/foo >actual &&
test_cmp expect actual &&
- test_grep -q "refname conflict" stdout
+ test_grep "rejected refs/heads/ref $old_head $ZERO_OID refname conflict" stdout &&
+ test_grep "${SQ}refs/heads/ref/foo${SQ} exists; cannot create ${SQ}refs/heads/ref${SQ}" err
)
'
head=$(git rev-parse HEAD) &&
git update-ref refs/heads/ref/foo $head &&
- format_command $type "update refs/heads/foo" "$old_head" "" >stdin &&
- format_command $type "update refs/heads/ref" "$old_head" "" >>stdin &&
- git update-ref $type --stdin --batch-updates <stdin >stdout &&
+ format_command $type "update refs/heads/foo" "$old_head" "$ZERO_OID" >stdin &&
+ format_command $type "update refs/heads/ref" "$old_head" "$ZERO_OID" >>stdin &&
+ git update-ref $type --stdin --batch-updates <stdin >stdout 2>err &&
echo $old_head >expect &&
git rev-parse refs/heads/foo >actual &&
test_cmp expect actual &&
- test_grep -q "refname conflict" stdout
+ test_grep "rejected refs/heads/ref $old_head $ZERO_OID refname conflict" stdout &&
+ test_grep "${SQ}refs/heads/ref/foo${SQ} exists; cannot create ${SQ}refs/heads/ref${SQ}" err
)
'
format_command $type "create refs/heads/ref" "$old_head" &&
format_command $type "create refs/heads/Foo" "$old_head"
} >stdin &&
- git update-ref $type --stdin --batch-updates <stdin >stdout &&
+ git update-ref $type --stdin --batch-updates <stdin >stdout 2>err &&
echo $head >expect &&
git rev-parse refs/heads/foo >actual &&
echo $old_head >expect &&
git rev-parse refs/heads/ref >actual &&
test_cmp expect actual &&
- test_grep -q "reference conflict due to case-insensitive filesystem" stdout
+ test_grep "rejected refs/heads/Foo $old_head $ZERO_OID reference conflict due to case-insensitive filesystem" stdout &&
+ test_grep -e "cannot lock ref ${SQ}refs/heads/Foo${SQ}: Unable to create" -e "Foo.lock" err
)
'
git symbolic-ref refs/heads/symbolic refs/heads/non-existent &&
format_command $type "delete refs/heads/symbolic" "$head" >stdin &&
- git update-ref $type --stdin --batch-updates <stdin >stdout &&
- test_grep "reference does not exist" stdout
+ git update-ref $type --stdin --batch-updates <stdin >stdout 2>err &&
+ test_grep "rejected refs/heads/non-existent $ZERO_OID $head reference does not exist" stdout &&
+ test_grep "cannot lock ref ${SQ}refs/heads/symbolic${SQ}: unable to resolve reference ${SQ}refs/heads/non-existent${SQ}" err
)
'
head=$(git rev-parse HEAD) &&
format_command $type "delete refs/heads/new-branch" "$head" >stdin &&
- git update-ref $type --stdin --batch-updates <stdin >stdout &&
- test_grep "incorrect old value provided" stdout
+ git update-ref $type --stdin --batch-updates <stdin >stdout 2>err &&
+ test_grep "rejected refs/heads/new-branch $ZERO_OID $head incorrect old value provided" stdout &&
+ test_grep "cannot lock ref ${SQ}refs/heads/new-branch${SQ}: is at $(git rev-parse new-branch) but expected $head" err
)
'
head=$(git rev-parse HEAD) &&
format_command $type "delete refs/heads/non-existent" "$head" >stdin &&
- git update-ref $type --stdin --batch-updates <stdin >stdout &&
- test_grep "reference does not exist" stdout
+ git update-ref $type --stdin --batch-updates <stdin >stdout 2>err &&
+ test_grep "rejected refs/heads/non-existent $ZERO_OID $head reference does not exist" stdout &&
+ test_grep "cannot lock ref ${SQ}refs/heads/non-existent${SQ}: unable to resolve reference ${SQ}refs/heads/non-existent${SQ}" err
)
'
done