Skip to content

Commit 44439c1

Browse files
avargitster
authored andcommitted
object-file API: have hash_object_file() take "enum object_type"
Change the hash_object_file() function to take an "enum object_type". Since a preceding commit all of its callers are passing either "{commit,tree,blob,tag}_type", or the result of a call to type_name(), the parse_object() caller that would pass NULL is now using stream_object_signature(). Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0ff7b4f commit 44439c1

16 files changed

+41
-34
lines changed

apply.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3157,7 +3157,7 @@ static int apply_binary(struct apply_state *state,
31573157
* See if the old one matches what the patch
31583158
* applies to.
31593159
*/
3160-
hash_object_file(the_hash_algo, img->buf, img->len, blob_type,
3160+
hash_object_file(the_hash_algo, img->buf, img->len, OBJ_BLOB,
31613161
&oid);
31623162
if (strcmp(oid_to_hex(&oid), patch->old_oid_prefix))
31633163
return error(_("the patch applies to '%s' (%s), "
@@ -3203,7 +3203,7 @@ static int apply_binary(struct apply_state *state,
32033203
name);
32043204

32053205
/* verify that the result matches */
3206-
hash_object_file(the_hash_algo, img->buf, img->len, blob_type,
3206+
hash_object_file(the_hash_algo, img->buf, img->len, OBJ_BLOB,
32073207
&oid);
32083208
if (strcmp(oid_to_hex(&oid), patch->new_oid_prefix))
32093209
return error(_("binary patch to '%s' creates incorrect result (expecting %s, got %s)"),

builtin/fast-export.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ static void export_blob(const struct object_id *oid)
300300
if (!buf)
301301
die("could not read blob %s", oid_to_hex(oid));
302302
if (check_object_signature(the_repository, oid, buf, size,
303-
type_name(type)) < 0)
303+
type) < 0)
304304
die("oid mismatch in blob %s", oid_to_hex(oid));
305305
object = parse_object_buffer(the_repository, oid, type,
306306
size, buf, &eaten);

builtin/index-pack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ static struct base_data *resolve_delta(struct object_entry *delta_obj,
970970
if (!result_data)
971971
bad_object(delta_obj->idx.offset, _("failed to apply delta"));
972972
hash_object_file(the_hash_algo, result_data, result_size,
973-
type_name(delta_obj->real_type), &delta_obj->idx.oid);
973+
delta_obj->real_type, &delta_obj->idx.oid);
974974
sha1_object(result_data, NULL, result_size, delta_obj->real_type,
975975
&delta_obj->idx.oid);
976976

@@ -1413,7 +1413,7 @@ static void fix_unresolved_deltas(struct hashfile *f)
14131413
continue;
14141414

14151415
if (check_object_signature(the_repository, &d->oid, data, size,
1416-
type_name(type)) < 0)
1416+
type) < 0)
14171417
die(_("local object %s is corrupt"), oid_to_hex(&d->oid));
14181418

14191419
/*

builtin/mktag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static int verify_object_in_tag(struct object_id *tagged_oid, int *tagged_type)
6262

6363
repl = lookup_replace_object(the_repository, tagged_oid);
6464
ret = check_object_signature(the_repository, repl, buffer, size,
65-
type_name(*tagged_type));
65+
*tagged_type);
6666
free(buffer);
6767

6868
return ret;

builtin/replace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ static int check_one_mergetag(struct commit *commit,
409409
int i;
410410

411411
hash_object_file(the_hash_algo, extra->value, extra->len,
412-
type_name(OBJ_TAG), &tag_oid);
412+
OBJ_TAG, &tag_oid);
413413
tag = lookup_tag(the_repository, &tag_oid);
414414
if (!tag)
415415
return error(_("bad mergetag in commit '%s'"), ref);

builtin/unpack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ static void write_object(unsigned nr, enum object_type type,
266266
} else {
267267
struct object *obj;
268268
int eaten;
269-
hash_object_file(the_hash_algo, buf, size, type_name(type),
269+
hash_object_file(the_hash_algo, buf, size, type,
270270
&obj_list[nr].oid);
271271
added_object(nr, type, buf, size);
272272
obj = parse_object_buffer(the_repository, &obj_list[nr].oid,

cache-tree.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,14 +432,14 @@ static int update_one(struct cache_tree *it,
432432
if (repair) {
433433
struct object_id oid;
434434
hash_object_file(the_hash_algo, buffer.buf, buffer.len,
435-
tree_type, &oid);
435+
OBJ_TREE, &oid);
436436
if (has_object_file_with_flags(&oid, OBJECT_INFO_SKIP_FETCH_OBJECT))
437437
oidcpy(&it->oid, &oid);
438438
else
439439
to_invalidate = 1;
440440
} else if (dryrun) {
441441
hash_object_file(the_hash_algo, buffer.buf, buffer.len,
442-
tree_type, &it->oid);
442+
OBJ_TREE, &it->oid);
443443
} else if (write_object_file_flags(buffer.buf, buffer.len, OBJ_TREE,
444444
&it->oid, flags & WRITE_TREE_SILENT
445445
? HASH_SILENT : 0)) {
@@ -948,7 +948,7 @@ static int verify_one(struct repository *r,
948948
strbuf_addf(&tree_buf, "%o %.*s%c", mode, entlen, name, '\0');
949949
strbuf_add(&tree_buf, oid->hash, r->hash_algo->rawsz);
950950
}
951-
hash_object_file(r->hash_algo, tree_buf.buf, tree_buf.len, tree_type,
951+
hash_object_file(r->hash_algo, tree_buf.buf, tree_buf.len, OBJ_TREE,
952952
&new_oid);
953953
if (!oideq(&new_oid, &it->oid))
954954
BUG("cache-tree for path %.*s does not match. "

cache.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,8 @@ int parse_loose_header(const char *hdr, struct object_info *oi);
13271327
* what we expected, but it might also indicate another error.
13281328
*/
13291329
int check_object_signature(struct repository *r, const struct object_id *oid,
1330-
void *buf, unsigned long size, const char *type);
1330+
void *map, unsigned long size,
1331+
enum object_type type);
13311332

13321333
/**
13331334
* A streaming version of check_object_signature().

convert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ static int ident_to_worktree(const char *src, size_t len,
11591159
/* are we "faking" in place editing ? */
11601160
if (src == buf->buf)
11611161
to_free = strbuf_detach(buf, NULL);
1162-
hash_object_file(the_hash_algo, src, len, "blob", &oid);
1162+
hash_object_file(the_hash_algo, src, len, OBJ_BLOB, &oid);
11631163

11641164
strbuf_grow(buf, len + cnt * (the_hash_algo->hexsz + 3));
11651165
for (;;) {

diffcore-rename.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ static unsigned int hash_filespec(struct repository *r,
261261
if (diff_populate_filespec(r, filespec, NULL))
262262
return 0;
263263
hash_object_file(r->hash_algo, filespec->data, filespec->size,
264-
"blob", &filespec->oid);
264+
OBJ_BLOB, &filespec->oid);
265265
}
266266
return oidhash(&filespec->oid);
267267
}

0 commit comments

Comments
 (0)