ref_newer: convert to use struct object_id
Convert ref_newer and its caller to use struct object_id instead of unsigned char *. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Jeff King <peff@peff.net>
This commit is contained in:
parent
27912a03fd
commit
6f3d57b6e4
@ -417,7 +417,7 @@ static int get_push_ref_states(const struct ref *remote_refs,
|
|||||||
else if (is_null_oid(&ref->old_oid))
|
else if (is_null_oid(&ref->old_oid))
|
||||||
info->status = PUSH_STATUS_CREATE;
|
info->status = PUSH_STATUS_CREATE;
|
||||||
else if (has_object_file(&ref->old_oid) &&
|
else if (has_object_file(&ref->old_oid) &&
|
||||||
ref_newer(ref->new_oid.hash, ref->old_oid.hash))
|
ref_newer(&ref->new_oid, &ref->old_oid))
|
||||||
info->status = PUSH_STATUS_FASTFORWARD;
|
info->status = PUSH_STATUS_FASTFORWARD;
|
||||||
else
|
else
|
||||||
info->status = PUSH_STATUS_OUTOFDATE;
|
info->status = PUSH_STATUS_OUTOFDATE;
|
||||||
|
@ -1886,8 +1886,8 @@ int main(int argc, char **argv)
|
|||||||
!is_null_oid(&ref->old_oid) &&
|
!is_null_oid(&ref->old_oid) &&
|
||||||
!ref->force) {
|
!ref->force) {
|
||||||
if (!has_object_file(&ref->old_oid) ||
|
if (!has_object_file(&ref->old_oid) ||
|
||||||
!ref_newer(ref->peer_ref->new_oid.hash,
|
!ref_newer(&ref->peer_ref->new_oid,
|
||||||
ref->old_oid.hash)) {
|
&ref->old_oid)) {
|
||||||
/*
|
/*
|
||||||
* We do not have the remote ref, or
|
* We do not have the remote ref, or
|
||||||
* we know that the remote ref is not
|
* we know that the remote ref is not
|
||||||
|
8
remote.c
8
remote.c
@ -1590,7 +1590,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
|
|||||||
else if (!lookup_commit_reference_gently(ref->old_oid.hash, 1) ||
|
else if (!lookup_commit_reference_gently(ref->old_oid.hash, 1) ||
|
||||||
!lookup_commit_reference_gently(ref->new_oid.hash, 1))
|
!lookup_commit_reference_gently(ref->new_oid.hash, 1))
|
||||||
reject_reason = REF_STATUS_REJECT_NEEDS_FORCE;
|
reject_reason = REF_STATUS_REJECT_NEEDS_FORCE;
|
||||||
else if (!ref_newer(ref->new_oid.hash, ref->old_oid.hash))
|
else if (!ref_newer(&ref->new_oid, &ref->old_oid))
|
||||||
reject_reason = REF_STATUS_REJECT_NONFASTFORWARD;
|
reject_reason = REF_STATUS_REJECT_NONFASTFORWARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1944,7 +1944,7 @@ static void unmark_and_free(struct commit_list *list, unsigned int mark)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ref_newer(const unsigned char *new_sha1, const unsigned char *old_sha1)
|
int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)
|
||||||
{
|
{
|
||||||
struct object *o;
|
struct object *o;
|
||||||
struct commit *old, *new;
|
struct commit *old, *new;
|
||||||
@ -1955,12 +1955,12 @@ int ref_newer(const unsigned char *new_sha1, const unsigned char *old_sha1)
|
|||||||
* Both new and old must be commit-ish and new is descendant of
|
* Both new and old must be commit-ish and new is descendant of
|
||||||
* old. Otherwise we require --force.
|
* old. Otherwise we require --force.
|
||||||
*/
|
*/
|
||||||
o = deref_tag(parse_object(old_sha1), NULL, 0);
|
o = deref_tag(parse_object(old_oid->hash), NULL, 0);
|
||||||
if (!o || o->type != OBJ_COMMIT)
|
if (!o || o->type != OBJ_COMMIT)
|
||||||
return 0;
|
return 0;
|
||||||
old = (struct commit *) o;
|
old = (struct commit *) o;
|
||||||
|
|
||||||
o = deref_tag(parse_object(new_sha1), NULL, 0);
|
o = deref_tag(parse_object(new_oid->hash), NULL, 0);
|
||||||
if (!o || o->type != OBJ_COMMIT)
|
if (!o || o->type != OBJ_COMMIT)
|
||||||
return 0;
|
return 0;
|
||||||
new = (struct commit *) o;
|
new = (struct commit *) o;
|
||||||
|
2
remote.h
2
remote.h
@ -150,7 +150,7 @@ extern struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
|
|||||||
struct sha1_array *shallow);
|
struct sha1_array *shallow);
|
||||||
|
|
||||||
int resolve_remote_symref(struct ref *ref, struct ref *list);
|
int resolve_remote_symref(struct ref *ref, struct ref *list);
|
||||||
int ref_newer(const unsigned char *new_sha1, const unsigned char *old_sha1);
|
int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remove and free all but the first of any entries in the input list
|
* Remove and free all but the first of any entries in the input list
|
||||||
|
Loading…
Reference in New Issue
Block a user