tag: discover the target type if needed

Don't blindly pass the target type to git_tag_type2string as it will
give an empty string on GIT_OBJ_ANY which would cause us to create an
invalid tag object.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
This commit is contained in:
Carlos Martín Nieto 2011-04-05 16:53:32 +02:00 committed by Vicent Marti
parent 26f2c897b8
commit 81234673a1

View File

@ -209,6 +209,14 @@ static int tag_create(
return error;
}
/* Try to find out what the type is */
if (target_type == GIT_OBJ_ANY) {
size_t _unused;
error = git_odb_read_header(&_unused, &target_type, repo->db, target);
if (error < GIT_SUCCESS)
return error;
}
type_str = git_object_type2string(target_type);
tagger_str_len = git_signature__write(&tagger_str, "tagger", tagger);