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>
brian m. carlson committed
Mar 12, 2018 at 02:27 UTC
abef9020e3df87c441c9a3a95f592fce5fa49bb9
33 files changed
+71
-72
archive-tar.c
+1
-1
@@ -276,7 +276,7 @@ static int write_tar_entry(struct archiver_args *args,
276
memcpy(header.name, path, pathlen);
277
278
if (S_ISREG(mode) && !args->convert &&
279
- sha1_object_info(oid->hash, &size) == OBJ_BLOB &&
279
+ oid_object_info(oid, &size) == OBJ_BLOB &&
280
size > big_file_threshold)
281
buffer = NULL;
282
else if (S_ISLNK(mode) || S_ISREG(mode)) {
archive-zip.c
+1
-1
@@ -325,7 +325,7 @@ static int write_zip_entry(struct archiver_args *args,
325
compressed_size = 0;
326
buffer = NULL;
327
} 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);
329
330
method = 0;
331
attr2 = S_ISLNK(mode) ? ((mode | 0777) << 16) :
blame.c
+2
-2
@@ -81,7 +81,7 @@ static void verify_working_tree_path(struct commit *work_tree, const char *path)
81
unsigned mode;
82
83
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)
85
return;
86
}
87
@@ -506,7 +506,7 @@ static int fill_blob_sha1_and_mode(struct blame_origin *origin)
506
origin->path,
507
origin->blob_oid.hash, &origin->mode))
508
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)
510
goto error_out;
511
return 0;
512
error_out:
builtin/blame.c
+1
-1
@@ -655,7 +655,7 @@ static int is_a_rev(const char *name)
655
656
if (get_oid(name, &oid))
657
return 0;
658
- return OBJ_NONE < sha1_object_info(oid.hash, NULL);
658
+ return OBJ_NONE < oid_object_info(&oid, NULL);
659
}
660
661
int cmd_blame(int argc, const char **argv, const char *prefix)
builtin/cat-file.c
+7
-7
@@ -77,7 +77,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
77
switch (opt) {
78
case 't':
79
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)
81
die("git cat-file: could not get object info");
82
if (sb.len) {
83
printf("%s\n", sb.buf);
@@ -88,7 +88,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
88
89
case 's':
90
oi.sizep = &size;
91
- if (sha1_object_info_extended(oid.hash, &oi, flags) < 0)
91
+ if (oid_object_info_extended(&oid, &oi, flags) < 0)
92
die("git cat-file: could not get object info");
93
printf("%lu\n", size);
94
return 0;
@@ -116,7 +116,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
116
/* else fallthrough */
117
118
case 'p':
119
- type = sha1_object_info(oid.hash, NULL);
119
+ type = oid_object_info(&oid, NULL);
120
if (type < 0)
121
die("Not a valid object name %s", obj_name);
122
@@ -140,7 +140,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
140
case 0:
141
if (type_from_string(exp_type) == OBJ_BLOB) {
142
struct object_id blob_oid;
143
- if (sha1_object_info(oid.hash, NULL) == OBJ_TAG) {
143
+ if (oid_object_info(&oid, NULL) == OBJ_TAG) {
144
char *buffer = read_sha1_file(oid.hash, &type, &size);
145
const char *target;
146
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,
150
} else
151
oidcpy(&blob_oid, &oid);
152
153
- if (sha1_object_info(blob_oid.hash, NULL) == OBJ_BLOB)
153
+ if (oid_object_info(&blob_oid, NULL) == OBJ_BLOB)
154
return stream_blob_to_fd(1, &blob_oid, NULL, 0);
155
/*
156
* 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,
340
struct strbuf buf = STRBUF_INIT;
341
342
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) {
345
printf("%s missing\n",
346
obj_name ? obj_name : oid_to_hex(&data->oid));
347
fflush(stdout);
builtin/describe.c
+1
-1
@@ -502,7 +502,7 @@ static void describe(const char *arg, int last_one)
502
503
if (cmit)
504
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)
506
describe_blob(oid, &sb);
507
else
508
die(_("%s is neither a commit nor blob"), arg);
builtin/fast-export.c
+1
-1
@@ -947,7 +947,7 @@ static void import_marks(char *input_file)
947
if (last_idnum < mark)
948
last_idnum = mark;
949
950
- type = sha1_object_info(oid.hash, NULL);
950
+ type = oid_object_info(&oid, NULL);
951
if (type < 0)
952
die("object not found: %s", oid_to_hex(&oid));
953
builtin/fetch.c
+1
-1
@@ -637,7 +637,7 @@ static int update_local_ref(struct ref *ref,
637
struct branch *current_branch = branch_get(NULL);
638
const char *pretty_ref = prettify_refname(ref->name);
639
640
- type = sha1_object_info(ref->new_oid.hash, NULL);
640
+ type = oid_object_info(&ref->new_oid, NULL);
641
if (type < 0)
642
die(_("object %s not found"), oid_to_hex(&ref->new_oid));
643
builtin/fsck.c
+1
-1
@@ -65,7 +65,7 @@ static const char *printable_type(struct object *obj)
65
const char *ret;
66
67
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);
69
if (type > 0)
70
object_as_type(obj, type, 0);
71
}
builtin/index-pack.c
+2
-2
@@ -221,7 +221,7 @@ static unsigned check_object(struct object *obj)
221
222
if (!(obj->flags & FLAG_CHECKED)) {
223
unsigned long size;
224
- int type = sha1_object_info(obj->oid.hash, &size);
224
+ int type = oid_object_info(&obj->oid, &size);
225
if (type <= 0)
226
die(_("did not receive expected object %s"),
227
oid_to_hex(&obj->oid));
@@ -810,7 +810,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
810
enum object_type has_type;
811
unsigned long has_size;
812
read_lock();
813
- has_type = sha1_object_info(oid->hash, &has_size);
813
+ has_type = oid_object_info(oid, &has_size);
814
if (has_type < 0)
815
die(_("cannot read existing object info %s"), oid_to_hex(oid));
816
if (has_type != type || has_size != size)
builtin/ls-tree.c
+1
-1
@@ -94,7 +94,7 @@ static int show_tree(const struct object_id *oid, struct strbuf *base,
94
char size_text[24];
95
if (!strcmp(type, blob_type)) {
96
unsigned long size;
97
- if (sha1_object_info(oid->hash, &size) == OBJ_BAD)
97
+ if (oid_object_info(oid, &size) == OBJ_BAD)
98
xsnprintf(size_text, sizeof(size_text),
99
"BAD");
100
else
builtin/mktree.c
+1
-1
@@ -116,7 +116,7 @@ static void mktree_line(char *buf, size_t len, int nul_term_line, int allow_miss
116
}
117
118
/* Check the type of object identified by sha1 */
119
- obj_type = sha1_object_info(oid.hash, NULL);
119
+ obj_type = oid_object_info(&oid, NULL);
120
if (obj_type < 0) {
121
if (allow_missing) {
122
; /* no problem - missing objects are presumed to be of the right type */
builtin/pack-objects.c
+3
-4
@@ -1516,7 +1516,7 @@ static void check_object(struct object_entry *entry)
1516
unuse_pack(&w_curs);
1517
}
1518
1519
- entry->type = sha1_object_info(entry->idx.oid.hash, &entry->size);
1519
+ entry->type = oid_object_info(&entry->idx.oid, &entry->size);
1520
/*
1521
* The error condition is checked in prepare_pack(). This is
1522
* to permit a missing preferred base object to be ignored
@@ -1578,8 +1578,7 @@ static void drop_reused_delta(struct object_entry *entry)
1578
* And if that fails, the error will be recorded in entry->type
1579
* and dealt with in prepare_pack().
1580
*/
1581
- entry->type = sha1_object_info(entry->idx.oid.hash,
1582
- &entry->size);
1581
+ entry->type = oid_object_info(&entry->idx.oid, &entry->size);
1582
}
1583
}
1584
@@ -2708,7 +2707,7 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)
2707
static int add_loose_object(const struct object_id *oid, const char *path,
2708
void *data)
2709
{
2711
- enum object_type type = sha1_object_info(oid->hash, NULL);
2710
+ enum object_type type = oid_object_info(oid, NULL);
2711
2712
if (type < 0) {
2713
warning("loose object at %s could not be examined", path);
builtin/prune.c
+1
-1
@@ -50,7 +50,7 @@ static int prune_object(const struct object_id *oid, const char *fullpath,
50
if (st.st_mtime > expire)
51
return 0;
52
if (show_only || verbose) {
53
- enum object_type type = sha1_object_info(oid->hash, NULL);
53
+ enum object_type type = oid_object_info(oid, NULL);
54
printf("%s %s\n", oid_to_hex(oid),
55
(type > 0) ? type_name(type) : "unknown");
56
}
builtin/replace.c
+5
-5
@@ -53,8 +53,8 @@ static int show_reference(const char *refname, const struct object_id *oid,
53
if (get_oid(refname, &object))
54
return error("Failed to resolve '%s' as a valid ref.", refname);
55
56
- obj_type = sha1_object_info(object.hash, NULL);
57
- repl_type = sha1_object_info(oid->hash, NULL);
56
+ obj_type = oid_object_info(&object, NULL);
57
+ repl_type = oid_object_info(oid, NULL);
58
59
printf("%s (%s) -> %s (%s)\n", refname, type_name(obj_type),
60
oid_to_hex(oid), type_name(repl_type));
@@ -162,8 +162,8 @@ static int replace_object_oid(const char *object_ref,
162
struct ref_transaction *transaction;
163
struct strbuf err = STRBUF_INIT;
164
165
- obj_type = sha1_object_info(object->hash, NULL);
166
- repl_type = sha1_object_info(repl->hash, NULL);
165
+ obj_type = oid_object_info(object, NULL);
166
+ repl_type = oid_object_info(repl, NULL);
167
if (!force && obj_type != repl_type)
168
die("Objects must be of the same type.\n"
169
"'%s' points to a replaced object of type '%s'\n"
@@ -290,7 +290,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)
290
if (get_oid(object_ref, &old_oid) < 0)
291
die("Not a valid object name: '%s'", object_ref);
292
293
- type = sha1_object_info(old_oid.hash, NULL);
293
+ type = oid_object_info(&old_oid, NULL);
294
if (type < 0)
295
die("unable to get object type for %s", oid_to_hex(&old_oid));
296
builtin/tag.c
+2
-2
@@ -212,7 +212,7 @@ static void create_tag(const struct object_id *object, const char *tag,
212
struct strbuf header = STRBUF_INIT;
213
char *path = NULL;
214
215
- type = sha1_object_info(object->hash, NULL);
215
+ type = oid_object_info(object, NULL);
216
if (type <= OBJ_NONE)
217
die(_("bad object type."));
218
@@ -298,7 +298,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)
298
}
299
300
strbuf_addstr(sb, " (");
301
- type = sha1_object_info(oid->hash, NULL);
301
+ type = oid_object_info(oid, NULL);
302
switch (type) {
303
default:
304
strbuf_addstr(sb, "object of unknown type");
builtin/unpack-objects.c
+1
-1
@@ -198,7 +198,7 @@ static int check_object(struct object *obj, int type, void *data, struct fsck_op
198
199
if (!(obj->flags & FLAG_OPEN)) {
200
unsigned long size;
201
- int type = sha1_object_info(obj->oid.hash, &size);
201
+ int type = oid_object_info(&obj->oid, &size);
202
if (type != obj->type || type <= 0)
203
die("object of unexpected type");
204
obj->flags |= FLAG_WRITTEN;
cache.h
+3
-3
@@ -1212,8 +1212,8 @@ static inline const unsigned char *lookup_replace_object(const unsigned char *sh
1212
return do_lookup_replace_object(sha1);
1213
}
1214
1215
-/* Read and unpack a sha1 file into memory, write memory to a sha1 file */
1216
-extern int sha1_object_info(const unsigned char *, unsigned long *);
1215
+/* Read and unpack an object file into memory, write memory to an object file */
1216
+extern int oid_object_info(const struct object_id *, unsigned long *);
1217
1218
extern int hash_object_file(const void *buf, unsigned long len,
1219
const char *type, struct object_id *oid);
@@ -1773,7 +1773,7 @@ struct object_info {
1773
#define OBJECT_INFO_SKIP_CACHED 4
1774
/* Do not retry packed storage after checking packed and loose storage */
1775
#define OBJECT_INFO_QUICK 8
1776
-extern int sha1_object_info_extended(const unsigned char *, struct object_info *, unsigned flags);
1776
+extern int oid_object_info_extended(const struct object_id *, struct object_info *, unsigned flags);
1777
1778
/*
1779
* Set this to 0 to prevent sha1_object_info_extended() from fetching missing
diff.c
+1
-1
@@ -3615,7 +3615,7 @@ int diff_populate_filespec(struct diff_filespec *s, unsigned int flags)
3615
else {
3616
enum object_type type;
3617
if (size_only || (flags & CHECK_BINARY)) {
3618
- type = sha1_object_info(s->oid.hash, &s->size);
3618
+ type = oid_object_info(&s->oid, &s->size);
3619
if (type < 0)
3620
die("unable to read %s",
3621
oid_to_hex(&s->oid));
fast-import.c
+5
-5
@@ -1913,7 +1913,7 @@ static void read_marks(void)
1913
die("corrupt mark line: %s", line);
1914
e = find_object(&oid);
1915
if (!e) {
1916
- enum object_type type = sha1_object_info(oid.hash, NULL);
1916
+ enum object_type type = oid_object_info(&oid, NULL);
1917
if (type < 0)
1918
die("object not found: %s", oid_to_hex(&oid));
1919
e = insert_object(&oid);
@@ -2443,7 +2443,7 @@ static void file_change_m(const char *p, struct branch *b)
2443
enum object_type expected = S_ISDIR(mode) ?
2444
OBJ_TREE: OBJ_BLOB;
2445
enum object_type type = oe ? oe->type :
2446
- sha1_object_info(oid.hash, NULL);
2446
+ oid_object_info(&oid, NULL);
2447
if (type < 0)
2448
die("%s not found: %s",
2449
S_ISDIR(mode) ? "Tree" : "Blob",
@@ -2603,7 +2603,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
2603
die("Not a blob (actually a %s): %s",
2604
type_name(oe->type), command_buf.buf);
2605
} else if (!is_null_oid(&oid)) {
2606
- enum object_type type = sha1_object_info(oid.hash, NULL);
2606
+ enum object_type type = oid_object_info(&oid, NULL);
2607
if (type < 0)
2608
die("Blob not found: %s", command_buf.buf);
2609
if (type != OBJ_BLOB)
@@ -2890,7 +2890,7 @@ static void parse_new_tag(const char *arg)
2890
} else if (!get_oid(from, &oid)) {
2891
struct object_entry *oe = find_object(&oid);
2892
if (!oe) {
2893
- type = sha1_object_info(oid.hash, NULL);
2893
+ type = oid_object_info(&oid, NULL);
2894
if (type < 0)
2895
die("Not a valid object: %s", from);
2896
} else
@@ -3048,7 +3048,7 @@ static struct object_entry *dereference(struct object_entry *oe,
3048
unsigned long size;
3049
char *buf = NULL;
3050
if (!oe) {
3051
- enum object_type type = sha1_object_info(oid->hash, NULL);
3051
+ enum object_type type = oid_object_info(oid, NULL);
3052
if (type < 0)
3053
die("object not found: %s", oid_to_hex(oid));
3054
/* cache it! */
list-objects-filter.c
+1
-1
@@ -117,7 +117,7 @@ static enum list_objects_filter_result filter_blobs_limit(
117
assert(obj->type == OBJ_BLOB);
118
assert((obj->flags & SEEN) == 0);
119
120
- t = sha1_object_info(obj->oid.hash, &object_length);
120
+ t = oid_object_info(&obj->oid, &object_length);
121
if (t != OBJ_BLOB) { /* probably OBJ_NONE */
122
/*
123
* We DO NOT have the blob locally, so we cannot
object.c
+1
-1
@@ -254,7 +254,7 @@ struct object *parse_object(const struct object_id *oid)
254
255
if ((obj && obj->type == OBJ_BLOB && has_object_file(oid)) ||
256
(!obj && has_object_file(oid) &&
257
- sha1_object_info(oid->hash, NULL) == OBJ_BLOB)) {
257
+ oid_object_info(oid, NULL) == OBJ_BLOB)) {
258
struct object_id reploid;
259
hashcpy(reploid.hash, repl);
260
pack-bitmap-write.c
+1
-2
@@ -73,8 +73,7 @@ void bitmap_writer_build_type_index(struct pack_idx_entry **index,
73
break;
74
75
default:
76
- real_type = sha1_object_info(entry->idx.oid.hash,
77
- NULL);
76
+ real_type = oid_object_info(&entry->idx.oid, NULL);
77
break;
78
}
79
packfile.c
+2
-2
@@ -1101,7 +1101,7 @@ static int retry_bad_packed_offset(struct packed_git *p, off_t obj_offset)
1101
return OBJ_BAD;
1102
nth_packed_object_oid(&oid, p, revidx->nr);
1103
mark_bad_packed_object(p, oid.hash);
1104
- type = sha1_object_info(oid.hash, NULL);
1104
+ type = oid_object_info(&oid, NULL);
1105
if (type <= OBJ_NONE)
1106
return OBJ_BAD;
1107
return type;
@@ -1461,7 +1461,7 @@ static void *read_object(const struct object_id *oid, enum object_type *type,
1461
oi.sizep = size;
1462
oi.contentp = &content;
1463
1464
- if (sha1_object_info_extended(oid->hash, &oi, 0) < 0)
1464
+ if (oid_object_info_extended(oid, &oi, 0) < 0)
1465
return NULL;
1466
return content;
1467
}
reachable.c
+1
-1
@@ -77,7 +77,7 @@ static void add_recent_object(const struct object_id *oid,
77
* later processing, and the revision machinery expects
78
* commits and tags to have been parsed.
79
*/
80
- type = sha1_object_info(oid->hash, NULL);
80
+ type = oid_object_info(oid, NULL);
81
if (type < 0)
82
die("unable to get object info for %s", oid_to_hex(oid));
83
refs.c
+1
-1
@@ -301,7 +301,7 @@ enum peel_status peel_object(const struct object_id *name, struct object_id *oid
301
struct object *o = lookup_unknown_object(name->hash);
302
303
if (o->type == OBJ_NONE) {
304
- int type = sha1_object_info(name->hash, NULL);
304
+ int type = oid_object_info(name, NULL);
305
if (type < 0 || !object_as_type(o, type, 0))
306
return PEEL_INVALID;
307
}
remote.c
+1
-1
@@ -1376,7 +1376,7 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds
1376
continue; /* not a tag */
1377
if (string_list_has_string(&dst_tag, ref->name))
1378
continue; /* they already have it */
1379
- if (sha1_object_info(ref->new_oid.hash, NULL) != OBJ_TAG)
1379
+ if (oid_object_info(&ref->new_oid, NULL) != OBJ_TAG)
1380
continue; /* be conservative */
1381
item = string_list_append(&src_tag, ref->name);
1382
item->util = ref;
sequencer.c
+2
-1
@@ -2881,7 +2881,8 @@ int sequencer_pick_revisions(struct replay_opts *opts)
2881
2882
if (!get_oid(name, &oid)) {
2883
if (!lookup_commit_reference_gently(&oid, 1)) {
2884
- enum object_type type = sha1_object_info(oid.hash, NULL);
2884
+ enum object_type type = oid_object_info(&oid,
2885
+ NULL);
2886
return error(_("%s: can't cherry-pick a %s"),
2887
name, type_name(type));
2888
}
sha1_file.c
+11
-11
@@ -1222,14 +1222,14 @@ static int sha1_loose_object_info(const unsigned char *sha1,
1222
1223
int fetch_if_missing = 1;
1224
1225
-int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi, unsigned flags)
1225
+int oid_object_info_extended(const struct object_id *oid, struct object_info *oi, unsigned flags)
1226
{
1227
static struct object_info blank_oi = OBJECT_INFO_INIT;
1228
struct pack_entry e;
1229
int rtype;
1230
const unsigned char *real = (flags & OBJECT_INFO_LOOKUP_REPLACE) ?
1231
- lookup_replace_object(sha1) :
1232
- sha1;
1231
+ lookup_replace_object(oid->hash) :
1232
+ oid->hash;
1233
int already_retried = 0;
1234
struct object_id realoid;
1235
@@ -1298,7 +1298,7 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,
1298
rtype = packed_object_info(e.p, e.offset, oi);
1299
if (rtype < 0) {
1300
mark_bad_packed_object(e.p, real);
1301
- return sha1_object_info_extended(realoid.hash, oi, 0);
1301
+ return oid_object_info_extended(&realoid, oi, 0);
1302
} else if (oi->whence == OI_PACKED) {
1303
oi->u.packed.offset = e.offset;
1304
oi->u.packed.pack = e.p;
@@ -1310,15 +1310,15 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,
1310
}
1311
1312
/* returns enum object_type or negative */
1313
-int sha1_object_info(const unsigned char *sha1, unsigned long *sizep)
1313
+int oid_object_info(const struct object_id *oid, unsigned long *sizep)
1314
{
1315
enum object_type type;
1316
struct object_info oi = OBJECT_INFO_INIT;
1317
1318
oi.typep = &type;
1319
oi.sizep = sizep;
1320
- if (sha1_object_info_extended(sha1, &oi,
1321
- OBJECT_INFO_LOOKUP_REPLACE) < 0)
1320
+ if (oid_object_info_extended(oid, &oi,
1321
+ OBJECT_INFO_LOOKUP_REPLACE) < 0)
1322
return -1;
1323
return type;
1324
}
@@ -1335,7 +1335,7 @@ static void *read_object(const unsigned char *sha1, enum object_type *type,
1335
1336
hashcpy(oid.hash, sha1);
1337
1338
- if (sha1_object_info_extended(oid.hash, &oi, 0) < 0)
1338
+ if (oid_object_info_extended(&oid, &oi, 0) < 0)
1339
return NULL;
1340
return content;
1341
}
@@ -1733,8 +1733,8 @@ int has_sha1_file_with_flags(const unsigned char *sha1, int flags)
1733
if (!startup_info->have_repository)
1734
return 0;
1735
hashcpy(oid.hash, sha1);
1736
- return sha1_object_info_extended(oid.hash, NULL,
1737
- flags | OBJECT_INFO_SKIP_CACHED) >= 0;
1736
+ return oid_object_info_extended(&oid, NULL,
1737
+ flags | OBJECT_INFO_SKIP_CACHED) >= 0;
1738
}
1739
1740
int has_object_file(const struct object_id *oid)
@@ -1976,7 +1976,7 @@ int read_pack_header(int fd, struct pack_header *header)
1976
1977
void assert_oid_type(const struct object_id *oid, enum object_type expect)
1978
{
1979
- enum object_type type = sha1_object_info(oid->hash, NULL);
1979
+ enum object_type type = oid_object_info(oid, NULL);
1980
if (type < 0)
1981
die("%s is not a valid object", oid_to_hex(oid));
1982
if (type != expect)
sha1_name.c
+6
-6
@@ -238,7 +238,7 @@ static int finish_object_disambiguation(struct disambiguate_state *ds,
238
239
static int disambiguate_commit_only(const struct object_id *oid, void *cb_data_unused)
240
{
241
- int kind = sha1_object_info(oid->hash, NULL);
241
+ int kind = oid_object_info(oid, NULL);
242
return kind == OBJ_COMMIT;
243
}
244
@@ -247,7 +247,7 @@ static int disambiguate_committish_only(const struct object_id *oid, void *cb_da
247
struct object *obj;
248
int kind;
249
250
- kind = sha1_object_info(oid->hash, NULL);
250
+ kind = oid_object_info(oid, NULL);
251
if (kind == OBJ_COMMIT)
252
return 1;
253
if (kind != OBJ_TAG)
@@ -262,7 +262,7 @@ static int disambiguate_committish_only(const struct object_id *oid, void *cb_da
262
263
static int disambiguate_tree_only(const struct object_id *oid, void *cb_data_unused)
264
{
265
- int kind = sha1_object_info(oid->hash, NULL);
265
+ int kind = oid_object_info(oid, NULL);
266
return kind == OBJ_TREE;
267
}
268
@@ -271,7 +271,7 @@ static int disambiguate_treeish_only(const struct object_id *oid, void *cb_data_
271
struct object *obj;
272
int kind;
273
274
- kind = sha1_object_info(oid->hash, NULL);
274
+ kind = oid_object_info(oid, NULL);
275
if (kind == OBJ_TREE || kind == OBJ_COMMIT)
276
return 1;
277
if (kind != OBJ_TAG)
@@ -286,7 +286,7 @@ static int disambiguate_treeish_only(const struct object_id *oid, void *cb_data_
286
287
static int disambiguate_blob_only(const struct object_id *oid, void *cb_data_unused)
288
{
289
- int kind = sha1_object_info(oid->hash, NULL);
289
+ int kind = oid_object_info(oid, NULL);
290
return kind == OBJ_BLOB;
291
}
292
@@ -365,7 +365,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)
365
if (ds->fn && !ds->fn(oid, ds->cb_data))
366
return 0;
367
368
- type = sha1_object_info(oid->hash, NULL);
368
+ type = oid_object_info(oid, NULL);
369
if (type == OBJ_COMMIT) {
370
struct commit *commit = lookup_commit(oid);
371
if (commit) {
streaming.c
+1
-1
@@ -117,7 +117,7 @@ static enum input_source istream_source(const unsigned char *sha1,
117
118
oi->typep = type;
119
oi->sizep = &size;
120
- status = sha1_object_info_extended(oid.hash, oi, 0);
120
+ status = oid_object_info_extended(&oid, oi, 0);
121
if (status < 0)
122
return stream_error;
123
submodule.c
+1
-1
@@ -817,7 +817,7 @@ static int check_has_commit(const struct object_id *oid, void *data)
817
{
818
struct has_commit_data *cb = data;
819
820
- enum object_type type = sha1_object_info(oid->hash, NULL);
820
+ enum object_type type = oid_object_info(oid, NULL);
821
822
switch (type) {
823
case OBJ_COMMIT:
tag.c
+1
-1
@@ -41,7 +41,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,
41
unsigned long size;
42
int ret;
43
44
- type = sha1_object_info(oid->hash, NULL);
44
+ type = oid_object_info(oid, NULL);
45
if (type != OBJ_TAG)
46
return error("%s: cannot verify a non-tag object of type %s.",
47
name_to_report ?