Skip to content

Commit

Permalink
mktree: do not barf on a submodule commit
Browse files Browse the repository at this point in the history
It is perfectly normal if a tree entry points at a missing commit as long
as the mode of the entry says it is a submodule.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed May 10, 2009
1 parent fe0bb5f commit ad87b5d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion builtin-mktree.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,16 @@ static void mktree_line(char *buf, size_t len, int line_termination)
ntr[41] != '\t' ||
get_sha1_hex(ntr + 1, sha1))
die("input format error: %s", buf);
type = sha1_object_info(sha1, NULL);

/* It is perfectly normal if we do not have a commit from a submodule */
if (!S_ISGITLINK(mode))
type = sha1_object_info(sha1, NULL);
else
type = OBJ_COMMIT;

if (type < 0)
die("object %s unavailable", sha1_to_hex(sha1));

*ntr++ = 0; /* now at the beginning of SHA1 */
if (type != type_from_string(ptr))
die("object type %s mismatch (%s)", ptr, typename(type));
Expand Down

0 comments on commit ad87b5d

Please sign in to comment.