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 <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 3e93098 commit 3aca1fc

File tree

15 files changed

+19
-19
lines changed

15 files changed

+19
-19
lines changed

blob.c

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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
}

0 commit comments

Comments
 (0)