]> git.ipfire.org Git - thirdparty/git.git/blobdiff - remote.c
submodule: make zero-oid comparison hash function agnostic
[thirdparty/git.git] / remote.c
index 7f6277a1451d147fc5af4ae2910e7c40dd330aec..682f2a01f949ce942597a9190cecfc991db0108e 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -12,6 +12,7 @@
 #include "string-list.h"
 #include "mergesort.h"
 #include "argv-array.h"
+#include "commit-reach.h"
 
 enum map_direction { FROM_SRC, FROM_DST };
 
@@ -1388,7 +1389,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
 
                ref->deletion = is_null_oid(&ref->new_oid);
                if (!ref->deletion &&
-                       !oidcmp(&ref->old_oid, &ref->new_oid)) {
+                       oideq(&ref->old_oid, &ref->new_oid)) {
                        ref->status = REF_STATUS_UPTODATE;
                        continue;
                }
@@ -1403,7 +1404,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
                 * branch.
                 */
                if (ref->expect_old_sha1) {
-                       if (oidcmp(&ref->old_oid, &ref->old_oid_expect))
+                       if (!oideq(&ref->old_oid, &ref->old_oid_expect))
                                reject_reason = REF_STATUS_REJECT_STALE;
                        else
                                /* If the ref isn't stale then force the update. */
@@ -1791,55 +1792,6 @@ int resolve_remote_symref(struct ref *ref, struct ref *list)
        return 1;
 }
 
-static void unmark_and_free(struct commit_list *list, unsigned int mark)
-{
-       while (list) {
-               struct commit *commit = pop_commit(&list);
-               commit->object.flags &= ~mark;
-       }
-}
-
-int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)
-{
-       struct object *o;
-       struct commit *old_commit, *new_commit;
-       struct commit_list *list, *used;
-       int found = 0;
-
-       /*
-        * Both new_commit and old_commit must be commit-ish and new_commit is descendant of
-        * old_commit.  Otherwise we require --force.
-        */
-       o = deref_tag(the_repository, parse_object(the_repository, old_oid),
-                     NULL, 0);
-       if (!o || o->type != OBJ_COMMIT)
-               return 0;
-       old_commit = (struct commit *) o;
-
-       o = deref_tag(the_repository, parse_object(the_repository, new_oid),
-                     NULL, 0);
-       if (!o || o->type != OBJ_COMMIT)
-               return 0;
-       new_commit = (struct commit *) o;
-
-       if (parse_commit(new_commit) < 0)
-               return 0;
-
-       used = list = NULL;
-       commit_list_insert(new_commit, &list);
-       while (list) {
-               new_commit = pop_most_recent_commit(&list, TMP_MARK);
-               commit_list_insert(new_commit, &used);
-               if (new_commit == old_commit) {
-                       found = 1;
-                       break;
-               }
-       }
-       unmark_and_free(list, TMP_MARK);
-       unmark_and_free(used, TMP_MARK);
-       return found;
-}
-
 /*
  * Lookup the upstream branch for the given branch and if present, optionally
  * compute the commit ahead/behind values for the pair.
@@ -2049,7 +2001,7 @@ struct ref *guess_remote_head(const struct ref *head,
        /* If refs/heads/master could be right, it is. */
        if (!all) {
                r = find_ref_by_name(refs, "refs/heads/master");
-               if (r && !oidcmp(&r->old_oid, &head->old_oid))
+               if (r && oideq(&r->old_oid, &head->old_oid))
                        return copy_ref(r);
        }
 
@@ -2057,7 +2009,7 @@ struct ref *guess_remote_head(const struct ref *head,
        for (r = refs; r; r = r->next) {
                if (r != head &&
                    starts_with(r->name, "refs/heads/") &&
-                   !oidcmp(&r->old_oid, &head->old_oid)) {
+                   oideq(&r->old_oid, &head->old_oid)) {
                        *tail = copy_ref(r);
                        tail = &((*tail)->next);
                        if (!all)