describe: allow more than one revs to be named.
authorJunio C Hamano <junkio@cox.net>
Sun, 8 Jan 2006 02:52:42 +0000 (18:52 -0800)
committerJunio C Hamano <junkio@cox.net>
Sun, 8 Jan 2006 05:43:01 +0000 (21:43 -0800)
The main loop was prepared to take more than one revs, but the actual
naming logic wad not (it used pop_most_recent_commit while forgetting
that the commit marks stay after it's done).

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

index edd4ded..e9a29ca 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -352,6 +352,19 @@ struct commit *pop_most_recent_commit(struct commit_list **list,
        return ret;
 }
 
+void clear_commit_marks(struct commit *commit, unsigned int mark)
+{
+       struct commit_list *parents;
+
+       parents = commit->parents;
+       commit->object.flags &= ~mark;
+       while (parents) {
+               if (parents->item && parents->item->object.parsed)
+                       clear_commit_marks(parents->item, mark);
+               parents = parents->next;
+       }
+}
+
 /*
  * Generic support for pretty-printing the header
  */
index 6738a69..9c4a244 100644 (file)
--- a/commit.h
+++ b/commit.h
@@ -58,6 +58,8 @@ struct commit *pop_most_recent_commit(struct commit_list **list,
 
 struct commit *pop_commit(struct commit_list **stack);
 
+void clear_commit_marks(struct commit *commit, unsigned int mark);
+
 int count_parents(struct commit * commit);
 
 /*
index 84d96b5..00fa02a 100644 (file)
@@ -124,9 +124,10 @@ static void describe(struct commit *cmit)
                if (n) {
                        printf("%s-g%s\n", n->path,
                               find_unique_abbrev(cmit->object.sha1, abbrev));
-                       return;
+                       break;
                }
        }
+       clear_commit_marks(cmit, SEEN);
 }
 
 int main(int argc, char **argv)