object-file API: pass an enum to read_object_with_reference()
Change the read_object_with_reference() function to take an "enum object_type". It was not prepared to handle an arbitrary "const char *type", as it was itself calling type_from_string(). Let's change the only caller that passes in user data to use type_from_string(), and convert the rest to use e.g. "OBJ_TREE" instead of "tree_type". The "cat-file" caller is not on the codepath that handles"--allow-unknown", so the type_from_string() there is safe. Its use of type_from_string() doesn't functionally differ from that of the pre-image. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
2bbb28a3ee
commit
6aea6baeb3
@ -2483,7 +2483,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
|
||||
unsigned long size;
|
||||
char *buf = read_object_with_reference(the_repository,
|
||||
&commit_oid,
|
||||
commit_type, &size,
|
||||
OBJ_COMMIT, &size,
|
||||
&commit_oid);
|
||||
if (!buf || size < the_hash_algo->hexsz + 6)
|
||||
die("Not a valid commit: %s", p);
|
||||
@ -2555,7 +2555,7 @@ static void parse_from_existing(struct branch *b)
|
||||
char *buf;
|
||||
|
||||
buf = read_object_with_reference(the_repository,
|
||||
&b->oid, commit_type, &size,
|
||||
&b->oid, OBJ_COMMIT, &size,
|
||||
&b->oid);
|
||||
parse_from_commit(b, buf, size);
|
||||
free(buf);
|
||||
@ -2651,7 +2651,7 @@ static struct hash_list *parse_merge(unsigned int *count)
|
||||
unsigned long size;
|
||||
char *buf = read_object_with_reference(the_repository,
|
||||
&n->oid,
|
||||
commit_type,
|
||||
OBJ_COMMIT,
|
||||
&size, &n->oid);
|
||||
if (!buf || size < the_hash_algo->hexsz + 6)
|
||||
die("Not a valid commit: %s", from);
|
||||
|
||||
Reference in New Issue
Block a user