Skip to content

Commit

Permalink
merge-tree: fix where two branches share no changes
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Will Palmer authored and Junio C Hamano committed Jul 14, 2010
1 parent f32e985 commit 21baa6e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion builtin/merge-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ static void *result(struct merge_list *entry, unsigned long *size)
{
enum object_type type;
struct blob *base, *our, *their;
const char *path = entry->path;

if (!entry->stage)
return read_sha1_file(entry->blob->object.sha1, &type, size);
Expand All @@ -76,7 +77,7 @@ static void *result(struct merge_list *entry, unsigned long *size)
their = NULL;
if (entry)
their = entry->blob;
return merge_file(entry->path, base, our, their, size);
return merge_file(path, base, our, their, size);
}

static void *origin(struct merge_list *entry, unsigned long *size)
Expand Down
6 changes: 3 additions & 3 deletions t/t4300-merge-tree.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ EXPECTED
test_cmp expected actual
'

test_expect_failure 'file add !A, B' '
test_expect_success 'file add !A, B' '
cat >expected <<\EXPECTED &&
added in local
our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
Expand Down Expand Up @@ -195,7 +195,7 @@ EXPECTED
test_cmp expected actual
'

test_expect_failure 'file remove !A, B' '
test_expect_success 'file remove !A, B' '
cat >expected <<\EXPECTED &&
removed in remote
base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
Expand All @@ -213,7 +213,7 @@ EXPECTED
test_cmp expected actual
'

test_expect_failure 'file change A, remove B' '
test_expect_success 'file change A, remove B' '
cat >expected <<\EXPECTED &&
removed in remote
base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
Expand Down

0 comments on commit 21baa6e

Please sign in to comment.