Convert object iteration callbacks to struct object_id
[gitweb.git] / builtin / merge-base.c
index c0d1822eb3ad371b9ab0b830aed2cc2741a978bd..db95bc29cfa7b81e45b0062033675ae3e7d0668d 100644 (file)
@@ -131,7 +131,7 @@ static void add_one_commit(unsigned char *sha1, struct rev_collect *revs)
        commit->object.flags |= TMP_MARK;
 }
 
-static int collect_one_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
+static int collect_one_reflog_ent(struct object_id *ooid, struct object_id *noid,
                                  const char *ident, unsigned long timestamp,
                                  int tz, const char *message, void *cbdata)
 {
@@ -139,9 +139,9 @@ static int collect_one_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
 
        if (revs->initial) {
                revs->initial = 0;
-               add_one_commit(osha1, revs);
+               add_one_commit(ooid->hash, revs);
        }
-       add_one_commit(nsha1, revs);
+       add_one_commit(noid->hash, revs);
        return 0;
 }
 
@@ -173,6 +173,9 @@ static int handle_fork_point(int argc, const char **argv)
        revs.initial = 1;
        for_each_reflog_ent(refname, collect_one_reflog_ent, &revs);
 
+       if (!revs.nr && !get_sha1(refname, sha1))
+               add_one_commit(sha1, &revs);
+
        for (i = 0; i < revs.nr; i++)
                revs.commit[i]->object.flags &= ~TMP_MARK;