@@ -2646,6 +2646,8 @@ int repack_without_refs(const char **refnames, int n, struct strbuf *err)
2646
2646
struct string_list_item * ref_to_delete ;
2647
2647
int i , ret , removed = 0 ;
2648
2648
2649
+ assert (err );
2650
+
2649
2651
/* Look for a packed ref */
2650
2652
for (i = 0 ; i < n ; i ++ )
2651
2653
if (get_packed_ref (refnames [i ]))
@@ -2656,13 +2658,8 @@ int repack_without_refs(const char **refnames, int n, struct strbuf *err)
2656
2658
return 0 ; /* no refname exists in packed refs */
2657
2659
2658
2660
if (lock_packed_refs (0 )) {
2659
- if (err ) {
2660
- unable_to_lock_message (git_path ("packed-refs" ), errno ,
2661
- err );
2662
- return -1 ;
2663
- }
2664
- unable_to_lock_error (git_path ("packed-refs" ), errno );
2665
- return error ("cannot delete '%s' from packed refs" , refnames [i ]);
2661
+ unable_to_lock_message (git_path ("packed-refs" ), errno , err );
2662
+ return -1 ;
2666
2663
}
2667
2664
packed = get_packed_refs (& ref_cache );
2668
2665
@@ -2688,14 +2685,16 @@ int repack_without_refs(const char **refnames, int n, struct strbuf *err)
2688
2685
2689
2686
/* Write what remains */
2690
2687
ret = commit_packed_refs ();
2691
- if (ret && err )
2688
+ if (ret )
2692
2689
strbuf_addf (err , "unable to overwrite old ref-pack file: %s" ,
2693
2690
strerror (errno ));
2694
2691
return ret ;
2695
2692
}
2696
2693
2697
2694
static int delete_ref_loose (struct ref_lock * lock , int flag , struct strbuf * err )
2698
2695
{
2696
+ assert (err );
2697
+
2699
2698
if (!(flag & REF_ISPACKED ) || flag & REF_ISSYMREF ) {
2700
2699
/*
2701
2700
* loose. The loose file name is the same as the
@@ -3551,6 +3550,8 @@ struct ref_transaction {
3551
3550
3552
3551
struct ref_transaction * ref_transaction_begin (struct strbuf * err )
3553
3552
{
3553
+ assert (err );
3554
+
3554
3555
return xcalloc (1 , sizeof (struct ref_transaction ));
3555
3556
}
3556
3557
@@ -3590,6 +3591,8 @@ int ref_transaction_update(struct ref_transaction *transaction,
3590
3591
{
3591
3592
struct ref_update * update ;
3592
3593
3594
+ assert (err );
3595
+
3593
3596
if (transaction -> state != REF_TRANSACTION_OPEN )
3594
3597
die ("BUG: update called for transaction that is not open" );
3595
3598
@@ -3622,6 +3625,8 @@ int ref_transaction_create(struct ref_transaction *transaction,
3622
3625
{
3623
3626
struct ref_update * update ;
3624
3627
3628
+ assert (err );
3629
+
3625
3630
if (transaction -> state != REF_TRANSACTION_OPEN )
3626
3631
die ("BUG: create called for transaction that is not open" );
3627
3632
@@ -3653,6 +3658,8 @@ int ref_transaction_delete(struct ref_transaction *transaction,
3653
3658
{
3654
3659
struct ref_update * update ;
3655
3660
3661
+ assert (err );
3662
+
3656
3663
if (transaction -> state != REF_TRANSACTION_OPEN )
3657
3664
die ("BUG: delete called for transaction that is not open" );
3658
3665
@@ -3715,13 +3722,14 @@ static int ref_update_reject_duplicates(struct ref_update **updates, int n,
3715
3722
struct strbuf * err )
3716
3723
{
3717
3724
int i ;
3725
+
3726
+ assert (err );
3727
+
3718
3728
for (i = 1 ; i < n ; i ++ )
3719
3729
if (!strcmp (updates [i - 1 ]-> refname , updates [i ]-> refname )) {
3720
- const char * str =
3721
- "Multiple updates for ref '%s' not allowed." ;
3722
- if (err )
3723
- strbuf_addf (err , str , updates [i ]-> refname );
3724
-
3730
+ strbuf_addf (err ,
3731
+ "Multiple updates for ref '%s' not allowed." ,
3732
+ updates [i ]-> refname );
3725
3733
return 1 ;
3726
3734
}
3727
3735
return 0 ;
@@ -3735,6 +3743,8 @@ int ref_transaction_commit(struct ref_transaction *transaction,
3735
3743
int n = transaction -> nr ;
3736
3744
struct ref_update * * updates = transaction -> updates ;
3737
3745
3746
+ assert (err );
3747
+
3738
3748
if (transaction -> state != REF_TRANSACTION_OPEN )
3739
3749
die ("BUG: commit called for transaction that is not open" );
3740
3750
@@ -3771,9 +3781,8 @@ int ref_transaction_commit(struct ref_transaction *transaction,
3771
3781
ret = (errno == ENOTDIR )
3772
3782
? TRANSACTION_NAME_CONFLICT
3773
3783
: TRANSACTION_GENERIC_ERROR ;
3774
- if (err )
3775
- strbuf_addf (err , "Cannot lock the ref '%s'." ,
3776
- update -> refname );
3784
+ strbuf_addf (err , "Cannot lock the ref '%s'." ,
3785
+ update -> refname );
3777
3786
goto cleanup ;
3778
3787
}
3779
3788
}
@@ -3786,9 +3795,8 @@ int ref_transaction_commit(struct ref_transaction *transaction,
3786
3795
if (write_ref_sha1 (update -> lock , update -> new_sha1 ,
3787
3796
update -> msg )) {
3788
3797
update -> lock = NULL ; /* freed by write_ref_sha1 */
3789
- if (err )
3790
- strbuf_addf (err , "Cannot update the ref '%s'." ,
3791
- update -> refname );
3798
+ strbuf_addf (err , "Cannot update the ref '%s'." ,
3799
+ update -> refname );
3792
3800
ret = TRANSACTION_GENERIC_ERROR ;
3793
3801
goto cleanup ;
3794
3802
}
0 commit comments