object: allow clear_commit_marks_all to handle any repo

Allow callers to specify the repository to use. Rename the function to repo_clear_commit_marks to document its new scope. No functional change intended. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Oct 31, 2020 at 13:46 UTC cd8888452cd0e09c9efdc22da729023ae255b54b
5 files changed +9 -8
bisect.c
+1 -1
@@ -1090,7 +1090,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix)
1090 nr), nr, steps_msg);
1091 free(steps_msg);
1092 /* Clean up objects used, as they will be reused. */
1093 - clear_commit_marks_all(ALL_REV_FLAGS);
1093 + repo_clear_commit_marks(the_repository, ALL_REV_FLAGS);
1094
1095 return bisect_checkout(bisect_rev, no_checkout);
1096 }
builtin/checkout.c
+1 -1
@@ -1029,7 +1029,7 @@ static void orphaned_commit_warning(struct commit *old_commit, struct commit *ne
1029 describe_detached_head(_("Previous HEAD position was"), old_commit);
1030
1031 /* Clean up objects used, as they will be reused. */
1032 - clear_commit_marks_all(ALL_REV_FLAGS);
1032 + repo_clear_commit_marks(the_repository, ALL_REV_FLAGS);
1033 }
1034
1035 static int switch_branches(const struct checkout_opts *opts,
builtin/gc.c
+1 -1
@@ -786,7 +786,7 @@ static int should_write_commit_graph(void)
786
787 result = for_each_ref(dfs_on_ref, &data);
788
789 - clear_commit_marks_all(SEEN);
789 + repo_clear_commit_marks(the_repository, SEEN);
790
791 return result;
792 }
object.c
+3 -3
@@ -453,12 +453,12 @@ void clear_object_flags(unsigned flags)
453 }
454 }
455
456 -void clear_commit_marks_all(unsigned int flags)
456 +void repo_clear_commit_marks(struct repository *r, unsigned int flags)
457 {
458 int i;
459
460 - for (i = 0; i < the_repository->parsed_objects->obj_hash_size; i++) {
461 - struct object *obj = the_repository->parsed_objects->obj_hash[i];
460 + for (i = 0; i < r->parsed_objects->obj_hash_size; i++) {
461 + struct object *obj = r->parsed_objects->obj_hash[i];
462 if (obj && obj->type == OBJ_COMMIT)
463 obj->flags &= ~flags;
464 }
object.h
+3 -2
@@ -191,8 +191,9 @@ void object_array_clear(struct object_array *array);
191 void clear_object_flags(unsigned flags);
192
193 /*
194 - * Clear the specified object flags from all in-core commit objects.
194 + * Clear the specified object flags from all in-core commit objects from
195 + * the specified repository.
196 */
196 -void clear_commit_marks_all(unsigned int flags);
197 +void repo_clear_commit_marks(struct repository *r, unsigned int flags);
198
199 #endif /* OBJECT_H */