commit.c: add clear_commit_marks_many()

clear_commit_marks(struct commit *, unsigned) only can clear flag bits starting from a single commit; introduce an API to allow feeding an array of commits, so that flag bits can be cleared from commits reachable from any of them with a single traversal. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Mar 5, 2013 at 11:42 UTC e895cb5135d7fbff8037ce83302aff12ee83667c
2 files changed +14 -6
commit.c
+13 -6
@@ -463,14 +463,23 @@ static void clear_commit_marks_1(struct commit_list **plist,
463 }
464 }
465
466 -void clear_commit_marks(struct commit *commit, unsigned int mark)
466 +void clear_commit_marks_many(int nr, struct commit **commit, unsigned int mark)
467 {
468 struct commit_list *list = NULL;
469 - commit_list_insert(commit, &list);
469 +
470 + while (nr--) {
471 + commit_list_insert(*commit, &list);
472 + commit++;
473 + }
474 while (list)
475 clear_commit_marks_1(&list, pop_commit(&list), mark);
476 }
477
478 +void clear_commit_marks(struct commit *commit, unsigned int mark)
479 +{
480 + clear_commit_marks_many(1, &commit, mark);
481 +}
482 +
483 void clear_commit_marks_for_object_array(struct object_array *a, unsigned mark)
484 {
485 struct object *object;
@@ -797,8 +806,7 @@ struct commit_list *get_merge_bases_many(struct commit *one,
806 if (!result || !result->next) {
807 if (cleanup) {
808 clear_commit_marks(one, all_flags);
800 - for (i = 0; i < n; i++)
801 - clear_commit_marks(twos[i], all_flags);
809 + clear_commit_marks_many(n, twos, all_flags);
810 }
811 return result;
812 }
@@ -816,8 +824,7 @@ struct commit_list *get_merge_bases_many(struct commit *one,
824 free_commit_list(result);
825
826 clear_commit_marks(one, all_flags);
819 - for (i = 0; i < n; i++)
820 - clear_commit_marks(twos[i], all_flags);
827 + clear_commit_marks_many(n, twos, all_flags);
828
829 cnt = remove_redundant(rslt, cnt);
830 result = NULL;
commit.h
+1
@@ -134,6 +134,7 @@ struct commit *pop_most_recent_commit(struct commit_list **list,
134 struct commit *pop_commit(struct commit_list **stack);
135
136 void clear_commit_marks(struct commit *commit, unsigned int mark);
137 +void clear_commit_marks_many(int nr, struct commit **commit, unsigned int mark);
138 void clear_commit_marks_for_object_array(struct object_array *a, unsigned mark);
139
140 /*