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>maint
parent
4e675d1732
commit
5cb901a4b0
24
refs.c
24
refs.c
|
|
@ -10,7 +10,7 @@ struct ref_lock {
|
||||||
char *ref_name;
|
char *ref_name;
|
||||||
char *orig_ref_name;
|
char *orig_ref_name;
|
||||||
struct lock_file *lk;
|
struct lock_file *lk;
|
||||||
unsigned char old_sha1[20];
|
struct object_id old_oid;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -2225,16 +2225,16 @@ static struct ref_lock *verify_lock(struct ref_lock *lock,
|
||||||
{
|
{
|
||||||
if (read_ref_full(lock->ref_name,
|
if (read_ref_full(lock->ref_name,
|
||||||
mustexist ? RESOLVE_REF_READING : 0,
|
mustexist ? RESOLVE_REF_READING : 0,
|
||||||
lock->old_sha1, NULL)) {
|
lock->old_oid.hash, NULL)) {
|
||||||
int save_errno = errno;
|
int save_errno = errno;
|
||||||
error("Can't verify ref %s", lock->ref_name);
|
error("Can't verify ref %s", lock->ref_name);
|
||||||
unlock_ref(lock);
|
unlock_ref(lock);
|
||||||
errno = save_errno;
|
errno = save_errno;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (hashcmp(lock->old_sha1, old_sha1)) {
|
if (hashcmp(lock->old_oid.hash, old_sha1)) {
|
||||||
error("Ref %s is at %s but expected %s", lock->ref_name,
|
error("Ref %s is at %s but expected %s", lock->ref_name,
|
||||||
sha1_to_hex(lock->old_sha1), sha1_to_hex(old_sha1));
|
oid_to_hex(&lock->old_oid), sha1_to_hex(old_sha1));
|
||||||
unlock_ref(lock);
|
unlock_ref(lock);
|
||||||
errno = EBUSY;
|
errno = EBUSY;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -2382,7 +2382,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
|
||||||
}
|
}
|
||||||
|
|
||||||
refname = resolve_ref_unsafe(refname, resolve_flags,
|
refname = resolve_ref_unsafe(refname, resolve_flags,
|
||||||
lock->old_sha1, &type);
|
lock->old_oid.hash, &type);
|
||||||
if (!refname && errno == EISDIR) {
|
if (!refname && errno == EISDIR) {
|
||||||
/* we are trying to lock foo but we used to
|
/* we are trying to lock foo but we used to
|
||||||
* have foo/bar which now does not exist;
|
* have foo/bar which now does not exist;
|
||||||
|
|
@ -2401,7 +2401,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
|
||||||
goto error_return;
|
goto error_return;
|
||||||
}
|
}
|
||||||
refname = resolve_ref_unsafe(orig_refname, resolve_flags,
|
refname = resolve_ref_unsafe(orig_refname, resolve_flags,
|
||||||
lock->old_sha1, &type);
|
lock->old_oid.hash, &type);
|
||||||
}
|
}
|
||||||
if (type_p)
|
if (type_p)
|
||||||
*type_p = type;
|
*type_p = type;
|
||||||
|
|
@ -2421,7 +2421,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
|
||||||
* refname, nor a packed ref whose name is a proper prefix of
|
* refname, nor a packed ref whose name is a proper prefix of
|
||||||
* our refname.
|
* our refname.
|
||||||
*/
|
*/
|
||||||
if (is_null_sha1(lock->old_sha1) &&
|
if (is_null_oid(&lock->old_oid) &&
|
||||||
verify_refname_available(refname, extras, skip,
|
verify_refname_available(refname, extras, skip,
|
||||||
get_packed_refs(&ref_cache), err)) {
|
get_packed_refs(&ref_cache), err)) {
|
||||||
last_errno = ENOTDIR;
|
last_errno = ENOTDIR;
|
||||||
|
|
@ -2944,7 +2944,7 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
|
||||||
strbuf_release(&err);
|
strbuf_release(&err);
|
||||||
goto rollback;
|
goto rollback;
|
||||||
}
|
}
|
||||||
hashcpy(lock->old_sha1, orig_sha1);
|
hashcpy(lock->old_oid.hash, orig_sha1);
|
||||||
|
|
||||||
if (write_ref_to_lockfile(lock, orig_sha1) ||
|
if (write_ref_to_lockfile(lock, orig_sha1) ||
|
||||||
commit_ref_update(lock, orig_sha1, logmsg)) {
|
commit_ref_update(lock, orig_sha1, logmsg)) {
|
||||||
|
|
@ -3199,9 +3199,9 @@ static int commit_ref_update(struct ref_lock *lock,
|
||||||
const unsigned char *sha1, const char *logmsg)
|
const unsigned char *sha1, const char *logmsg)
|
||||||
{
|
{
|
||||||
clear_loose_ref_cache(&ref_cache);
|
clear_loose_ref_cache(&ref_cache);
|
||||||
if (log_ref_write(lock->ref_name, lock->old_sha1, sha1, logmsg) < 0 ||
|
if (log_ref_write(lock->ref_name, lock->old_oid.hash, sha1, logmsg) < 0 ||
|
||||||
(strcmp(lock->ref_name, lock->orig_ref_name) &&
|
(strcmp(lock->ref_name, lock->orig_ref_name) &&
|
||||||
log_ref_write(lock->orig_ref_name, lock->old_sha1, sha1, logmsg) < 0)) {
|
log_ref_write(lock->orig_ref_name, lock->old_oid.hash, sha1, logmsg) < 0)) {
|
||||||
unlock_ref(lock);
|
unlock_ref(lock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -3225,7 +3225,7 @@ static int commit_ref_update(struct ref_lock *lock,
|
||||||
head_sha1, &head_flag);
|
head_sha1, &head_flag);
|
||||||
if (head_ref && (head_flag & REF_ISSYMREF) &&
|
if (head_ref && (head_flag & REF_ISSYMREF) &&
|
||||||
!strcmp(head_ref, lock->ref_name))
|
!strcmp(head_ref, lock->ref_name))
|
||||||
log_ref_write("HEAD", lock->old_sha1, sha1, logmsg);
|
log_ref_write("HEAD", lock->old_oid.hash, sha1, logmsg);
|
||||||
}
|
}
|
||||||
if (commit_ref(lock)) {
|
if (commit_ref(lock)) {
|
||||||
error("Couldn't set %s", lock->ref_name);
|
error("Couldn't set %s", lock->ref_name);
|
||||||
|
|
@ -3923,7 +3923,7 @@ int ref_transaction_commit(struct ref_transaction *transaction,
|
||||||
(update->flags & REF_NODEREF));
|
(update->flags & REF_NODEREF));
|
||||||
|
|
||||||
if (!overwriting_symref &&
|
if (!overwriting_symref &&
|
||||||
!hashcmp(update->lock->old_sha1, update->new_sha1)) {
|
!hashcmp(update->lock->old_oid.hash, update->new_sha1)) {
|
||||||
/*
|
/*
|
||||||
* The reference already has the desired
|
* The reference already has the desired
|
||||||
* value, so we don't need to write it.
|
* value, so we don't need to write it.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue