aboutsummaryrefslogtreecommitdiff
path: root/unpack-trees.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-12-05 12:59:25 -0800
committerJunio C Hamano <gitster@pobox.com>2013-12-05 12:59:25 -0800
commit3979580265bac968c30ce203022d7a8294710909 (patch)
tree46597ff73917d723a1a285166042da516e5ce861 /unpack-trees.c
parent10167eb251e177349eebf24650d3c0cc26bd0d75 (diff)
parent77b43cac9feac1079f3643988cfadee63e4365f7 (diff)
downloadgit-3979580265bac968c30ce203022d7a8294710909.tar.gz
git-3979580265bac968c30ce203022d7a8294710909.tar.xz
Merge branch 'jk/two-way-merge-corner-case-fix'
Fix a rather longstanding corner-case bug in twoway "reset to there" merge, which is most often seen in "git am --abort". * jk/two-way-merge-corner-case-fix: t1005: add test for "read-tree --reset -u A B" t1005: reindent unpack-trees: fix "read-tree -u --reset A B" with conflicted index
Diffstat (limited to 'unpack-trees.c')
-rw-r--r--unpack-trees.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/unpack-trees.c b/unpack-trees.c
index 35cb05e92..ad3e9a04f 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1763,14 +1763,23 @@ int twoway_merge(const struct cache_entry * const *src,
newtree = NULL;
if (current) {
- if ((!oldtree && !newtree) || /* 4 and 5 */
- (!oldtree && newtree &&
- same(current, newtree)) || /* 6 and 7 */
- (oldtree && newtree &&
- same(oldtree, newtree)) || /* 14 and 15 */
- (oldtree && newtree &&
- !same(oldtree, newtree) && /* 18 and 19 */
- same(current, newtree))) {
+ if (current->ce_flags & CE_CONFLICTED) {
+ if (same(oldtree, newtree) || o->reset) {
+ if (!newtree)
+ return deleted_entry(current, current, o);
+ else
+ return merged_entry(newtree, current, o);
+ }
+ return o->gently ? -1 : reject_merge(current, o);
+ }
+ else if ((!oldtree && !newtree) || /* 4 and 5 */
+ (!oldtree && newtree &&
+ same(current, newtree)) || /* 6 and 7 */
+ (oldtree && newtree &&
+ same(oldtree, newtree)) || /* 14 and 15 */
+ (oldtree && newtree &&
+ !same(oldtree, newtree) && /* 18 and 19 */
+ same(current, newtree))) {
return keep_entry(current, o);
}
else if (oldtree && !newtree && same(current, oldtree)) {