object: allow clear_commit_marks_all to handle any repo
PATCH v2 1/2 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 <[email protected]>
---
Changes from v1: Renamed the function; the "_all" part became misleading when it became possible to represent multiple repositories, but the function was still only operating on one of them.
bisect.c | 2 +- builtin/checkout.c | 2 +- builtin/gc.c | 2 +- object.c | 6 +++--- object.h | 5 +++-- 5 files changed, 9 insertions(+), 8 deletions(-)
bisect.c +1 -1
@@ -1090,7 +1090,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix) nr), nr, steps_msg);free (steps_msg);/* Clean up objects used, as they will be reused. */ -clear_commit_marks_all (ALL_REV_FLAGS ); +repo_clear_commit_marks (the_repository,ALL_REV_FLAGS );return bisect_checkout (bisect_rev, no_checkout); }
builtin/checkout.c +1 -1
@@ -1042,7 +1042,7 @@ static void orphaned_commit_warning(struct commit *old_commit, struct commit *nedescribe_detached_head (_ ("Previous HEAD position was" ), old_commit);/* Clean up objects used, as they will be reused. */ -clear_commit_marks_all (ALL_REV_FLAGS ); +repo_clear_commit_marks (the_repository,ALL_REV_FLAGS ); } static int switch_branches(const struct checkout_opts *opts,
builtin/gc.c +1 -1
@@ -788,7 +788,7 @@ static int should_write_commit_graph(void) result =for_each_ref (dfs_on_ref, &data); -clear_commit_marks_all (SEEN ); +repo_clear_commit_marks (the_repository,SEEN );return result; }
object.c +3 -3
@@ -453,12 +453,12 @@ void clear_object_flags(unsigned flags) } } -void clear_commit_marks_all (unsigned int flags) +void repo_clear_commit_marks (struct repository *r,unsigned int flags) {int i; -for (i =0 ; i < the_repository->parsed_objects->obj_hash_size; i++) { -struct object *obj = the_repository->parsed_objects->obj_hash[i]; +for (i =0 ; i < r->parsed_objects->obj_hash_size; i++) { +struct object *obj = r->parsed_objects->obj_hash[i];if (obj && obj->type ==OBJ_COMMIT ) obj->flags &= ~flags; }
object.h +3 -2
@@ -191,8 +191,9 @@ void object_array_clear(struct object_array *array);void clear_object_flags (unsigned flags);/* -* Clear the specified object flags from all in-core commit objects. +* Clear the specified object flags from all in-core commit objects from +* the specified repository. */ -void clear_commit_marks_all (unsigned int flags); +void repo_clear_commit_marks (struct repository *r,unsigned int flags);#endif /* OBJECT_H */
--
2.29.2
PATCH v2 2/2 bisect: clear flags in passed repository
69d2cfe6e8 (bisect.c: remove the_repository reference, 2018-11-10) kept the implicit the_repository reference in clear_commit_marks_all, which was made explicit by the previous commit (and which also renamed it to repo_clear_commit_marks). Replace it as well.
Signed-off-by René Scharfe <[email protected]>
--- bisect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
bisect.c +1 -1
@@ -1090,7 +1090,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix) nr), nr, steps_msg);free (steps_msg);/* Clean up objects used, as they will be reused. */ -repo_clear_commit_marks (the_repository,ALL_REV_FLAGS ); +repo_clear_commit_marks (r,ALL_REV_FLAGS );return bisect_checkout (bisect_rev, no_checkout); }
--
2.29.2