revert clear-commit-marks for now.
authorJunio C Hamano <junkio@cox.net>
Mon, 3 Jul 2006 10:05:20 +0000 (03:05 -0700)
committerJunio C Hamano <junkio@cox.net>
Mon, 3 Jul 2006 10:05:20 +0000 (03:05 -0700)
Earlier change broke "git describe A B" among other things.
Revert it for now, and clean the commits smudged by
get_merge_bases using clear_object_marks() function.  For
complex commit ancestry graph, this is way cheaper as well.

Signed-off-by: Junio C Hamano <junkio@cox.net>
commit.c
object.c
object.h

index 12882fd496e5c18dacae76a6c68784700ce63721..04390643e8a26d38af32268610ad46d6095f81b7 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -397,12 +397,13 @@ void clear_commit_marks(struct commit *commit, unsigned int mark)
 {
        struct commit_list *parents;
 
-       if (!commit)
-               return;
        parents = commit->parents;
        commit->object.flags &= ~mark;
        while (parents) {
-               clear_commit_marks(parents->item, mark);
+               struct commit *parent = parents->item;
+               if (parent && parent->object.parsed &&
+                   (parent->object.flags & mark))
+                       clear_commit_marks(parent, mark);
                parents = parents->next;
        }
 }
@@ -1082,10 +1083,8 @@ struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2,
        }
 
  finish:
-       if (cleanup) {
-               clear_commit_marks(rev1, PARENT1 | PARENT2 | STALE);
-               clear_commit_marks(rev2, PARENT1 | PARENT2 | STALE);
-       }
+       if (cleanup)
+               clear_object_marks(PARENT1 | PARENT2 | STALE);
 
        return result;
 }
index 37784cee9a90a7e5b44dd660d6b7ea9191b59486..9caba4fac857d82e12416b3d579aa4fe79722e1f 100644 (file)
--- a/object.c
+++ b/object.c
@@ -217,3 +217,12 @@ void add_object_array(struct object *obj, const char *name, struct object_array
        objects[nr].name = name;
        array->nr = ++nr;
 }
+
+void clear_object_marks(unsigned mark)
+{
+       int i;
+
+       for (i = 0; i < obj_allocs; i++)
+               if (objs[i])
+                       objs[i]->flags &= ~mark;
+}
index 6f23a9a18099cbc9fdc827f53843b1157dd10935..7ac10111c67fde71f89e4d1b93367c6ca90dd5c8 100644 (file)
--- a/object.h
+++ b/object.h
@@ -83,4 +83,6 @@ int object_list_contains(struct object_list *list, struct object *obj);
 /* Object array handling .. */
 void add_object_array(struct object *obj, const char *name, struct object_array *array);
 
+void clear_object_marks(unsigned);
+
 #endif /* OBJECT_H */