diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-04-08 12:00:22 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-04-08 12:00:22 -0700 |
commit | 9b30a0339db28e6de9653b5631247d398cce626c (patch) | |
tree | e7710fd76ce6c4749e0935a98b8ac145c176d802 | |
parent | b389e04031ffe4c725161a082ff748bd33688641 (diff) | |
parent | b9d56b5dd9a8819c900725b8618f8bd994a5054f (diff) | |
download | git-9b30a0339db28e6de9653b5631247d398cce626c.tar.gz |
Merge branch 'mh/update-ref-batch-create-fix'
* mh/update-ref-batch-create-fix:
update-ref: fail create operation over stdin if ref already exists
-rw-r--r-- | builtin/update-ref.c | 1 | ||||
-rwxr-xr-x | t/t1400-update-ref.sh | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/builtin/update-ref.c b/builtin/update-ref.c index 1292cfea11..5c208bb1fc 100644 --- a/builtin/update-ref.c +++ b/builtin/update-ref.c @@ -147,6 +147,7 @@ static void parse_cmd_create(const char *next) struct ref_update *update; update = update_alloc(); + update->have_old = 1; if ((next = parse_first_arg(next, &ref)) != NULL && ref.buf[0]) update_store_ref_name(update, ref.buf); 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 <stdin 2>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 <stdin 2>err && grep "fatal: invalid new value for ref $c: does-not-exist" err && |