From: Stefan Beller <sbeller@google.com>
To: git@vger.kernel.org
Cc: Stefan Beller <sbeller@google.com>, Jonathan Nieder <jrnieder@gmail.com>
Subject: [PATCH 06/35] blob: add repository argument to lookup_blob
Date: Tue, 29 May 2018 17:47:41 -0700 [thread overview]
Message-ID: <20180530004810.30076-7-sbeller@google.com> (raw)
In-Reply-To: <20180530004810.30076-1-sbeller@google.com>
Add a repository argument to allow the callers of lookup_blob
to be more specific about which repository to act on. 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.
Add the cocci patch that converted the callers.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
blob.c | 2 +-
blob.h | 3 ++-
builtin/fast-export.c | 2 +-
builtin/fsck.c | 3 ++-
builtin/index-pack.c | 2 +-
builtin/merge-tree.c | 3 ++-
builtin/unpack-objects.c | 2 +-
fsck.c | 2 +-
http-push.c | 3 ++-
list-objects.c | 2 +-
object.c | 4 ++--
reachable.c | 2 +-
revision.c | 4 ++--
tag.c | 2 +-
walker.c | 3 ++-
15 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/blob.c b/blob.c
index dada295698c..17b9314f0a0 100644
--- a/blob.c
+++ b/blob.c
@@ -5,7 +5,7 @@
const char *blob_type = "blob";
-struct blob *lookup_blob(const struct object_id *oid)
+struct blob *lookup_blob_the_repository(const struct object_id *oid)
{
struct object *obj = lookup_object(the_repository, oid->hash);
if (!obj)
diff --git a/blob.h b/blob.h
index 44606168310..08bc34487a0 100644
--- a/blob.h
+++ b/blob.h
@@ -9,7 +9,8 @@ struct blob {
struct object object;
};
-struct blob *lookup_blob(const struct object_id *oid);
+#define lookup_blob(r, o) lookup_blob_##r(o)
+struct blob *lookup_blob_the_repository(const struct object_id *oid);
int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size);
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index a34ab9768f4..23ca46e6008 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -237,7 +237,7 @@ static void export_blob(const struct object_id *oid)
if (anonymize) {
buf = anonymize_blob(&size);
- object = (struct object *)lookup_blob(oid);
+ object = (struct object *)lookup_blob(the_repository, oid);
eaten = 0;
} else {
buf = read_object_file(oid, &type, &size);
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 82a5acaf76e..6e2b204e938 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -808,7 +808,8 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
mode = active_cache[i]->ce_mode;
if (S_ISGITLINK(mode))
continue;
- blob = lookup_blob(&active_cache[i]->oid);
+ blob = lookup_blob(the_repository,
+ &active_cache[i]->oid);
if (!blob)
continue;
obj = &blob->object;
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 0dd10693597..51c5244a15a 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -832,7 +832,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
if (strict || do_fsck_object) {
read_lock();
if (type == OBJ_BLOB) {
- struct blob *blob = lookup_blob(oid);
+ struct blob *blob = lookup_blob(the_repository, oid);
if (blob)
blob->object.flags |= FLAG_CHECKED;
else
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index 8a8d5797520..f8023bae1e2 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -2,6 +2,7 @@
#include "tree-walk.h"
#include "xdiff-interface.h"
#include "object-store.h"
+#include "repository.h"
#include "blob.h"
#include "exec-cmd.h"
#include "merge-blobs.h"
@@ -170,7 +171,7 @@ static struct merge_list *create_entry(unsigned stage, unsigned mode, const stru
res->stage = stage;
res->path = path;
res->mode = mode;
- res->blob = lookup_blob(oid);
+ res->blob = lookup_blob(the_repository, oid);
return res;
}
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 8e454c48649..dfea7790fde 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -254,7 +254,7 @@ static void write_object(unsigned nr, enum object_type type,
added_object(nr, type, buf, size);
free(buf);
- blob = lookup_blob(&obj_list[nr].oid);
+ blob = lookup_blob(the_repository, &obj_list[nr].oid);
if (blob)
blob->object.flags |= FLAG_WRITTEN;
else
diff --git a/fsck.c b/fsck.c
index f9476f56e93..2d372f2a3f3 100644
--- a/fsck.c
+++ b/fsck.c
@@ -367,7 +367,7 @@ static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *op
result = options->walk(obj, OBJ_TREE, data, options);
}
else if (S_ISREG(entry.mode) || S_ISLNK(entry.mode)) {
- obj = (struct object *)lookup_blob(entry.oid);
+ obj = (struct object *)lookup_blob(the_repository, entry.oid);
if (name && obj)
put_object_name(options, obj, "%s%s", name,
entry.path);
diff --git a/http-push.c b/http-push.c
index 04d95bd5da8..730e9cd0667 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1314,7 +1314,8 @@ static struct object_list **process_tree(struct tree *tree,
p = process_tree(lookup_tree(entry.oid), p);
break;
case OBJ_BLOB:
- p = process_blob(lookup_blob(entry.oid), p);
+ p = process_blob(lookup_blob(the_repository, entry.oid),
+ p);
break;
default:
/* Subproject commit - not in this repository */
diff --git a/list-objects.c b/list-objects.c
index 7ae0eb8ebc7..56682c2a441 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -167,7 +167,7 @@ static void process_tree(struct rev_info *revs,
cb_data);
else
process_blob(revs,
- lookup_blob(entry.oid),
+ lookup_blob(the_repository, entry.oid),
show, base, entry.path,
cb_data, filter_fn, filter_data);
}
diff --git a/object.c b/object.c
index bd5df7d007a..80a8e44832f 100644
--- a/object.c
+++ b/object.c
@@ -193,7 +193,7 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e
obj = NULL;
if (type == OBJ_BLOB) {
- struct blob *blob = lookup_blob(oid);
+ struct blob *blob = lookup_blob(the_repository, oid);
if (blob) {
if (parse_blob_buffer(blob, buffer, size))
return NULL;
@@ -266,7 +266,7 @@ struct object *parse_object_the_repository(const struct object_id *oid)
error("sha1 mismatch %s", oid_to_hex(oid));
return NULL;
}
- parse_blob_buffer(lookup_blob(oid), NULL, 0);
+ parse_blob_buffer(lookup_blob(the_repository, oid), NULL, 0);
return lookup_object(the_repository, oid->hash);
}
diff --git a/reachable.c b/reachable.c
index 2ee55695595..cc25f012e5d 100644
--- a/reachable.c
+++ b/reachable.c
@@ -91,7 +91,7 @@ static void add_recent_object(const struct object_id *oid,
obj = (struct object *)lookup_tree(oid);
break;
case OBJ_BLOB:
- obj = (struct object *)lookup_blob(oid);
+ obj = (struct object *)lookup_blob(the_repository, oid);
break;
default:
die("unknown object type for %s: %s",
diff --git a/revision.c b/revision.c
index f051c6c5806..aeccbf5fe24 100644
--- a/revision.c
+++ b/revision.c
@@ -69,7 +69,7 @@ static void mark_tree_contents_uninteresting(struct tree *tree)
mark_tree_uninteresting(lookup_tree(entry.oid));
break;
case OBJ_BLOB:
- mark_blob_uninteresting(lookup_blob(entry.oid));
+ mark_blob_uninteresting(lookup_blob(the_repository, entry.oid));
break;
default:
/* Subproject commit - not in this repository */
@@ -1338,7 +1338,7 @@ static void do_add_index_objects_to_pending(struct rev_info *revs,
if (S_ISGITLINK(ce->ce_mode))
continue;
- blob = lookup_blob(&ce->oid);
+ blob = lookup_blob(the_repository, &ce->oid);
if (!blob)
die("unable to add index blob to traversal");
add_pending_object_with_path(revs, &blob->object, "",
diff --git a/tag.c b/tag.c
index a14a4f23037..a31ae75e960 100644
--- a/tag.c
+++ b/tag.c
@@ -154,7 +154,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)
bufptr = nl + 1;
if (!strcmp(type, blob_type)) {
- item->tagged = (struct object *)lookup_blob(&oid);
+ item->tagged = (struct object *)lookup_blob(the_repository, &oid);
} else if (!strcmp(type, tree_type)) {
item->tagged = (struct object *)lookup_tree(&oid);
} else if (!strcmp(type, commit_type)) {
diff --git a/walker.c b/walker.c
index aea96f0eaff..a36f53f37be 100644
--- a/walker.c
+++ b/walker.c
@@ -54,7 +54,8 @@ static int process_tree(struct walker *walker, struct tree *tree)
obj = &tree->object;
}
else {
- struct blob *blob = lookup_blob(entry.oid);
+ struct blob *blob = lookup_blob(the_repository,
+ entry.oid);
if (blob)
obj = &blob->object;
}
--
2.17.0.582.gccdcbd54c44.dirty
next prev 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 ` [PATCH 03/35] object: add repository argument to lookup_unknown_object Stefan Beller
2018-05-30 18:29 ` 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 ` Stefan Beller [this message]
2018-05-30 18:36 ` [PATCH 06/35] blob: add repository argument to lookup_blob 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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180530004810.30076-7-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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).