static void check_valid(unsigned char *sha1, const char *expect)
{
- char type[20];
-
- if (sha1_object_info(sha1, type, NULL))
+ enum object_type type = sha1_object_info(sha1, NULL);
+ if (type < 0)
die("%s is not a valid object", sha1_to_hex(sha1));
- if (expect && strcmp(type, expect))
+ if (expect && type != type_from_string(expect))
die("%s is not a valid '%s' object", sha1_to_hex(sha1),
expect);
}
unsigned int size;
int encoding_is_utf8;
- setup_ident();
git_config(git_default_config);
if (argc < 2)
}
/* Not having i18n.commitencoding is the same as having utf-8 */
- encoding_is_utf8 = (!git_commit_encoding ||
- !strcmp(git_commit_encoding, "utf-8"));
+ encoding_is_utf8 = is_encoding_utf8(git_commit_encoding);
init_buffer(&buffer, &size);
add_buffer(&buffer, &size, "tree %s\n", sha1_to_hex(tree_sha1));