Skip to content

Commit 5a6f470

Browse files
stefanbellergitster
authored andcommitted
struct ref_lock: delete the force_write member
Instead, compute the value when it is needed. Signed-off-by: Stefan Beller <[email protected]> Edited-by: Michael Haggerty <[email protected]> Signed-off-by: Michael Haggerty <[email protected]> Reviewed-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 074336e commit 5a6f470

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

refs.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ struct ref_lock {
1212
struct lock_file *lk;
1313
unsigned char old_sha1[20];
1414
int lock_fd;
15-
int force_write;
1615
};
1716

1817
/*
@@ -2319,8 +2318,6 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
23192318
lock->ref_name = xstrdup(refname);
23202319
lock->orig_ref_name = xstrdup(orig_refname);
23212320
ref_file = git_path("%s", refname);
2322-
if ((flags & REF_NODEREF) && (type & REF_ISSYMREF))
2323-
lock->force_write = 1;
23242321

23252322
retry:
23262323
switch (safe_create_leading_directories(ref_file)) {
@@ -3788,8 +3785,15 @@ int ref_transaction_commit(struct ref_transaction *transaction,
37883785
struct ref_update *update = updates[i];
37893786

37903787
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+
*/
37933797
unlock_ref(update->lock);
37943798
update->lock = NULL;
37953799
} else if (write_ref_sha1(update->lock, update->new_sha1,

0 commit comments

Comments
 (0)