struct ref_lock: convert old_sha1 member to object_id
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
May 25, 2015 at 18:39 UTC
5cb901a4b0e19c87a1415f0f74995e54690598af
1 file changed
+12
-12
refs.c
+12
-12
@@ -10,7 +10,7 @@ struct ref_lock {
10
char *ref_name;
11
char *orig_ref_name;
12
struct lock_file *lk;
13
- unsigned char old_sha1[20];
13
+ struct object_id old_oid;
14
};
15
16
/*
@@ -2225,16 +2225,16 @@ static struct ref_lock *verify_lock(struct ref_lock *lock,
2225
{
2226
if (read_ref_full(lock->ref_name,
2227
mustexist ? RESOLVE_REF_READING : 0,
2228
- lock->old_sha1, NULL)) {
2228
+ lock->old_oid.hash, NULL)) {
2229
int save_errno = errno;
2230
error("Can't verify ref %s", lock->ref_name);
2231
unlock_ref(lock);
2232
errno = save_errno;
2233
return NULL;
2234
}
2235
- if (hashcmp(lock->old_sha1, old_sha1)) {
2235
+ if (hashcmp(lock->old_oid.hash, old_sha1)) {
2236
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));
2238
unlock_ref(lock);
2239
errno = EBUSY;
2240
return NULL;
@@ -2382,7 +2382,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
2382
}
2383
2384
refname = resolve_ref_unsafe(refname, resolve_flags,
2385
- lock->old_sha1, &type);
2385
+ lock->old_oid.hash, &type);
2386
if (!refname && errno == EISDIR) {
2387
/* we are trying to lock foo but we used to
2388
* have foo/bar which now does not exist;
@@ -2401,7 +2401,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
2401
goto error_return;
2402
}
2403
refname = resolve_ref_unsafe(orig_refname, resolve_flags,
2404
- lock->old_sha1, &type);
2404
+ lock->old_oid.hash, &type);
2405
}
2406
if (type_p)
2407
*type_p = type;
@@ -2421,7 +2421,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
2421
* refname, nor a packed ref whose name is a proper prefix of
2422
* our refname.
2423
*/
2424
- if (is_null_sha1(lock->old_sha1) &&
2424
+ if (is_null_oid(&lock->old_oid) &&
2425
verify_refname_available(refname, extras, skip,
2426
get_packed_refs(&ref_cache), err)) {
2427
last_errno = ENOTDIR;
@@ -2944,7 +2944,7 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
2944
strbuf_release(&err);
2945
goto rollback;
2946
}
2947
- hashcpy(lock->old_sha1, orig_sha1);
2947
+ hashcpy(lock->old_oid.hash, orig_sha1);
2948
2949
if (write_ref_to_lockfile(lock, orig_sha1) ||
2950
commit_ref_update(lock, orig_sha1, logmsg)) {
@@ -3199,9 +3199,9 @@ static int commit_ref_update(struct ref_lock *lock,
3199
const unsigned char *sha1, const char *logmsg)
3200
{
3201
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 ||
3203
(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)) {
3205
unlock_ref(lock);
3206
return -1;
3207
}
@@ -3225,7 +3225,7 @@ static int commit_ref_update(struct ref_lock *lock,
3225
head_sha1, &head_flag);
3226
if (head_ref && (head_flag & REF_ISSYMREF) &&
3227
!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);
3229
}
3230
if (commit_ref(lock)) {
3231
error("Couldn't set %s", lock->ref_name);
@@ -3923,7 +3923,7 @@ int ref_transaction_commit(struct ref_transaction *transaction,
3923
(update->flags & REF_NODEREF));
3924
3925
if (!overwriting_symref &&
3926
- !hashcmp(update->lock->old_sha1, update->new_sha1)) {
3926
+ !hashcmp(update->lock->old_oid.hash, update->new_sha1)) {
3927
/*
3928
* The reference already has the desired
3929
* value, so we don't need to write it.