File tree 2 files changed +12
-0
lines changed
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)
147
147
struct ref_update * update ;
148
148
149
149
update = update_alloc ();
150
+ update -> have_old = 1 ;
150
151
151
152
if ((next = parse_first_arg (next , & ref )) != NULL && ref .buf [0 ])
152
153
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' '
820
820
test_must_fail git rev-parse --verify -q $c
821
821
'
822
822
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
+
823
833
test_expect_success ' stdin -z create ref fails with bad new value' '
834
+ git update-ref -d "$c" &&
824
835
printf $F "create $c" "does-not-exist" >stdin &&
825
836
test_must_fail git update-ref -z --stdin <stdin 2>err &&
826
837
grep "fatal: invalid new value for ref $c: does-not-exist" err &&
You can’t perform that action at this time.
0 commit comments