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>

brian m. carlson committed Nov 10, 2015 at 02:22 UTC 6f3d57b6e43d6c6f13c94371f16b79fcdece25bc
4 files changed +8 -8
builtin/remote.c
+1 -1
@@ -417,7 +417,7 @@ static int get_push_ref_states(const struct ref *remote_refs,
417 else if (is_null_oid(&ref->old_oid))
418 info->status = PUSH_STATUS_CREATE;
419 else if (has_object_file(&ref->old_oid) &&
420 - ref_newer(ref->new_oid.hash, ref->old_oid.hash))
420 + ref_newer(&ref->new_oid, &ref->old_oid))
421 info->status = PUSH_STATUS_FASTFORWARD;
422 else
423 info->status = PUSH_STATUS_OUTOFDATE;
http-push.c
+2 -2
@@ -1886,8 +1886,8 @@ int main(int argc, char **argv)
1886 !is_null_oid(&ref->old_oid) &&
1887 !ref->force) {
1888 if (!has_object_file(&ref->old_oid) ||
1889 - !ref_newer(ref->peer_ref->new_oid.hash,
1890 - ref->old_oid.hash)) {
1889 + !ref_newer(&ref->peer_ref->new_oid,
1890 + &ref->old_oid)) {
1891 /*
1892 * We do not have the remote ref, or
1893 * we know that the remote ref is not
remote.c
+4 -4
@@ -1590,7 +1590,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
1590 else if (!lookup_commit_reference_gently(ref->old_oid.hash, 1) ||
1591 !lookup_commit_reference_gently(ref->new_oid.hash, 1))
1592 reject_reason = REF_STATUS_REJECT_NEEDS_FORCE;
1593 - else if (!ref_newer(ref->new_oid.hash, ref->old_oid.hash))
1593 + else if (!ref_newer(&ref->new_oid, &ref->old_oid))
1594 reject_reason = REF_STATUS_REJECT_NONFASTFORWARD;
1595 }
1596
@@ -1944,7 +1944,7 @@ static void unmark_and_free(struct commit_list *list, unsigned int mark)
1944 }
1945 }
1946
1947 -int ref_newer(const unsigned char *new_sha1, const unsigned char *old_sha1)
1947 +int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)
1948 {
1949 struct object *o;
1950 struct commit *old, *new;
@@ -1955,12 +1955,12 @@ int ref_newer(const unsigned char *new_sha1, const unsigned char *old_sha1)
1955 * Both new and old must be commit-ish and new is descendant of
1956 * old. Otherwise we require --force.
1957 */
1958 - o = deref_tag(parse_object(old_sha1), NULL, 0);
1958 + o = deref_tag(parse_object(old_oid->hash), NULL, 0);
1959 if (!o || o->type != OBJ_COMMIT)
1960 return 0;
1961 old = (struct commit *) o;
1962
1963 - o = deref_tag(parse_object(new_sha1), NULL, 0);
1963 + o = deref_tag(parse_object(new_oid->hash), NULL, 0);
1964 if (!o || o->type != OBJ_COMMIT)
1965 return 0;
1966 new = (struct commit *) o;
remote.h
+1 -1
@@ -150,7 +150,7 @@ extern struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
150 struct sha1_array *shallow);
151
152 int resolve_remote_symref(struct ref *ref, struct ref *list);
153 -int ref_newer(const unsigned char *new_sha1, const unsigned char *old_sha1);
153 +int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid);
154
155 /*
156 * Remove and free all but the first of any entries in the input list