All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Beller <sbeller@google.com>
To: git@vger.kernel.org
Cc: Jonathan Nieder <jrnieder@gmail.com>, Stefan Beller <sbeller@google.com>
Subject: [PATCH 03/35] object: add repository argument to lookup_unknown_object
Date: Tue, 29 May 2018 17:47:38 -0700	[thread overview]
Message-ID: <20180530004810.30076-4-sbeller@google.com> (raw)
In-Reply-To: <20180530004810.30076-1-sbeller@google.com>

From: Jonathan Nieder <jrnieder@gmail.com>

Add a repository argument to allow callers of lookup_unknown_object to
be more specific about which repository to handle. This is a small
mechanical change; it doesn't change the implementation to handle
repositories other than the_repository yet.

As with the previous commits, use a macro to catch callers passing a
repository other than the_repository at compile time.

The included coccinelle semantic patch will adapt any new callers in
the diff produced by `make coccicheck`.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
 builtin/fsck.c                   | 2 +-
 builtin/pack-objects.c           | 2 +-
 http-push.c                      | 2 +-
 object.c                         | 2 +-
 object.h                         | 3 ++-
 refs.c                           | 2 +-
 t/helper/test-example-decorate.c | 6 +++---
 upload-pack.c                    | 2 +-
 walker.c                         | 2 +-
 9 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/builtin/fsck.c b/builtin/fsck.c
index 98fdeef5407..700739804fc 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -638,7 +638,7 @@ static int fsck_cache_tree(struct cache_tree *it)
 
 static void mark_object_for_connectivity(const struct object_id *oid)
 {
-	struct object *obj = lookup_unknown_object(oid->hash);
+	struct object *obj = lookup_unknown_object(the_repository, oid->hash);
 	obj->flags |= HAS_OBJ;
 }
 
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 8c108109985..6eae39cf858 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -2689,7 +2689,7 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)
 
 		for (i = 0; i < p->num_objects; i++) {
 			nth_packed_object_oid(&oid, p, i);
-			o = lookup_unknown_object(oid.hash);
+			o = lookup_unknown_object(the_repository, oid.hash);
 			if (!(o->flags & OBJECT_ADDED))
 				mark_in_pack_object(o, p, &in_pack);
 			o->flags |= OBJECT_ADDED;
diff --git a/http-push.c b/http-push.c
index 2615c823d60..04d95bd5da8 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1429,7 +1429,7 @@ static void one_remote_ref(const char *refname)
 	 * may be required for updating server info later.
 	 */
 	if (repo->can_update_info_refs && !has_object_file(&ref->old_oid)) {
-		obj = lookup_unknown_object(ref->old_oid.hash);
+		obj = lookup_unknown_object(the_repository, ref->old_oid.hash);
 		fprintf(stderr,	"  fetch %s for %s\n",
 			oid_to_hex(&ref->old_oid), refname);
 		add_fetch_request(obj);
diff --git a/object.c b/object.c
index 4de4fa58d59..def3c71cac2 100644
--- a/object.c
+++ b/object.c
@@ -177,7 +177,7 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet)
 	}
 }
 
