Skip to content

Commit 3aca1fc

Browse files
bk2204gitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3e93098 commit 3aca1fc

15 files changed

+19
-19
lines changed

blob.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
const char *blob_type = "blob";
55

6-
struct blob *lookup_blob(const unsigned char *sha1)
6+
struct blob *lookup_blob(const struct object_id *oid)
77
{
8-
struct object *obj = lookup_object(sha1);
8+
struct object *obj = lookup_object(oid->hash);
99
if (!obj)
10-
return create_object(sha1, alloc_blob_node());
10+
return create_object(oid->hash, alloc_blob_node());
1111
return object_as_type(obj, OBJ_BLOB, 0);
1212
}
1313

blob.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ struct blob {
99
struct object object;
1010
};
1111

12-
struct blob *lookup_blob(const unsigned char *sha1);
12+
struct blob *lookup_blob(const struct object_id *oid);
1313

1414
int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size);
1515

builtin/fast-export.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ static void export_blob(const struct object_id *oid)
232232

233233
if (anonymize) {
234234
buf = anonymize_blob(&size);
235-
object = (struct object *)lookup_blob(oid->hash);
235+
object = (struct object *)lookup_blob(oid);
236236
eaten = 0;
237237
} else {
238238
buf = read_sha1_file(oid->hash, &type, &size);

builtin/fsck.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
781781
mode = active_cache[i]->ce_mode;
782782
if (S_ISGITLINK(mode))
783783
continue;
784-
blob = lookup_blob(active_cache[i]->oid.hash);
784+
blob = lookup_blob(&active_cache[i]->oid);
785785
if (!blob)
786786
continue;
787787
obj = &blob->object;

builtin/index-pack.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
829829
if (strict) {
830830
read_lock();
831831
if (type == OBJ_BLOB) {
832-
struct blob *blob = lookup_blob(oid->hash);
832+
struct blob *blob = lookup_blob(oid);
833833
if (blob)
834834
blob->object.flags |= FLAG_CHECKED;
835835
else

builtin/merge-tree.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ static struct merge_list *create_entry(unsigned stage, unsigned mode, const stru
168168
res->stage = stage;
169169
res->path = path;
170170
res->mode = mode;
171-
res->blob = lookup_blob(oid->hash);
171+
res->blob = lookup_blob(oid);
172172
return res;
173173
}
174174

builtin/unpack-objects.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ static void write_object(unsigned nr, enum object_type type,
249249
added_object(nr, type, buf, size);
250250
free(buf);
251251

252-
blob = lookup_blob(obj_list[nr].oid.hash);
252+
blob = lookup_blob(&obj_list[nr].oid);
253253
if (blob)
254254
blob->object.flags |= FLAG_WRITTEN;
255255
else

fsck.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *op
365365
result = options->walk(obj, OBJ_TREE, data, options);
366366
}
367367
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;
369369
if (name)
370370
put_object_name(options, obj, "%s%s", name,
371371
entry.path);

http-push.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ static struct object_list **process_tree(struct tree *tree,
13151315
p = process_tree(lookup_tree(entry.oid->hash), p);
13161316
break;
13171317
case OBJ_BLOB:
1318-
p = process_blob(lookup_blob(entry.oid->hash), p);
1318+
p = process_blob(lookup_blob(entry.oid), p);
13191319
break;
13201320
default:
13211321
/* Subproject commit - not in this repository */

list-objects.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ static void process_tree(struct rev_info *revs,
119119
cb_data);
120120
else
121121
process_blob(revs,
122-
lookup_blob(entry.oid->hash),
122+
lookup_blob(entry.oid),
123123
show, base, entry.path,
124124
cb_data);
125125
}

object.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
190190

191191
obj = NULL;
192192
if (type == OBJ_BLOB) {
193-
struct blob *blob = lookup_blob(oid.hash);
193+
struct blob *blob = lookup_blob(&oid);
194194
if (blob) {
195195
if (parse_blob_buffer(blob, buffer, size))
196196
return NULL;
@@ -266,7 +266,7 @@ struct object *parse_object(const unsigned char *sha1)
266266
error("sha1 mismatch %s", sha1_to_hex(repl));
267267
return NULL;
268268
}
269-
parse_blob_buffer(lookup_blob(oid.hash), NULL, 0);
269+
parse_blob_buffer(lookup_blob(&oid), NULL, 0);
270270
return lookup_object(sha1);
271271
}
272272

reachable.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static void add_recent_object(const struct object_id *oid,
8888
obj = (struct object *)lookup_tree(oid->hash);
8989
break;
9090
case OBJ_BLOB:
91-
obj = (struct object *)lookup_blob(oid->hash);
91+
obj = (struct object *)lookup_blob(oid);
9292
break;
9393
default:
9494
die("unknown object type for %s: %s",

revision.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static void mark_tree_contents_uninteresting(struct tree *tree)
6262
mark_tree_uninteresting(lookup_tree(entry.oid->hash));
6363
break;
6464
case OBJ_BLOB:
65-
mark_blob_uninteresting(lookup_blob(entry.oid->hash));
65+
mark_blob_uninteresting(lookup_blob(entry.oid));
6666
break;
6767
default:
6868
/* Subproject commit - not in this repository */
@@ -1275,7 +1275,7 @@ void add_index_objects_to_pending(struct rev_info *revs, unsigned flags)
12751275
if (S_ISGITLINK(ce->ce_mode))
12761276
continue;
12771277

1278-
blob = lookup_blob(ce->oid.hash);
1278+
blob = lookup_blob(&ce->oid);
12791279
if (!blob)
12801280
die("unable to add index blob to traversal");
12811281
add_pending_object_with_path(revs, &blob->object, "",

tag.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)
142142
bufptr = nl + 1;
143143

144144
if (!strcmp(type, blob_type)) {
145-
item->tagged = &lookup_blob(oid.hash)->object;
145+
item->tagged = &lookup_blob(&oid)->object;
146146
} else if (!strcmp(type, tree_type)) {
147147
item->tagged = &lookup_tree(oid.hash)->object;
148148
} else if (!strcmp(type, commit_type)) {

walker.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static int process_tree(struct walker *walker, struct tree *tree)
5252
obj = &tree->object;
5353
}
5454
else {
55-
struct blob *blob = lookup_blob(entry.oid->hash);
55+
struct blob *blob = lookup_blob(entry.oid);
5656
if (blob)
5757
obj = &blob->object;
5858
}

0 commit comments

Comments
 (0)