sha1_file: add for_each iterators for loose and packed objects
[gitweb.git] / reachable.c
index 02bf6c2fe4fc90c2f3327988b009f1dc1a3b1e2c..d03f8294eea9793bc93a44423f49e039888a9ffb 100644 (file)
@@ -22,22 +22,6 @@ static void update_progress(struct connectivity_progress *cp)
                display_progress(cp->progress, cp->count);
 }
 
-static int add_one_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
-               const char *email, unsigned long timestamp, int tz,
-               const char *message, void *cb_data)
-{
-       struct object *object;
-       struct rev_info *revs = (struct rev_info *)cb_data;
-
-       object = parse_object(osha1);
-       if (object)
-               add_pending_object(revs, object, "");
-       object = parse_object(nsha1);
-       if (object)
-               add_pending_object(revs, object, "");
-       return 0;
-}
-
 static int add_one_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data)
 {
        struct object *object = parse_object_or_die(sha1, path);
@@ -48,12 +32,6 @@ static int add_one_ref(const char *path, const unsigned char *sha1, int flag, vo
        return 0;
 }
 
-static int add_one_reflog(const char *path, const unsigned char *sha1, int flag, void *cb_data)
-{
-       for_each_reflog_ent(path, add_one_reflog_ent, cb_data);
-       return 0;
-}
-
 static void add_one_tree(const unsigned char *sha1, struct rev_info *revs)
 {
        struct tree *tree = lookup_tree(sha1);
@@ -77,6 +55,8 @@ static void add_cache_refs(struct rev_info *revs)
 
        read_cache();
        for (i = 0; i < active_nr; i++) {
+               struct blob *blob;
+
                /*
                 * The index can contain blobs and GITLINKs, GITLINKs are hashes
                 * that don't actually point to objects in the repository, it's
@@ -87,7 +67,10 @@ static void add_cache_refs(struct rev_info *revs)
                if (S_ISGITLINK(active_cache[i]->ce_mode))
                        continue;
 
-               lookup_blob(active_cache[i]->sha1);
+               blob = lookup_blob(active_cache[i]->sha1);
+               if (blob)
+                       blob->object.flags |= SEEN;
+
                /*
                 * We could add the blobs to the pending list, but quite
                 * frankly, we don't care. Once we've looked them up, and
@@ -138,7 +121,7 @@ void mark_reachable_objects(struct rev_info *revs, int mark_reflog,
 
        /* Add all reflog info */
        if (mark_reflog)
-               for_each_reflog(add_one_reflog, revs);
+               add_reflogs_to_pending(revs, 0);
 
        cp.progress = progress;
        cp.count = 0;