Skip to content

Commit abef902

Browse files
bk2204gitster
authored andcommitted
sha1_file: convert sha1_object_info* to object_id
Convert sha1_object_info and sha1_object_info_extended to take pointers to struct object_id and rename them to use "oid" instead of "sha1" in their names. Update the declaration and definition and apply the following semantic patch, plus the standard object_id transforms: @@ expression E1, E2; @@ - sha1_object_info(E1.hash, E2) + oid_object_info(&E1, E2) @@ expression E1, E2; @@ - sha1_object_info(E1->hash, E2) + oid_object_info(E1, E2) @@ expression E1, E2, E3; @@ - sha1_object_info_extended(E1.hash, E2, E3) + oid_object_info_extended(&E1, E2, E3) @@ expression E1, E2, E3; @@ - sha1_object_info_extended(E1->hash, E2, E3) + oid_object_info_extended(E1, E2, E3) Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 7984f23 commit abef902

33 files changed

+71
-72
lines changed

archive-tar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ static int write_tar_entry(struct archiver_args *args,
276276
memcpy(header.name, path, pathlen);
277277

278278
if (S_ISREG(mode) && !args->convert &&
279-
sha1_object_info(oid->hash, &size) == OBJ_BLOB &&
279+
oid_object_info(oid, &size) == OBJ_BLOB &&
280280
size > big_file_threshold)
281281
buffer = NULL;
282282
else if (S_ISLNK(mode) || S_ISREG(mode)) {

archive-zip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ static int write_zip_entry(struct archiver_args *args,
325325
compressed_size = 0;
326326
buffer = NULL;
327327
} else if (S_ISREG(mode) || S_ISLNK(mode)) {
328-
enum object_type type = sha1_object_info(oid->hash, &size);
328+
enum object_type type = oid_object_info(oid, &size);
329329

330330
method = 0;
331331
attr2 = S_ISLNK(mode) ? ((mode | 0777) << 16) :

blame.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static void verify_working_tree_path(struct commit *work_tree, const char *path)
8181
unsigned mode;
8282

8383
if (!get_tree_entry(commit_oid->hash, path, blob_oid.hash, &mode) &&
84-
sha1_object_info(blob_oid.hash, NULL) == OBJ_BLOB)
84+
oid_object_info(&blob_oid, NULL) == OBJ_BLOB)
8585
return;
8686
}
8787

@@ -506,7 +506,7 @@ static int fill_blob_sha1_and_mode(struct blame_origin *origin)
506506
origin->path,
507507
origin->blob_oid.hash, &origin->mode))
508508
goto error_out;
509-
if (sha1_object_info(origin->blob_oid.hash, NULL) != OBJ_BLOB)
509+
if (oid_object_info(&origin->blob_oid, NULL) != OBJ_BLOB)
510510
goto error_out;
511511
return 0;
512512
error_out:

builtin/blame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ static int is_a_rev(const char *name)
655655

656656
if (get_oid(name, &oid))
657657
return 0;
658-
return OBJ_NONE < sha1_object_info(oid.hash, NULL);
658+
return OBJ_NONE < oid_object_info(&oid, NULL);
659659
}
660660

661661
int cmd_blame(int argc, const char **argv, const char *prefix)

