diff options
author | Nicolas Pitre <nico@cam.org> | 2007-02-26 14:55:59 -0500 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-02-27 01:34:21 -0800 |
commit | 21666f1aae4e890d8f50924f9e80763b27e6a45d (patch) | |
tree | 462de5be3e949924f58858e08e24355f613191ab /fast-import.c | |
parent | df8436622fb553f468180b61032fe34bd6712752 (diff) | |
download | git-21666f1aae4e890d8f50924f9e80763b27e6a45d.tar.gz git-21666f1aae4e890d8f50924f9e80763b27e6a45d.tar.xz |
convert object type handling from a string to a number
We currently have two parallel notation for dealing with object types
in the code: a string and a numerical value. One of them is obviously
redundent, and the most used one requires more stack space and a bunch
of strcmp() all over the place.
This is an initial step for the removal of the version using a char array
found in object reading code paths. The patch is unfortunately large but
there is no sane way to split it in smaller parts without breaking the
system.
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'fast-import.c')
-rw-r--r-- | fast-import.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/fast-import.c b/fast-import.c index aa9eac392..65e99c2e8 100644 --- a/fast-import.c +++ b/fast-import.c @@ -1008,11 +1008,11 @@ static void *gfi_unpack_entry( struct object_entry *oe, unsigned long *sizep) { - static char type[20]; + enum object_type type; struct packed_git *p = all_packs[oe->pack_id]; if (p == pack_data) p->pack_size = pack_size + 20; - return unpack_entry(p, oe->offset, type, sizep); + return unpack_entry(p, oe->offset, &type, sizep); } static const char *get_mode(const char *str, uint16_t *modep) @@ -1049,9 +1049,9 @@ static void load_tree(struct tree_entry *root) t->delta_depth = 0; buf = gfi_unpack_entry(myoe, &size); } else { - char type[20]; - buf = read_sha1_file(sha1, type, &size); - if (!buf || strcmp(type, tree_type)) + enum object_type type; + buf = read_sha1_file(sha1, &type, &size); + if (!buf || type != OBJ_TREE) die("Can't load tree %s", sha1_to_hex(sha1)); } @@ -1573,7 +1573,6 @@ static void file_change_m(struct branch *b) struct object_entry *oe = oe; unsigned char sha1[20]; uint16_t mode, inline_data = 0; - char type[20]; p = get_mode(p, &mode); if (!p) @@ -1628,11 +1627,12 @@ static void file_change_m(struct branch *b) die("Not a blob (actually a %s): %s", command_buf.buf, typename(oe->type)); } else { - if (sha1_object_info(sha1, type, NULL)) + enum object_type type = sha1_object_info(sha1, NULL); + if (type < 0) die("Blob not found: %s", command_buf.buf); - if (strcmp(blob_type, type)) + if (type != OBJ_BLOB) die("Not a blob (actually a %s): %s", - command_buf.buf, type); + typename(type), command_buf.buf); } tree_content_set(&b->branch_tree, p, sha1, S_IFREG | mode); |