Skip to content

Commit 15ba878

Browse files
committed
Merge branch 'rs/lock-correct-ref-during-delete'
When "update-ref -d --no-deref SYM" tried to delete a symbolic ref SYM, it incorrectly locked the underlying reference pointed by SYM, not the symbolic ref itself. * rs/lock-correct-ref-during-delete: refs: lock symref that is to be deleted, not its target
2 parents 5f83642 + 547d058 commit 15ba878

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

refs.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,26 +1762,18 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
17621762
struct ref_lock *lock;
17631763
int err, i = 0, ret = 0, flag = 0;
17641764

1765-
lock = lock_ref_sha1_basic(refname, sha1, 0, &flag);
1765+
lock = lock_ref_sha1_basic(refname, sha1, delopt, &flag);
17661766
if (!lock)
17671767
return 1;
17681768
if (!(flag & REF_ISPACKED) || flag & REF_ISSYMREF) {
17691769
/* loose */
1770-
const char *path;
1771-
1772-
if (!(delopt & REF_NODEREF)) {
1773-
i = strlen(lock->lk->filename) - 5; /* .lock */
1774-
lock->lk->filename[i] = 0;
1775-
path = lock->lk->filename;
1776-
} else {
1777-
path = git_path("%s", refname);
1778-
}
1779-
err = unlink_or_warn(path);
1770+
i = strlen(lock->lk->filename) - 5; /* .lock */
1771+
lock->lk->filename[i] = 0;
1772+
err = unlink_or_warn(lock->lk->filename);
17801773
if (err && errno != ENOENT)
17811774
ret = 1;
17821775

1783-
if (!(delopt & REF_NODEREF))
1784-
lock->lk->filename[i] = '.';
1776+
lock->lk->filename[i] = '.';
17851777
}
17861778
/* removing the loose one could have resurrected an earlier
17871779
* packed one. Also, if it was not loose we need to repack

0 commit comments

Comments
 (0)