path: root/builtin/merge-tree.c
diff options
authorJohn Keeping <>2013-05-06 15:20:54 (GMT)
committerJunio C Hamano <>2013-05-07 05:17:00 (GMT)
commit94883b4302118fe6ea50028d02bb453c9af38b66 (patch)
tree720fe7f32b19b31a4ebf48469c0bff77e57a1c1d /builtin/merge-tree.c
parentab5f42422d7e025c3151d91cc5ec0d20b9a80922 (diff)
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 <>
Diffstat (limited to 'builtin/merge-tree.c')
1 files changed, 5 insertions, 1 deletions
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index ec49917..61cbde4 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);