[PATCH] read-tree: loosen too strict index requirements
This patch teaches read-tree 3-way merge that, when only "the other tree" changed a path, and if the index file already has the same change, we are not in a situation that would clobber the index and the work tree, and lets the merge succeed; this is case #14ALT in t1000 test. It does not change the result of the merge, but prevents it from failing when it does not have to. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
32192e6622
commit
036d51cc55
@ -280,6 +280,12 @@ static int threeway_merge(struct cache_entry *stages[4],
|
|||||||
}
|
}
|
||||||
/* otherwise we will apply the original rule */
|
/* otherwise we will apply the original rule */
|
||||||
}
|
}
|
||||||
|
/* #14ALT */
|
||||||
|
if (a && b && c && same(a, b) && !same(a, c)) {
|
||||||
|
if (old && same(old, c))
|
||||||
|
return merged_entry_allow_dirty(c, old, dst);
|
||||||
|
/* otherwise the regular rule applies */
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* If we have an entry in the index cache ("old"), then we want
|
* If we have an entry in the index cache ("old"), then we want
|
||||||
* to make sure that it matches any entries in stage 2 ("first
|
* to make sure that it matches any entries in stage 2 ("first
|
||||||
|
@ -464,6 +464,15 @@ test_expect_success \
|
|||||||
git-read-tree -m $tree_O $tree_A $tree_B &&
|
git-read-tree -m $tree_O $tree_A $tree_B &&
|
||||||
check_result"
|
check_result"
|
||||||
|
|
||||||
|
test_expect_success \
|
||||||
|
'14 - may match B in O && A && B && O==A && O!=B case' \
|
||||||
|
"rm -f .git/index NM &&
|
||||||
|
cp .orig-B/NM NM &&
|
||||||
|
git-update-cache --add NM &&
|
||||||
|
echo extra >>NM &&
|
||||||
|
git-read-tree -m $tree_O $tree_A $tree_B &&
|
||||||
|
check_result"
|
||||||
|
|
||||||
test_expect_failure \
|
test_expect_failure \
|
||||||
'14 (fail) - must match and be up-to-date in O && A && B && O==A && O!=B case' \
|
'14 (fail) - must match and be up-to-date in O && A && B && O==A && O!=B case' \
|
||||||
"rm -f .git/index NM &&
|
"rm -f .git/index NM &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user