From 94883b4302118fe6ea50028d02bb453c9af38b66 Mon Sep 17 00:00:00 2001 From: John Keeping Date: Mon, 6 May 2013 16:20:54 +0100 Subject: merge-tree: handle directory/empty conflict correctly git-merge-tree causes a null pointer dereference when a directory entry exists in only one or two of the three trees being compared with no corresponding entry in the other tree(s). When this happens, we want to handle the entry as a directory and not attempt to mark it as a file merge. Do this by setting the entries bit in the directory mask when the entry is missing or when it is a directory, only performing the file comparison when we know that a file entry exists. Reported-by: Andreas Jacobsen Signed-off-by: John Keeping Tested-by: Andreas Jacobsen Signed-off-by: Junio C Hamano --- builtin/merge-tree.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c index ec49917a3..61cbde409 100644 --- a/builtin/merge-tree.c +++ b/builtin/merge-tree.c @@ -251,7 +251,11 @@ static void unresolved(const struct traverse_info *info, struct name_entry n[3]) for (i = 0; i < 3; i++) { mask |= (1 << i); - if (n[i].mode && S_ISDIR(n[i].mode)) + /* + * Treat missing entries as directories so that we return + * after unresolved_directory has handled this. + */ + if (!n[i].mode || S_ISDIR(n[i].mode)) dirmask |= (1 << i); } -- cgit v1.2.1