X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=mktree.c;h=d86dde89d63e21994fd2538d5ac3a21ead3a7338;hb=a781785d8f1eb7adf05a24b121104716a086a67a;hp=56205d1e0053cdcb7236bde199817a5529d3f433;hpb=b32d37a3a6817ba307062fe2f7b6d9cfb85a1ebd;p=git.git diff --git a/mktree.c b/mktree.c index 56205d1e0..d86dde89d 100644 --- a/mktree.c +++ b/mktree.c @@ -95,7 +95,7 @@ int main(int ac, char **av) int len; char *ptr, *ntr; unsigned mode; - char type[20]; + enum object_type type; char *path; read_line(&sb, stdin, line_termination); @@ -115,11 +115,12 @@ int main(int ac, char **av) ntr[41] != '\t' || get_sha1_hex(ntr + 1, sha1)) die("input format error: %s", sb.buf); - if (sha1_object_info(sha1, type, NULL)) + type = sha1_object_info(sha1, NULL); + if (type < 0) die("object %s unavailable", sha1_to_hex(sha1)); *ntr++ = 0; /* now at the beginning of SHA1 */ - if (strcmp(ptr, type)) - die("object type %s mismatch (%s)", ptr, type); + if (type != type_from_string(ptr)) + die("object type %s mismatch (%s)", ptr, typename(type)); ntr += 41; /* at the beginning of name */ if (line_termination && ntr[0] == '"') path = unquote_c_style(ntr, NULL);