File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,7 @@ static void parse_cmd_create(const char *next)
147147 struct ref_update * update ;
148148
149149 update = update_alloc ();
150+ update -> have_old = 1 ;
150151
151152 if ((next = parse_first_arg (next , & ref )) != NULL && ref .buf [0 ])
152153 update_store_ref_name (update , ref .buf );
Original file line number Diff line number Diff line change @@ -820,7 +820,18 @@ test_expect_success 'stdin -z update ref fails with bad old value' '
820820 test_must_fail git rev-parse --verify -q $c
821821'
822822
823+ test_expect_success ' stdin -z create ref fails when ref exists' '
824+ git update-ref $c $m &&
825+ git rev-parse "$c" >expect &&
826+ printf $F "create $c" "$m~1" >stdin &&
827+ test_must_fail git update-ref -z --stdin <stdin 2>err &&
828+ grep "fatal: Cannot lock the ref ' " '" ' $c' " '" ' " err &&
829+ git rev-parse "$c" >actual &&
830+ test_cmp expect actual
831+ '
832+
823833test_expect_success ' stdin -z create ref fails with bad new value' '
834+ git update-ref -d "$c" &&
824835 printf $F "create $c" "does-not-exist" >stdin &&
825836 test_must_fail git update-ref -z --stdin <stdin 2>err &&
826837 grep "fatal: invalid new value for ref $c: does-not-exist" err &&
You can’t perform that action at this time.
0 commit comments