Skip to content

Commit 5cb901a

Browse files
mhaggergitster
authored andcommitted
struct ref_lock: convert old_sha1 member to object_id
Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4e675d1 commit 5cb901a

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

refs.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct ref_lock {
1010
char *ref_name;
1111
char *orig_ref_name;
1212
struct lock_file *lk;
13-
unsigned char old_sha1[20];
13+
struct object_id old_oid;
1414
};
1515

1616
/*
@@ -2225,16 +2225,16 @@ static struct ref_lock *verify_lock(struct ref_lock *lock,
22252225
{
22262226
if (read_ref_full(lock->ref_name,
22272227
mustexist ? RESOLVE_REF_READING : 0,
2228-
lock->old_sha1, NULL)) {
2228+
lock->old_oid.hash, NULL)) {
22292229
int save_errno = errno;
22302230
error("Can't verify ref %s", lock->ref_name);
22312231
unlock_ref(lock);
22322232
errno = save_errno;
22332233
return NULL;
22342234
}
2235-
if (hashcmp(lock->old_sha1, old_sha1)) {
2235+
if (hashcmp(lock->old_oid.hash, old_sha1)) {
22362236
error("Ref %s is at %s but expected %s", lock->ref_name,
2237-
sha1_to_hex(lock->old_sha1), sha1_to_hex(old_sha1));
2237+
oid_to_hex(&lock->old_oid), sha1_to_hex(old_sha1));
22382238
unlock_ref(lock);
22392239
errno = EBUSY;
22402240
return NULL;
@@ -2382,7 +2382,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
23822382
}
23832383

23842384
refname = resolve_ref_unsafe(refname, resolve_flags,
2385-
lock->old_sha1, &type);
2385+
lock->old_oid.hash, &type);
23862386
if (!refname && errno == EISDIR) {
23872387
/* we are trying to lock foo but we used to
23882388
* have foo/bar which now does not exist;
@@ -2401,7 +2401,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
24012401
goto error_return;
24022402
}
24032403
refname = resolve_ref_unsafe(orig_refname, resolve_flags,
2404-
lock->old_sha1, &type);
2404+
lock->old_oid.hash, &type);
24052405
}
24062406
if (type_p)
24072407
*type_p = type;
@@ -2421,7 +2421,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
24212421
* refname, nor a packed ref whose name is a proper prefix of
24222422
* our refname.
24232423
*/
2424-
if (is_null_sha1(lock->old_sha1) &&
2424+
if (is_null_oid(&lock->old_oid) &&
24252425
verify_refname_available(refname, extras, skip,
24262426
get_packed_refs(&ref_cache), err)) {
24272427
last_errno = ENOTDIR;
@@ -2944,7 +2944,7 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
29442944
strbuf_release(&err);
29452945
goto rollback;
29462946
}
2947-
hashcpy(lock->old_sha1, orig_sha1);
2947+
hashcpy(lock->old_oid.hash, orig_sha1);
29482948

29492949
if (write_ref_to_lockfile(lock, orig_sha1) ||
29502950
commit_ref_update(lock, orig_sha1, logmsg)) {
@@ -3199,9 +3199,9 @@ static int commit_ref_update(struct ref_lock *lock,
31993199
const unsigned char *sha1, const char *logmsg)
32003200
{
32013201
clear_loose_ref_cache(&ref_cache);
3202-
if (log_ref_write(lock->ref_name, lock->old_sha1, sha1, logmsg) < 0 ||
3202+
if (log_ref_write(lock->ref_name, lock->old_oid.hash, sha1, logmsg) < 0 ||
32033203
(strcmp(lock->ref_name, lock->orig_ref_name) &&
3204-
log_ref_write(lock->orig_ref_name, lock->old_sha1, sha1, logmsg) < 0)) {
3204+
log_ref_write(lock->orig_ref_name, lock->old_oid.hash, sha1, logmsg) < 0)) {
32053205
unlock_ref(lock);
32063206
return -1;
32073207
}
@@ -3225,7 +3225,7 @@ static int commit_ref_update(struct ref_lock *lock,
32253225
head_sha1, &head_flag);
32263226
if (head_ref && (head_flag & REF_ISSYMREF) &&
32273227
!strcmp(head_ref, lock->ref_name))
3228-
log_ref_write("HEAD", lock->old_sha1, sha1, logmsg);
3228+
log_ref_write("HEAD", lock->old_oid.hash, sha1, logmsg);
32293229
}
32303230
if (commit_ref(lock)) {
32313231
error("Couldn't set %s", lock->ref_name);
@@ -3923,7 +3923,7 @@ int ref_transaction_commit(struct ref_transaction *transaction,
39233923
(update->flags & REF_NODEREF));
39243924

39253925
if (!overwriting_symref &&
3926-
!hashcmp(update->lock->old_sha1, update->new_sha1)) {
3926+
!hashcmp(update->lock->old_oid.hash, update->new_sha1)) {
39273927
/*
39283928
* The reference already has the desired
39293929
* value, so we don't need to write it.

0 commit comments

Comments
 (0)