All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Parth Gala via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Parth Gala <parthpgala@gmail.com>, Parth Gala <parthpgala@gmail.com>
Subject: [PATCH 3/5] object.c: parse_object_or_die() accept 'r' as parameter
Date: Wed, 12 Feb 2020 19:19:09 +0000	[thread overview]
Message-ID: <ef8ec98181ff03d756be80f1d3796eda98c7f475.1581535151.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.545.git.1581535151.gitgitgadget@gmail.com>

From: Parth Gala <parthpgala@gmail.com>

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

Signed-off-by: Parth Gala <parthpgala@gmail.com>
---
 builtin/grep.c  | 6 ++++--
 builtin/prune.c | 3 ++-
 bundle.c        | 8 +++++---
 object.c        | 4 ++--
 object.h        | 2 +-
 pack-bitmap.c   | 5 +++--
 reachable.c     | 6 ++++--
 upload-pack.c   | 4 +++-
 8 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/builtin/grep.c b/builtin/grep.c
index 50ce8d9461..c4156b0560 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -406,6 +406,7 @@ static int grep_submodule(struct grep_opt *opt,
 			  const char *filename, const char *path, int cached)
 {
 	struct repository subrepo;
+	struct repository *r = the_repository;
 	struct repository *superproject = opt->repo;
 	const struct submodule *sub = submodule_from_path(superproject,
 							  &null_oid, path);
@@ -455,7 +456,7 @@ static int grep_submodule(struct grep_opt *opt,
 		unsigned long size;
 		struct strbuf base = STRBUF_INIT;
 
-		object = parse_object_or_die(oid, oid_to_hex(oid));
+		object = parse_object_or_die(r, oid, oid_to_hex(oid));
 
 		grep_read_lock();
 		data = read_object_with_reference(&subrepo,
@@ -802,6 +803,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
 	const char *show_in_pager = NULL, *default_pager = "dummy";
 	struct grep_opt opt;
 	struct object_array list = OBJECT_ARRAY_INIT;
+	struct repository *r = the_repository;
 	struct pathspec pathspec;
 	struct string_list path_list = STRING_LIST_INIT_NODUP;
 	int i;
@@ -1037,7 +1039,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
 			break;
 		}
 
-		object = parse_object_or_die(&oid, arg);
+		object = parse_object_or_die(r, &oid, arg);
 		if (!seen_dashdash)
 			verify_non_filename(prefix, arg);
 		add_object_array_with_path(object, arg, &list, oc.mode, oc.path);
diff --git a/builtin/prune.c b/builtin/prune.c
index 2b76872ad2..6d478717ef 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -125,6 +125,7 @@ static void remove_temporary_files(const char *path)
 int cmd_prune(int argc, const char **argv, const char *prefix)
 {
 	struct rev_info revs;
+	struct repository *r = the_repository;
 	int exclude_promisor_objects = 0;
 	const struct option options[] = {
 		OPT__DRY_RUN(&show_only, N_("do not remove, show only")),
@@ -154,7 +155,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
 		const char *name = *argv++;
 
 		if (!get_oid(name, &oid)) {
-			struct object *object = parse_object_or_die(&oid,
+			struct object *object = parse_object_or_die(r, &oid,
 								    name);
 			add_pending_object(&revs, object, "");
 		}
diff --git a/bundle.c b/bundle.c
index 99439e07a1..26231f2a38 100644
--- a/bundle.c
+++ b/bundle.c
@@ -298,6 +298,7 @@ static int compute_and_write_prerequisites(int bundle_fd,
 {
 	struct child_process rls = CHILD_PROCESS_INIT;
 	struct strbuf buf = STRBUF_INIT;
+	struct repository *r = the_repository;
 	FILE *rls_fout;
 	int i;
 
@@ -316,13 +317,13 @@ static int compute_and_write_prerequisites(int bundle_fd,
 		if (buf.len > 0 && buf.buf[0] == '-') {
 			write_or_die(bundle_fd, buf.buf, buf.len);
 			if (!get_oid_hex(buf.buf + 1, &oid)) {
-				struct object *object = parse_object_or_die(&oid,
+				struct object *object = parse_object_or_die(r, &oid,
 									    buf.buf);
 				object->flags |= UNINTERESTING;
 				add_pending_object(revs, object, buf.buf);
 			}
 		} else if (!get_oid_hex(buf.buf, &oid)) {
-			struct object *object = parse_object_or_die(&oid,
+			struct object *object = parse_object_or_die(r, &oid,
 								    buf.buf);
 			object->flags |= SHOWN;
 		}
@@ -347,6 +348,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
 {
 	int i;
 	int ref_count = 0;
+	struct repository *r = the_repository;
 
 	for (i = 0; i < revs->pending.nr; i++) {
 		struct object_array_entry *e = revs->pending.objects + i;
@@ -407,7 +409,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
 				 * end up triggering "empty bundle"
 				 * error.
 				 */
-				obj = parse_object_or_die(&oid, e->name);
+				obj = parse_object_or_die(r, &oid, e->name);
 				obj->flags |= SHOWN;
 				add_pending_object(revs, obj, e->name);
 			}
diff --git a/object.c b/object.c
index 90338a509c..0a7a278c88 100644
--- a/object.c
+++ b/object.c
@@ -236,10 +236,10 @@ struct object *parse_object_buffer(struct repository *r, const struct object_id
 	return obj;
 }
 
-struct object *parse_object_or_die(const struct object_id *oid,
+struct object *parse_object_or_die(struct repository *r, const struct object_id *oid,
 				   const char *name)
 {
-	struct object *o = parse_object(the_repository, oid);
+	struct object *o = parse_object(r, oid);
 	if (o)
 		return o;
 
diff --git a/object.h b/object.h
index 375236cec3..92af2ead8f 100644
--- a/object.h
+++ b/object.h
@@ -135,7 +135,7 @@ struct object *parse_object(struct repository *r, const struct object_id *oid);
  * "name" parameter is not NULL, it is included in the error message
  * (otherwise, the hex object ID is given).
  */
-struct object *parse_object_or_die(const struct object_id *oid, const char *name);
+struct object *parse_object_or_die(struct repository *, const struct object_id *oid, const char *name);
 
 /* Given the result of read_sha1_file(), returns the object after
  * parsing it.  eaten_p indicates if the object has a borrowed copy
diff --git a/pack-bitmap.c b/pack-bitmap.c
index e07c798879..b7f9aebc7b 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -682,6 +682,7 @@ static int in_bitmapped_pack(struct bitmap_index *bitmap_git,
 struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs)
 {
 	unsigned int i;
+	struct repository *r = the_repository;
 
 	struct object_list *wants = NULL;
 	struct object_list *haves = NULL;
@@ -699,7 +700,7 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs)
 		struct object *object = revs->pending.objects[i].item;
 
 		if (object->type == OBJ_NONE)
-			parse_object_or_die(&object->oid, NULL);
+			parse_object_or_die(r, &object->oid, NULL);
 
 		while (object->type == OBJ_TAG) {
 			struct tag *tag = (struct tag *) object;
@@ -709,7 +710,7 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs)
 			else
 				object_list_insert(object, &wants);
 
-			object = parse_object_or_die(get_tagged_oid(tag), NULL);
+			object = parse_object_or_die(r, get_tagged_oid(tag), NULL);
 		}
 
 		if (object->flags & UNINTERESTING)
diff --git a/reachable.c b/reachable.c
index 8f50235b28..c661a1c892 100644
--- a/reachable.c
+++ b/reachable.c
@@ -31,13 +31,14 @@ static int add_one_ref(const char *path, const struct object_id *oid,
 {
 	struct rev_info *revs = (struct rev_info *)cb_data;
 	struct object *object;
+	struct repository *r = the_repository;
 
 	if ((flag & REF_ISSYMREF) && (flag & REF_ISBROKEN)) {
 		warning("symbolic ref is dangling: %s", path);
 		return 0;
 	}
 
-	object = parse_object_or_die(oid, path);
+	object = parse_object_or_die(r, oid, path);
 	add_pending_object(revs, object, "");
 
 	return 0;
@@ -68,6 +69,7 @@ static void add_recent_object(const struct object_id *oid,
 {
 	struct object *obj;
 	enum object_type type;
+	struct repository *r = the_repository;
 
 	if (mtime <= data->timestamp)
 		return;
@@ -86,7 +88,7 @@ static void add_recent_object(const struct object_id *oid,
 	switch (type) {
 	case OBJ_TAG:
 	case OBJ_COMMIT:
-		obj = parse_object_or_die(oid, NULL);
+		obj = parse_object_or_die(r, oid, NULL);
 		break;
 	case OBJ_TREE:
 		obj = (struct object *)lookup_tree(the_repository, oid);
diff --git a/upload-pack.c b/upload-pack.c
index 6d196e275b..daea9059f0 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -1210,6 +1210,8 @@ static int parse_want_ref(struct packet_writer *writer, const char *line,
 			  struct object_array *want_obj)
 {
 	const char *arg;
+	struct repository *r = the_repository;
+
 	if (skip_prefix(line, "want-ref ", &arg)) {
 		struct object_id oid;
 		struct string_list_item *item;
@@ -1223,7 +1225,7 @@ static int parse_want_ref(struct packet_writer *writer, const char *line,
 		item = string_list_append(wanted_refs, arg);
 		item->util = oiddup(&oid);
 
-		o = parse_object_or_die(&oid, arg);
+		o = parse_object_or_die(r, &oid, arg);
 		if (!(o->flags & WANTED)) {
 			o->flags |= WANTED;
 			add_object_array(o, NULL, want_obj);
-- 
gitgitgadget


  parent reply	other threads:[~2020-02-12 19:19 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-12 19:19 [PATCH 0/5] object.c: localize global the_repository variable into r Parth Gala via GitGitGadget
2020-02-12 19:19 ` [PATCH 1/5] object.c: get_max_object_index and get_indexed_object accept 'r' parameter Parth Gala via GitGitGadget
2020-02-12 20:22   ` Taylor Blau
2020-02-12 21:13     ` Eric Sunshine
2020-02-13  5:23     ` parth gala
2020-02-12 19:19 ` [PATCH 2/5] object.c: lookup_unknown_object() accept 'r' as parameter Parth Gala via GitGitGadget
2020-02-12 20:25   ` Taylor Blau
2020-02-12 21:11     ` Junio C Hamano
2020-02-13 18:00       ` Taylor Blau
2020-02-13 18:10         ` Junio C Hamano
2020-02-13 18:52           ` Jeff King
2020-02-15  0:00             ` Taylor Blau
2020-02-12 19:19 ` Parth Gala via GitGitGadget [this message]
2020-02-12 19:19 ` [PATCH 4/5] object.c: clear_object_flags() " Parth Gala via GitGitGadget
2020-02-12 19:19 ` [PATCH 5/5] object.c: clear_commit_marks_all() " Parth Gala via GitGitGadget
2020-02-12 20:18 ` [PATCH 0/5] object.c: localize global the_repository variable into r Taylor Blau
2020-02-13  5:14   ` parth gala

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ef8ec98181ff03d756be80f1d3796eda98c7f475.1581535151.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=parthpgala@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.