From b9d56b5dd9a8819c900725b8618f8bd994a5054f Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Wed, 2 Apr 2014 10:09:54 +0200 Subject: update-ref: fail create operation over stdin if ref already exists Signed-off-by: Aman Gupta Signed-off-by: Michael Haggerty Acked-by: Brad King Signed-off-by: Junio C Hamano --- t/t1400-update-ref.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 't') diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index 6ffd82fe32..e130c528fe 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -820,7 +820,18 @@ test_expect_success 'stdin -z update ref fails with bad old value' ' test_must_fail git rev-parse --verify -q $c ' +test_expect_success 'stdin -z create ref fails when ref exists' ' + git update-ref $c $m && + git rev-parse "$c" >expect && + printf $F "create $c" "$m~1" >stdin && + test_must_fail git update-ref -z --stdin err && + grep "fatal: Cannot lock the ref '"'"'$c'"'"'" err && + git rev-parse "$c" >actual && + test_cmp expect actual +' + test_expect_success 'stdin -z create ref fails with bad new value' ' + git update-ref -d "$c" && printf $F "create $c" "does-not-exist" >stdin && test_must_fail git update-ref -z --stdin err && grep "fatal: invalid new value for ref $c: does-not-exist" err && -- cgit v1.2.3