git-prompt.sh: don't put unsanitized branch names in $PS1
[gitweb.git] / unpack-trees.c
index 35cb05e92bed9fb273747adc4718458b9f500898..ad3e9a04fe8ccb9286b94480f4484b0569f70a57 100644 (file)
@@ -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)) {