Convert lookup_blob to struct object_id

Convert lookup_blob to take a pointer to struct object_id. The commit was created with manual changes to blob.c and blob.h, plus the following semantic patch: @@ expression E1; @@ - lookup_blob(E1.hash) + lookup_blob(&E1) @@ expression E1; @@ - lookup_blob(E1->hash) + lookup_blob(E1) Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed May 6, 2017 at 22:10 UTC 3aca1fc6c9c69fbfce0e6312fc8e3087cb6334a4
15 files changed +19 -19
blob.c
+3 -3
@@ -3,11 +3,11 @@
3
4 const char *blob_type = "blob";
5
6 -struct blob *lookup_blob(const unsigned char *sha1)
6 +struct blob *lookup_blob(const struct object_id *oid)
7 {
8 - struct object *obj = lookup_object(sha1);
8 + struct object *obj = lookup_object(oid->hash);
9 if (!obj)
10 - return create_object(sha1, alloc_blob_node());
10 + return create_object(oid->hash, alloc_blob_node());
11 return object_as_type(obj, OBJ_BLOB, 0);
12 }
13
blob.h
+1 -1
@@ -9,7 +9,7 @@ struct blob {
9 struct object object;
10 };
11
12 -struct blob *lookup_blob(const unsigned char *sha1);
12 +struct blob *lookup_blob(const struct object_id *oid);
13
14 int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size);
15
builtin/fast-export.c
+1 -1
@@ -232,7 +232,7 @@ static void export_blob(const struct object_id *oid)
232
233 if (anonymize) {
234 buf = anonymize_blob(&size);
235 - object = (struct object *)lookup_blob(oid->hash);
235 + object = (struct object *)lookup_blob(oid);
236 eaten = 0;
237 } else {
238 buf = read_sha1_file(oid->hash, &type, &size);
builtin/fsck.c
+1 -1
@@ -781,7 +781,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
781 mode = active_cache[i]->ce_mode;
782 if (S_ISGITLINK(mode))
783 continue;
784 - blob = lookup_blob(active_cache[i]->oid.hash);
784 + blob = lookup_blob(&active_cache[i]->oid);
785 if (!blob)
786 continue;
787 obj = &blob->object;
builtin/index-pack.c
+1 -1
@@ -829,7 +829,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
829 if (strict) {
830 read_lock();
831 if (type == OBJ_BLOB) {
832 - struct blob *blob = lookup_blob(oid->hash);
832 + struct blob *blob = lookup_blob(oid);
833 if (blob)
834 blob->object.flags |= FLAG_CHECKED;
835 else
builtin/merge-tree.c
+1 -1
@@ -168,7 +168,7 @@ static struct merge_list *create_entry(unsigned stage, unsigned mode, const stru
168 res->stage = stage;
169 res->path = path;
170 res->mode = mode;
171 - res->blob = lookup_blob(oid->hash);
171 + res->blob = lookup_blob(oid);
172 return res;
173 }
174
builtin/unpack-objects.c
+1 -1
@@ -249,7 +249,7 @@ static void write_object(unsigned nr, enum object_type type,
249 added_object(nr, type, buf, size);
250 free(buf);
251
252 - blob = lookup_blob(obj_list[nr].oid.hash);
252 + blob = lookup_blob(&obj_list[nr].oid);
253 if (blob)
254 blob->object.flags |= FLAG_WRITTEN;
255 else
fsck.c
+1 -1
@@ -365,7 +365,7 @@ static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *op
365 result = options->walk(obj, OBJ_TREE, data, options);
366 }
367 else if (S_ISREG(entry.mode) || S_ISLNK(entry.mode)) {
368 - obj = &lookup_blob(entry.oid->hash)->object;
368 + obj = &lookup_blob(entry.oid)->object;
369 if (name)
370 put_object_name(options, obj, "%s%s", name,
371 entry.path);
http-push.c
+1 -1
@@ -1315,7 +1315,7 @@ static struct object_list **process_tree(struct tree *tree,
1315 p = process_tree(lookup_tree(entry.oid->hash), p);
1316 break;
1317 case OBJ_BLOB:
1318 - p = process_blob(lookup_blob(entry.oid->hash), p);
1318 + p = process_blob(lookup_blob(entry.oid), p);
1319 break;
1320 default:
1321 /* Subproject commit - not in this repository */
list-objects.c
+1 -1
@@ -119,7 +119,7 @@ static void process_tree(struct rev_info *revs,
119 cb_data);
120 else
121 process_blob(revs,
122 - lookup_blob(entry.oid->hash),
122 + lookup_blob(entry.oid),
123 show, base, entry.path,
124 cb_data);
125 }
object.c
+2 -2
@@ -190,7 +190,7 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
190
191 obj = NULL;
192 if (type == OBJ_BLOB) {
193 - struct blob *blob = lookup_blob(oid.hash);
193 + struct blob *blob = lookup_blob(&oid);
194 if (blob) {
195 if (parse_blob_buffer(blob, buffer, size))
196 return NULL;
@@ -266,7 +266,7 @@ struct object *parse_object(const unsigned char *sha1)
266 error("sha1 mismatch %s", sha1_to_hex(repl));
267 return NULL;
268 }
269 - parse_blob_buffer(lookup_blob(oid.hash), NULL, 0);
269 + parse_blob_buffer(lookup_blob(&oid), NULL, 0);
270 return lookup_object(sha1);
271 }
272
reachable.c
+1 -1
@@ -88,7 +88,7 @@ static void add_recent_object(const struct object_id *oid,
88 obj = (struct object *)lookup_tree(oid->hash);
89 break;
90 case OBJ_BLOB:
91 - obj = (struct object *)lookup_blob(oid->hash);
91 + obj = (struct object *)lookup_blob(oid);
92 break;
93 default:
94 die("unknown object type for %s: %s",
revision.c
+2 -2
@@ -62,7 +62,7 @@ static void mark_tree_contents_uninteresting(struct tree *tree)
62 mark_tree_uninteresting(lookup_tree(entry.oid->hash));
63 break;
64 case OBJ_BLOB:
65 - mark_blob_uninteresting(lookup_blob(entry.oid->hash));
65 + mark_blob_uninteresting(lookup_blob(entry.oid));
66 break;
67 default:
68 /* Subproject commit - not in this repository */
@@ -1275,7 +1275,7 @@ void add_index_objects_to_pending(struct rev_info *revs, unsigned flags)
1275 if (S_ISGITLINK(ce->ce_mode))
1276 continue;
1277
1278 - blob = lookup_blob(ce->oid.hash);
1278 + blob = lookup_blob(&ce->oid);
1279 if (!blob)
1280 die("unable to add index blob to traversal");
1281 add_pending_object_with_path(revs, &blob->object, "",
tag.c
+1 -1
@@ -142,7 +142,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)
142 bufptr = nl + 1;
143
144 if (!strcmp(type, blob_type)) {
145 - item->tagged = &lookup_blob(oid.hash)->object;
145 + item->tagged = &lookup_blob(&oid)->object;
146 } else if (!strcmp(type, tree_type)) {
147 item->tagged = &lookup_tree(oid.hash)->object;
148 } else if (!strcmp(type, commit_type)) {
walker.c
+1 -1
@@ -52,7 +52,7 @@ static int process_tree(struct walker *walker, struct tree *tree)
52 obj = &tree->object;
53 }
54 else {
55 - struct blob *blob = lookup_blob(entry.oid->hash);
55 + struct blob *blob = lookup_blob(entry.oid);
56 if (blob)
57 obj = &blob->object;
58 }