diff mbox series

[5/5] object.c: clear_commit_marks_all() accept 'r' as parameter

Message ID 746d9ff810c384db8568c75472b18f8a9afec5fb.1581535151.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series object.c: localize global the_repository variable into r | expand

Commit Message

John Passaro via GitGitGadget Feb. 12, 2020, 7:19 p.m. UTC
From: Parth Gala <parthpgala@gmail.com>

'clear_commit_marks_all()' and its callers are modified to enable
passing 'r' as an argument to 'clear_commit_marks_all()'.

Signed-off-by: Parth Gala <parthpgala@gmail.com>
---
 builtin/checkout.c | 3 ++-
 object.c           | 6 +++---
 object.h           | 2 +-
 3 files changed, 6 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/builtin/checkout.c b/builtin/checkout.c
index b52c490c8f..bd2b8de8b7 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -989,6 +989,7 @@  static void suggest_reattach(struct commit *commit, struct rev_info *revs)
 static void orphaned_commit_warning(struct commit *old_commit, struct commit *new_commit)
 {
 	struct rev_info revs;
+	struct repository *r = the_repository;
 	struct object *object = &old_commit->object;
 
 	repo_init_revisions(the_repository, &revs, NULL);
@@ -1011,7 +1012,7 @@  static void orphaned_commit_warning(struct commit *old_commit, struct commit *ne
 		describe_detached_head(_("Previous HEAD position was"), old_commit);
 
 	/* Clean up objects used, as they will be reused. */
-	clear_commit_marks_all(ALL_REV_FLAGS);
+	clear_commit_marks_all(r, ALL_REV_FLAGS);
 }
 
 static int switch_branches(const struct checkout_opts *opts,
diff --git a/object.c b/object.c
index 804488c8dd..2bc08d8df7 100644
--- a/object.c
+++ b/object.c
@@ -443,12 +443,12 @@  void clear_object_flags(struct repository *r, unsigned flags)
 	}
 }
 
-void clear_commit_marks_all(unsigned int flags)
+void clear_commit_marks_all(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;
 	}
diff --git a/object.h b/object.h
index bfc95e062a..b0f0bce0a3 100644
--- a/object.h
+++ b/object.h
@@ -190,6 +190,6 @@  void clear_object_flags(struct repository *, unsigned flags);
 /*
  * Clear the specified object flags from all in-core commit objects.
  */
-void clear_commit_marks_all(unsigned int flags);
+void clear_commit_marks_all(struct repository *, unsigned int flags);
 
 #endif /* OBJECT_H */