Skip to content

Commit 6f3d57b

Browse files
bk2204peff
authored andcommitted
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 <[email protected]> Signed-off-by: Jeff King <[email protected]>
1 parent 27912a0 commit 6f3d57b

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

builtin/remote.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ static int get_push_ref_states(const struct ref *remote_refs,
417417
else if (is_null_oid(&ref->old_oid))
418418
info->status = PUSH_STATUS_CREATE;
419419
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))
421421
info->status = PUSH_STATUS_FASTFORWARD;
422422
else
423423
info->status = PUSH_STATUS_OUTOFDATE;

http-push.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,8 +1886,8 @@ int main(int argc, char **argv)
18861886
!is_null_oid(&ref->old_oid) &&
18871887
!ref->force) {
18881888
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)) {
18911891
/*
18921892
* We do not have the remote ref, or
18931893
* we know that the remote ref is not

remote.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,7 +1590,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
15901590
else if (!lookup_commit_reference_gently(ref->old_oid.hash, 1) ||
15911591
!lookup_commit_reference_gently(ref->new_oid.hash, 1))
15921592
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))
15941594
reject_reason = REF_STATUS_REJECT_NONFASTFORWARD;
15951595
}
15961596

@@ -1944,7 +1944,7 @@ static void unmark_and_free(struct commit_list *list, unsigned int mark)
19441944
}
19451945
}
19461946

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)
19481948
{
19491949
struct object *o;
19501950
struct commit *old, *new;
@@ -1955,12 +1955,12 @@ int ref_newer(const unsigned char *new_sha1, const unsigned char *old_sha1)
19551955
* Both new and old must be commit-ish and new is descendant of
19561956
* old. Otherwise we require --force.
19571957
*/
1958-
o = deref_tag(parse_object(old_sha1), NULL, 0);
1958+
o = deref_tag(parse_object(old_oid->hash), NULL, 0);
19591959
if (!o || o->type != OBJ_COMMIT)
19601960
return 0;
19611961
old = (struct commit *) o;
19621962

1963-
o = deref_tag(parse_object(new_sha1), NULL, 0);
1963+
o = deref_tag(parse_object(new_oid->hash), NULL, 0);
19641964
if (!o || o->type != OBJ_COMMIT)
19651965
return 0;
19661966
new = (struct commit *) o;

remote.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ extern struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
150150
struct sha1_array *shallow);
151151

152152
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);
154154

155155
/*
156156
* Remove and free all but the first of any entries in the input list

0 commit comments

Comments
 (0)