SHA_CTX c;
z_stream s;
- hdrlen = sprintf((char*)hdr,"%s %lu", type_names[type],
+ hdrlen = sprintf((char*)hdr,"%s %lu", typename(type),
(unsigned long)datlen) + 1;
SHA1_Init(&c);
SHA1_Update(&c, hdr, hdrlen);
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)
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));
}
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)
} else if (oe) {
if (oe->type != OBJ_BLOB)
die("Not a blob (actually a %s): %s",
- command_buf.buf, type_names[oe->type]);
+ 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);
char *buf;
buf = read_object_with_reference(b->sha1,
- type_names[OBJ_COMMIT], &size, b->sha1);
+ commit_type, &size, b->sha1);
if (!buf || size < 46)
die("Not a valid commit: %s", from);
if (memcmp("tree ", buf, 5)
char *buf;
buf = read_object_with_reference(sha1,
- type_names[OBJ_COMMIT], &size, sha1);
+ commit_type, &size, sha1);
if (!buf || size < 46)
die("Not a valid commit: %s", from);
free(buf);
size_dbuf(&new_data, 67+strlen(t->name)+strlen(tagger)+msglen);
sp = new_data.buffer;
sp += sprintf(sp, "object %s\n", sha1_to_hex(sha1));
- sp += sprintf(sp, "type %s\n", type_names[OBJ_COMMIT]);
+ sp += sprintf(sp, "type %s\n", commit_type);
sp += sprintf(sp, "tag %s\n", t->name);
sp += sprintf(sp, "tagger %s\n", tagger);
*sp++ = '\n';