Skip to content

Commit 21baa6e

Browse files
wpalmergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f32e985 commit 21baa6e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

builtin/merge-tree.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ static void *result(struct merge_list *entry, unsigned long *size)
6060
{
6161
enum object_type type;
6262
struct blob *base, *our, *their;
63+
const char *path = entry->path;
6364

6465
if (!entry->stage)
6566
return read_sha1_file(entry->blob->object.sha1, &type, size);
@@ -76,7 +77,7 @@ static void *result(struct merge_list *entry, unsigned long *size)
7677
their = NULL;
7778
if (entry)
7879
their = entry->blob;
79-
return merge_file(entry->path, base, our, their, size);
80+
return merge_file(path, base, our, their, size);
8081
}
8182

8283
static void *origin(struct merge_list *entry, unsigned long *size)

t/t4300-merge-tree.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ EXPECTED
2424
test_cmp expected actual
2525
'
2626

27-
test_expect_failure 'file add !A, B' '
27+
test_expect_success 'file add !A, B' '
2828
cat >expected <<\EXPECTED &&
2929
added in local
3030
our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
@@ -195,7 +195,7 @@ EXPECTED
195195
test_cmp expected actual
196196
'
197197

198-
test_expect_failure 'file remove !A, B' '
198+
test_expect_success 'file remove !A, B' '
199199
cat >expected <<\EXPECTED &&
200200
removed in remote
201201
base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
@@ -213,7 +213,7 @@ EXPECTED
213213
test_cmp expected actual
214214
'
215215

216-
test_expect_failure 'file change A, remove B' '
216+
test_expect_success 'file change A, remove B' '
217217
cat >expected <<\EXPECTED &&
218218
removed in remote
219219
base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE

0 commit comments

Comments
 (0)