]> asedeno.scripts.mit.edu Git - git.git/blobdiff - reachable.c
Merge branch 'aw/git-p4-deletion' into maint
[git.git] / reachable.c
index 11499a60c4202ba29b2dfc8bf1e6536343dfed4c..a03fabf060081e9fa5e0d753cd0d9cf4bca5062e 100644 (file)
@@ -15,6 +15,8 @@ static void process_blob(struct blob *blob,
 {
        struct object *obj = &blob->object;
 
+       if (!blob)
+               die("bad blob object");
        if (obj->flags & SEEN)
                return;
        obj->flags |= SEEN;
@@ -39,12 +41,13 @@ static void process_tree(struct tree *tree,
        struct name_entry entry;
        struct name_path me;
 
+       if (!tree)
+               die("bad tree object");
        if (obj->flags & SEEN)
                return;
        obj->flags |= SEEN;
        if (parse_tree(tree) < 0)
                die("bad tree object %s", sha1_to_hex(obj->sha1));
-       name = xstrdup(name);
        add_object(obj, p, path, name);
        me.up = path;
        me.elem = name;
@@ -87,7 +90,7 @@ static void walk_commit_list(struct rev_info *revs)
 {
        int i;
        struct commit *commit;
-       struct object_array objects = { 0, 0, NULL };
+       struct object_array objects = OBJECT_ARRAY_INIT;
 
        /* Walk all commits, process their trees */
        while ((commit = get_revision(revs)) != NULL)
@@ -178,7 +181,7 @@ static void add_cache_refs(struct rev_info *revs)
                 * lookup_blob() on them, to avoid populating the hash table
                 * with invalid information
                 */
-               if (S_ISGITLINK(ntohl(active_cache[i]->ce_mode)))
+               if (S_ISGITLINK(active_cache[i]->ce_mode))
                        continue;
 
                lookup_blob(active_cache[i]->sha1);
@@ -217,6 +220,7 @@ void mark_reachable_objects(struct rev_info *revs, int mark_reflog)
         * Set up the revision walk - this will move all commits
         * from the pending list to the commit walking list.
         */
-       prepare_revision_walk(revs);
+       if (prepare_revision_walk(revs))
+               die("revision walk setup failed");
        walk_commit_list(revs);
 }