summaryrefslogtreecommitdiff
path: root/unpack-trees.c
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2014-08-12 17:03:18 -0700
committerJunio C Hamano <gitster@pobox.com>2014-08-25 15:17:34 -0700
commit6a143aa2b23b97fa8363e2f4fd16f23b4c5b104d (patch)
tree6b8755ddc6c9210f39a5f477c41d859e9114d3c5 /unpack-trees.c
parent6c1db1b38886f70165cb9f5822b1a2e99a2c331b (diff)
downloadgit-6a143aa2b23b97fa8363e2f4fd16f23b4c5b104d.tar.gz
checkout -m: attempt merge when deletion of path was stagedjn/unpack-trees-checkout-m-carry-deletion
twoway_merge() is missing an o->gently check in the case where a file that needs to be modified is missing from the index but present in the old and new trees. As a result, in this case 'git checkout -m' errors out instead of trying to perform a merge. Fix it by checking o->gently. While at it, inline the o->gently check into reject_merge to prevent future call sites from making the same mistake. Noticed by code inspection. The test for the motivating case was added by JC. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'unpack-trees.c')
-rw-r--r--unpack-trees.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/unpack-trees.c b/unpack-trees.c
index 187b15b56f..6c45af7248 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1178,7 +1178,8 @@ return_failed:
static int reject_merge(const struct cache_entry *ce,
struct unpack_trees_options *o)
{
- return add_rejected_path(o, ERROR_WOULD_OVERWRITE, ce->name);
+ return o->gently ? -1 :
+ add_rejected_path(o, ERROR_WOULD_OVERWRITE, ce->name);
}
static int same(const struct cache_entry *a, const struct cache_entry *b)
@@ -1633,7 +1634,7 @@ int threeway_merge(const struct cache_entry * const *stages,
/* #14, #14ALT, #2ALT */
if (remote && !df_conflict_head && head_match && !remote_match) {
if (index && !same(index, remote) && !same(index, head))
- return o->gently ? -1 : reject_merge(index, o);
+ return reject_merge(index, o);
return merged_entry(remote, index, o);
}
/*
@@ -1641,7 +1642,7 @@ int threeway_merge(const struct cache_entry * const *stages,
* make sure that it matches head.
*/
if (index && !same(index, head))
- return o->gently ? -1 : reject_merge(index, o);
+ return reject_merge(index, o);
if (head) {
/* #5ALT, #15 */
@@ -1770,7 +1771,7 @@ int twoway_merge(const struct cache_entry * const *src,
else
return merged_entry(newtree, current, o);
}
- return o->gently ? -1 : reject_merge(current, o);
+ return reject_merge(current, o);
} else if ((!oldtree && !newtree) || /* 4 and 5 */
(!oldtree && newtree &&
same(current, newtree)) || /* 6 and 7 */
@@ -1788,7 +1789,7 @@ int twoway_merge(const struct cache_entry * const *src,
/* 20 or 21 */
return merged_entry(newtree, current, o);
} else
- return o->gently ? -1 : reject_merge(current, o);
+ return reject_merge(current, o);
}
else if (newtree) {
if (oldtree && !o->initial_checkout) {