@matheusbsbs / matheus-bagliano / commits / 21baa6e0c5
Fork 0

merge-tree: fix where two branches share no changes

15b4f7a (merge-tree: use ll_merge() not xdl_merge(), 2010-01-16) introduced a regression to merge-tree to cause it to segfault when merging files which existed in one branch, but not in the other or in the merge-base. This was caused by referencing entry->path at a time when entry was known to be possibly-NULL. To correct the problem, we save the path of the entry we came in with, as the path should be the same among all the stages no matter which sides are involved in the merge. Signed-off-by: Will Palmer <wmpalmer@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Will Palmer committed Jul 14, 2010 at 18:04 UTC 21baa6e0c56d229866c02c4b42b8b53af648d853
2 files changed +5 -4
builtin/merge-tree.c
+2 -1
@@ -60,6 +60,7 @@ static void *result(struct merge_list *entry, unsigned long *size)
60 {
61 enum object_type type;
62 struct blob *base, *our, *their;
63 + const char *path = entry->path;
64
65 if (!entry->stage)
66 return read_sha1_file(entry->blob->object.sha1, &type, size);
@@ -76,7 +77,7 @@ static void *result(struct merge_list *entry, unsigned long *size)
77 their = NULL;
78 if (entry)
79 their = entry->blob;
79 - return merge_file(entry->path, base, our, their, size);
80 + return merge_file(path, base, our, their, size);
81 }
82
83 static void *origin(struct merge_list *entry, unsigned long *size)
t/t4300-merge-tree.sh
+3 -3
@@ -24,7 +24,7 @@ EXPECTED
24 test_cmp expected actual
25 '
26
27 -test_expect_failure 'file add !A, B' '
27 +test_expect_success 'file add !A, B' '
28 cat >expected <<\EXPECTED &&
29 added in local
30 our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
@@ -195,7 +195,7 @@ EXPECTED
195 test_cmp expected actual
196 '
197
198 -test_expect_failure 'file remove !A, B' '
198 +test_expect_success 'file remove !A, B' '
199 cat >expected <<\EXPECTED &&
200 removed in remote
201 base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
@@ -213,7 +213,7 @@ EXPECTED
213 test_cmp expected actual
214 '
215
216 -test_expect_failure 'file change A, remove B' '
216 +test_expect_success 'file change A, remove B' '
217 cat >expected <<\EXPECTED &&
218 removed in remote
219 base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE