diff mbox series

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

Message ID a8202cc5353d274f6278f2350ae1371af0a093d5.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

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

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

Signed-off-by: Parth Gala <parthpgala@gmail.com>
---
 builtin/log.c | 3 ++-
 object.c      | 6 +++---
 object.h      | 2 +-
 revision.c    | 3 ++-
 shallow.c     | 3 ++-
 upload-pack.c | 2 +-
 6 files changed, 11 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/builtin/log.c b/builtin/log.c
index 83a4a6188e..b163d2fbdf 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1592,6 +1592,7 @@  int cmd_format_patch(int argc, const char **argv, const char *prefix)
 {
 	struct commit *commit;
 	struct commit **list = NULL;
+	struct repository *r = the_repository;
 	struct rev_info rev;
 	struct setup_revision_opt s_r_opt;
 	int nr = 0, total, i;
@@ -1998,7 +1999,7 @@  int cmd_format_patch(int argc, const char **argv, const char *prefix)
 	if (base_commit) {
 		struct commit *base = get_base_commit(base_commit, list, nr);
 		reset_revision_walk();
-		clear_object_flags(UNINTERESTING);
+		clear_object_flags(r, UNINTERESTING);
 		prepare_bases(&bases, base, list, nr);
 	}
 
diff --git a/object.c b/object.c
index 0a7a278c88..804488c8dd 100644
--- a/object.c
+++ b/object.c
@@ -432,12 +432,12 @@  void object_array_remove_duplicates(struct object_array *array)
 	}
 }
 
-void clear_object_flags(unsigned flags)
+void clear_object_flags(struct repository *r, unsigned 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->flags &= ~flags;
 	}
diff --git a/object.h b/object.h
index 92af2ead8f..bfc95e062a 100644
--- a/object.h
+++ b/object.h
@@ -185,7 +185,7 @@  void object_array_remove_duplicates(struct object_array *array);
  */
 void object_array_clear(struct object_array *array);
 
-void clear_object_flags(unsigned flags);
+void clear_object_flags(struct repository *, unsigned flags);
 
 /*
  * Clear the specified object flags from all in-core commit objects.
diff --git a/revision.c b/revision.c
index 8136929e23..ac32ecf2e2 100644
--- a/revision.c
+++ b/revision.c
@@ -3086,7 +3086,8 @@  static void set_children(struct rev_info *revs)
 
 void reset_revision_walk(void)
 {
-	clear_object_flags(SEEN | ADDED | SHOWN | TOPO_WALK_EXPLORED | TOPO_WALK_INDEGREE);
+	struct repository *r = the_repository;
+	clear_object_flags(r, SEEN | ADDED | SHOWN | TOPO_WALK_EXPLORED | TOPO_WALK_INDEGREE);
 }
 
 static int mark_uninteresting(const struct object_id *oid,
diff --git a/shallow.c b/shallow.c
index 4537d98482..d32adbe088 100644
--- a/shallow.c
+++ b/shallow.c
@@ -180,6 +180,7 @@  struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,
 {
 	struct commit_list *result = NULL, *p;
 	struct commit_list *not_shallow_list = NULL;
+	struct repository *r = the_repository;
 	struct rev_info revs;
 	int both_flags = shallow_flag | not_shallow_flag;
 
@@ -187,7 +188,7 @@  struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,
 	 * SHALLOW (excluded) and NOT_SHALLOW (included) should not be
 	 * set at this point. But better be safe than sorry.
 	 */
-	clear_object_flags(both_flags);
+	clear_object_flags(r, both_flags);
 
 	is_repository_shallow(the_repository); /* make sure shallows are read */
 
diff --git a/upload-pack.c b/upload-pack.c
index daea9059f0..e296f2cfa8 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -1472,7 +1472,7 @@  int upload_pack_v2(struct repository *r, struct argv_array *keys,
 	struct object_array have_obj = OBJECT_ARRAY_INIT;
 	struct object_array want_obj = OBJECT_ARRAY_INIT;
 
-	clear_object_flags(ALL_FLAGS);
+	clear_object_flags(r, ALL_FLAGS);
 
 	git_config(upload_pack_config, NULL);