Skip to content

Commit ad87b5d

Browse files
committed
mktree: do not barf on a submodule commit
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>
1 parent fe0bb5f commit ad87b5d

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

builtin-mktree.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,16 @@ static void mktree_line(char *buf, size_t len, int line_termination)
8989
ntr[41] != '\t' ||
9090
get_sha1_hex(ntr + 1, sha1))
9191
die("input format error: %s", buf);
92-
type = sha1_object_info(sha1, NULL);
92+
93+
/* It is perfectly normal if we do not have a commit from a submodule */
94+
if (!S_ISGITLINK(mode))
95+
type = sha1_object_info(sha1, NULL);
96+
else
97+
type = OBJ_COMMIT;
98+
9399
if (type < 0)
94100
die("object %s unavailable", sha1_to_hex(sha1));
101+
95102
*ntr++ = 0; /* now at the beginning of SHA1 */
96103
if (type != type_from_string(ptr))
97104
die("object type %s mismatch (%s)", ptr, typename(type));

0 commit comments

Comments
 (0)