builtin/cat-file.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
7777
switch (opt) {
7878
case 't':
7979
oi.type_name = &sb;
80-
if (sha1_object_info_extended(oid.hash, &oi, flags) < 0)
80+
if (oid_object_info_extended(&oid, &oi, flags) < 0)
8181
die("git cat-file: could not get object info");
8282
if (sb.len) {
8383
printf("%s\n", sb.buf);
@@ -88,7 +88,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
8888

8989
case 's':
9090
oi.sizep = &size;
91-
if (sha1_object_info_extended(oid.hash, &oi, flags) < 0)
91+
if (oid_object_info_extended(&oid, &oi, flags) < 0)
9292
die("git cat-file: could not get object info");
9393
printf("%lu\n", size);
9494
return 0;
@@ -116,7 +116,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
116116
/* else fallthrough */
117117

118118
case 'p':
119-
type = sha1_object_info(oid.hash, NULL);
119+
type = oid_object_info(&oid, NULL);
120120
if (type < 0)
121121
die("Not a valid object name %s", obj_name);
122122

@@ -140,7 +140,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
140140
case 0:
141141
if (type_from_string(exp_type) == OBJ_BLOB) {
142142
struct object_id blob_oid;
143-
if (sha1_object_info(oid.hash, NULL) == OBJ_TAG) {
143+
if (oid_object_info(&oid, NULL) == OBJ_TAG) {
144144
char *buffer = read_sha1_file(oid.hash, &type, &size);
145145
const char *target;
146146
if (!skip_prefix(buffer, "object ", &target) ||
@@ -150,7 +150,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
150150
} else
151151
oidcpy(&blob_oid, &oid);
152152

153-
if (sha1_object_info(blob_oid.hash, NULL) == OBJ_BLOB)
153+
if (oid_object_info(&blob_oid, NULL) == OBJ_BLOB)
154154
return stream_blob_to_fd(1, &blob_oid, NULL, 0);
155155
/*
156156
* we attempted to dereference a tag to a blob
@@ -340,8 +340,8 @@ static void batch_object_write(const char *obj_name, struct batch_options *opt,
340340
struct strbuf buf = STRBUF_INIT;
341341

342342
if (!data->skip_object_info &&
343-
sha1_object_info_extended(data->oid.hash, &data->info,
344-
OBJECT_INFO_LOOKUP_REPLACE) < 0) {
343+
oid_object_info_extended(&data->oid, &data->info,
344+
OBJECT_INFO_LOOKUP_REPLACE) < 0) {
345345
printf("%s missing\n",
346346
obj_name ? obj_name : oid_to_hex(&data->oid));
347347
fflush(stdout);

builtin/describe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ static void describe(const char *arg, int last_one)
502502

503503
if (cmit)
504504
describe_commit(&oid, &sb);
505-
else if (sha1_object_info(oid.hash, NULL) == OBJ_BLOB)
505+
else if (oid_object_info(&oid, NULL) == OBJ_BLOB)
506506
describe_blob(oid, &sb);
507507
else
508508
die(_("%s is neither a commit nor blob"), arg);

builtin/fast-export.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ static void import_marks(char *input_file)
947947
if (last_idnum < mark)
948948
last_idnum = mark;
949949

950-
type = sha1_object_info(oid.hash, NULL);
950+
type = oid_object_info(&oid, NULL);
951951
if (type < 0)
952952
die("object not found: %s", oid_to_hex(&oid));
953953

builtin/fetch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ static int update_local_ref(struct ref *ref,
637637
struct branch *current_branch = branch_get(NULL);
638638
const char *pretty_ref = prettify_refname(ref->name);
639639

640-
type = sha1_object_info(ref->new_oid.hash, NULL);
640+
type = oid_object_info(&ref->new_oid, NULL);
641641
if (type < 0)
642642
die(_("object %s not found"), oid_to_hex(&ref->new_oid));
643643

builtin/fsck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static const char *printable_type(struct object *obj)
6565
const char *ret;
6666

6767
if (obj->type == OBJ_NONE) {
68-
enum object_type type = sha1_object_info(obj->oid.hash, NULL);
68+
enum object_type type = oid_object_info(&obj->oid, NULL);
6969
if (type > 0)
7070
object_as_type(obj, type, 0);
7171
}

builtin/index-pack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ static unsigned check_object(struct object *obj)
221221

222222
if (!(obj->flags & FLAG_CHECKED)) {
223223
unsigned long size;
224-
int type = sha1_object_info(obj->oid.hash, &size);
224+
int type = oid_object_info(&obj->oid, &size);
225225
if (type <= 0)
226226
die(_("did not receive expected object %s"),
227227
oid_to_hex(&obj->oid));
@@ -810,7 +810,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
810810
enum object_type has_type;
811811
unsigned long has_size;
812812
read_lock();
813-
has_type = sha1_object_info(oid->hash, &has_size);
813+
has_type = oid_object_info(oid, &has_size);
814814
if (has_type < 0)
815815
die(_("cannot read existing object info %s"), oid_to_hex(oid));
816816
if (has_type != type || has_size != size)

0 commit comments

Comments
 (0)