@@ -12,7 +12,6 @@ struct ref_lock {
12
12
struct lock_file * lk ;
13
13
unsigned char old_sha1 [20 ];
14
14
int lock_fd ;
15
- int force_write ;
16
15
};
17
16
18
17
/*
@@ -2319,8 +2318,6 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
2319
2318
lock -> ref_name = xstrdup (refname );
2320
2319
lock -> orig_ref_name = xstrdup (orig_refname );
2321
2320
ref_file = git_path ("%s" , refname );
2322
- if ((flags & REF_NODEREF ) && (type & REF_ISSYMREF ))
2323
- lock -> force_write = 1 ;
2324
2321
2325
2322
retry :
2326
2323
switch (safe_create_leading_directories (ref_file )) {
@@ -3788,8 +3785,15 @@ int ref_transaction_commit(struct ref_transaction *transaction,
3788
3785
struct ref_update * update = updates [i ];
3789
3786
3790
3787
if (!is_null_sha1 (update -> new_sha1 )) {
3791
- if (!update -> lock -> force_write &&
3792
- !hashcmp (update -> lock -> old_sha1 , update -> new_sha1 )) {
3788
+ int overwriting_symref = ((update -> type & REF_ISSYMREF ) &&
3789
+ (update -> flags & REF_NODEREF ));
3790
+
3791
+ if (!overwriting_symref
3792
+ && !hashcmp (update -> lock -> old_sha1 , update -> new_sha1 )) {
3793
+ /*
3794
+ * The reference already has the desired
3795
+ * value, so we don't need to write it.
3796
+ */
3793
3797
unlock_ref (update -> lock );
3794
3798
update -> lock = NULL ;
3795
3799
} else if (write_ref_sha1 (update -> lock , update -> new_sha1 ,
0 commit comments