-struct object *lookup_unknown_object(const unsigned char *sha1)
+struct object *lookup_unknown_object_the_repository(const unsigned char *sha1)
 {
 	struct object *obj = lookup_object(the_repository, sha1);
 	if (!obj)
diff --git a/object.h b/object.h
index fa41d711f44..778f83bf0f7 100644
--- a/object.h
+++ b/object.h
@@ -139,7 +139,8 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *name
 struct object *parse_object_buffer(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p);
 
 /** Returns the object, with potentially excess memory allocated. **/
-struct object *lookup_unknown_object(const unsigned  char *sha1);
+#define lookup_unknown_object(r, s) lookup_unknown_object_##r(s)
+struct object *lookup_unknown_object_the_repository(const unsigned char *sha1);
 
 struct object_list *object_list_insert(struct object *item,
 				       struct object_list **list_p);
diff --git a/refs.c b/refs.c
index 23d53957deb..3b9e8463656 100644
--- a/refs.c
+++ b/refs.c
@@ -301,7 +301,7 @@ static int filter_refs(const char *refname, const struct object_id *oid,
 
 enum peel_status peel_object(const struct object_id *name, struct object_id *oid)
 {
-	struct object *o = lookup_unknown_object(name->hash);
+	struct object *o = lookup_unknown_object(the_repository, name->hash);
 
 	if (o->type == OBJ_NONE) {
 		int type = oid_object_info(the_repository, name, NULL);
diff --git a/t/helper/test-example-decorate.c b/t/helper/test-example-decorate.c
index 081115bf8eb..33e727f7fc5 100644
--- a/t/helper/test-example-decorate.c
+++ b/t/helper/test-example-decorate.c
@@ -26,8 +26,8 @@ int cmd__example_decorate(int argc, const char **argv)
 	 * Add 2 objects, one with a non-NULL decoration and one with a NULL
 	 * decoration.
 	 */
-	one = lookup_unknown_object(one_oid.hash);
-	two = lookup_unknown_object(two_oid.hash);
+	one = lookup_unknown_object(the_repository, one_oid.hash);
+	two = lookup_unknown_object(the_repository, two_oid.hash);
 	ret = add_decoration(&n, one, &decoration_a);
 	if (ret)
 		die("BUG: when adding a brand-new object, NULL should be returned");
@@ -56,7 +56,7 @@ int cmd__example_decorate(int argc, const char **argv)
 	ret = lookup_decoration(&n, two);
 	if (ret != &decoration_b)
 		die("BUG: lookup should return added declaration");
-	three = lookup_unknown_object(three_oid.hash);
+	three = lookup_unknown_object(the_repository, three_oid.hash);
 	ret = lookup_decoration(&n, three);
 	if (ret)
 		die("BUG: lookup for unknown object should return NULL");
diff --git a/upload-pack.c b/upload-pack.c
index 20e61180e48..aebab6f3277 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -971,7 +971,7 @@ static void receive_needs(void)
 static int mark_our_ref(const char *refname, const char *refname_full,
 			const struct object_id *oid)
 {
-	struct object *o = lookup_unknown_object(oid->hash);
+	struct object *o = lookup_unknown_object(the_repository, oid->hash);
 
 	if (ref_is_hidden(refname, refname_full)) {
 		o->flags |= HIDDEN_REF;
diff --git a/walker.c b/walker.c
index 3678e344312..aea96f0eaff 100644
--- a/walker.c
+++ b/walker.c
@@ -282,7 +282,7 @@ int walker_fetch(struct walker *walker, int targets, char **target,
 			error("Could not interpret response from server '%s' as something to pull", target[i]);
 			goto done;
 		}
-		if (process(walker, lookup_unknown_object(oids[i].hash)))
+		if (process(walker, lookup_unknown_object(the_repository, oids[i].hash)))
 			goto done;
 	}
 
-- 
2.17.0.582.gccdcbd54c44.dirty


  parent reply	other threads:[~2018-05-30  0:48 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-30  0:47 [RFC PATCH 00/35] object-store: lookup_commit Stefan Beller
2018-05-30  0:47 ` [PATCH 01/35] object: add repository argument to parse_object Stefan Beller
2018-05-30  0:47 ` [PATCH 02/35] object: add repository argument to lookup_object Stefan Beller
2018-05-30  0:47 ` Stefan Beller [this message]
2018-05-30 18:29   ` [PATCH 03/35] object: add repository argument to lookup_unknown_object Derrick Stolee
2018-06-06 19:38   ` Duy Nguyen
2018-06-13 19:30     ` Stefan Beller
2018-06-14  1:17       ` Derrick Stolee
2018-05-30  0:47 ` [PATCH 04/35] object: add repository argument to parse_object_buffer Stefan Beller
2018-05-30 18:34   ` Derrick Stolee
2018-05-30  0:47 ` [PATCH 05/35] object: add repository argument to object_as_type Stefan Beller
2018-05-30  0:47 ` [PATCH 06/35] blob: add repository argument to lookup_blob Stefan Beller
2018-05-30 18:36   ` Derrick Stolee
2018-05-30  0:47 ` [PATCH 07/35] tree: add repository argument to lookup_tree Stefan Beller
2018-06-06 19:26   ` Duy Nguyen
2018-05-30  0:47 ` [PATCH 08/35] commit: add repository argument to lookup_commit_reference_gently Stefan Beller
2018-05-30  0:47 ` [PATCH 09/35] commit: add repository argument to lookup_commit_reference Stefan Beller
2018-05-30  0:47 ` [PATCH 10/35] commit: add repository argument to lookup_commit Stefan Beller
2018-06-14 16:22   ` Duy Nguyen
2018-06-14 21:15     ` Stefan Beller
2018-06-14 21:24       ` Brandon Williams
2018-05-30  0:47 ` [PATCH 11/35] commit: add repository argument to parse_commit_buffer Stefan Beller
2018-05-30  0:47 ` [PATCH 12/35] commit: add repository argument to set_commit_buffer Stefan Beller
2018-05-30  0:47 ` [PATCH 13/35] commit: add repository argument to get_cached_commit_buffer Stefan Beller
2018-05-30  0:47 ` [PATCH 14/35] tag: add repository argument to lookup_tag Stefan Beller
2018-05-30  0:47 ` [PATCH 15/35] tag: add repository argument to parse_tag_buffer Stefan Beller
2018-05-30  0:47 ` [PATCH 16/35] tag: add repository argument to deref_tag Stefan Beller
2018-05-30  0:47 ` [PATCH 17/35] object: add repository argument to parse_commit_gently Stefan Beller
2018-05-30  0:47 ` [PATCH 18/35] commit: add repository argument to parse_commit Stefan Beller
2018-05-30  0:47 ` [PATCH 19/35] object: allow object_as_type to handle arbitrary repositories Stefan Beller
2018-05-30  0:47 ` [PATCH 20/35] object: allow lookup_object " Stefan Beller
2018-05-30  0:47 ` [PATCH 21/35] blob: allow lookup_blob " Stefan Beller
2018-05-30  0:47 ` [PATCH 22/35] tree: allow lookup_tree " Stefan Beller
2018-05-30  0:47 ` [PATCH 23/35] commit: allow lookup_commit " Stefan Beller
2018-05-30  0:47 ` [PATCH 24/35] tag: allow lookup_tag " Stefan Beller
2018-05-30  0:48 ` [PATCH 25/35] tag: allow parse_tag_buffer " Stefan Beller
2018-05-30  0:48 ` [PATCH 26/35] commit.c: allow parse_commit_buffer " Stefan Beller
2018-05-30  0:48 ` [PATCH 27/35] commit-slabs: remove realloc counter outside of slab struct Stefan Beller
2018-05-30 19:00   ` Derrick Stolee
2018-05-30  0:48 ` [PATCH 28/35] commit.c: migrate the commit buffer to the parsed object store Stefan Beller
2018-06-06 19:31   ` Duy Nguyen
2018-06-13 20:55     ` Stefan Beller
2018-05-30  0:48 ` [PATCH 29/35] commit.c: allow set_commit_buffer to handle arbitrary repositories Stefan Beller
2018-05-30  0:48 ` [PATCH 30/35] commit.c: allow get_cached_commit_buffer " Stefan Beller
2018-05-30  0:48 ` [PATCH 31/35] object.c: allow parse_object_buffer " Stefan Beller
2018-05-30  0:48 ` [PATCH 32/35] object.c: allow parse_object " Stefan Beller
2018-05-30  0:48 ` [PATCH 33/35] tag.c: allow deref_tag " Stefan Beller
2018-05-30  0:48 ` [PATCH 34/35] commit.c: allow lookup_commit_reference_gently " Stefan Beller
2018-05-30  0:48 ` [PATCH 35/35] commit.c: allow lookup_commit_reference " Stefan Beller
2018-05-30  1:05 ` [RFC PATCH 00/35] object-store: lookup_commit Derrick Stolee
2018-05-30  3:18   ` Stefan Beller
2018-05-30 19:18     ` Derrick Stolee
2018-05-30 22:19       ` Stefan Beller
2018-06-13 23:04 ` [PATCH v2 00/31] " Stefan Beller
2018-06-13 23:04   ` [PATCH v2 01/31] object: add repository argument to lookup_object Stefan Beller
2018-06-13 23:04   ` [PATCH v2 02/31] object: add repository argument to parse_object_buffer Stefan Beller
2018-06-13 23:04   ` [PATCH v2 03/31] object: add repository argument to object_as_type Stefan Beller
2018-06-13 23:04   ` [PATCH v2 04/31] blob: add repository argument to lookup_blob Stefan Beller
2018-06-13 23:04   ` [PATCH v2 05/31] tree: add repository argument to lookup_tree Stefan Beller
2018-06-14 17:55     ` Derrick Stolee
2018-06-14 19:33       ` Derrick Stolee
2018-06-14 21:31         ` Stefan Beller
2018-06-13 23:04   ` [PATCH v2 06/31] commit: add repository argument to lookup_commit_reference_gently Stefan Beller
2018-06-13 23:04   ` [PATCH v2 07/31] commit: add repository argument to lookup_commit_reference Stefan Beller
2018-06-13 23:04   ` [PATCH v2 08/31] commit: add repository argument to lookup_commit Stefan Beller
2018-06-13 23:05   ` [PATCH v2 09/31] commit: add repository argument to parse_commit_buffer Stefan Beller
2018-06-13 23:05   ` [PATCH v2 10/31] commit: add repository argument to set_commit_buffer Stefan Beller
2018-06-13 23:05   ` [PATCH v2 11/31] commit: add repository argument to get_cached_commit_buffer Stefan Beller
2018-06-13 23:05   ` [PATCH v2 12/31] tag: add repository argument to lookup_tag Stefan Beller
2018-06-13 23:05   ` [PATCH v2 13/31] tag: add repository argument to parse_tag_buffer Stefan Beller
2018-06-13 23:05   ` [PATCH v2 14/31] tag: add repository argument to deref_tag Stefan Beller
2018-06-13 23:05   ` [PATCH v2 15/31] object: allow object_as_type to handle arbitrary repositories Stefan Beller
2018-06-13 23:05   ` [PATCH v2 16/31] object: allow lookup_object " Stefan Beller
2018-06-13 23:05   ` [PATCH v2 17/31] blob: allow lookup_blob " Stefan Beller
2018-06-13 23:05   ` [PATCH v2 18/31] tree: allow lookup_tree " Stefan Beller
2018-06-13 23:05   ` [PATCH v2 19/31] commit: allow lookup_commit " Stefan Beller
2018-06-13 23:05   ` [PATCH v2 20/31] tag: allow lookup_tag " Stefan Beller
2018-06-13 23:05   ` [PATCH v2 21/31] tag: allow parse_tag_buffer " Stefan Beller
2018-06-13 23:05   ` [PATCH v2 22/31] commit.c: allow parse_commit_buffer " Stefan Beller
2018-06-13 23:05   ` [PATCH v2 23/31] commit-slabs: remove realloc counter outside of slab struct Stefan Beller
2018-06-13 23:05   ` [PATCH v2 24/31] commit.c: migrate the commit buffer to the parsed object store Stefan Beller
2018-06-13 23:05   ` [PATCH v2 25/31] commit.c: allow set_commit_buffer to handle arbitrary repositories Stefan Beller
2018-06-13 23:05   ` [PATCH v2 26/31] commit.c: allow get_cached_commit_buffer " Stefan Beller
2018-06-13 23:05   ` [PATCH v2 27/31] object.c: allow parse_object_buffer " Stefan Beller
2018-06-13 23:05   ` [PATCH v2 28/31] object.c: allow parse_object " Stefan Beller
2018-06-13 23:05   ` [PATCH v2 29/31] tag.c: allow deref_tag " Stefan Beller
2018-06-13 23:05   ` [PATCH v2 30/31] commit.c: allow lookup_commit_reference_gently " Stefan Beller
2018-06-13 23:05   ` [PATCH v2 31/31] commit.c: allow lookup_commit_reference " Stefan Beller
2018-06-14  1:23   ` [PATCH v2 00/31] object-store: lookup_commit Derrick Stolee
2018-06-14  1:42     ` Derrick Stolee
2018-06-14 16:26   ` Duy Nguyen
2018-06-14 18:27   ` Brandon Williams

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=20180530004810.30076-4-sbeller@google.com \
    --to=sbeller@google.com \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@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.