merge-recursive: avoid incorporating uncommitted changes in a merge
[gitweb.git] / merge-recursive.c
index 9fb0b9f8fdfe12b58b5876a4984f4bf9a9f5c0fb..be01f528cb4849fc68c7f082e1d65709f86147d5 100644 (file)
@@ -1952,6 +1952,13 @@ int merge_trees(struct merge_options *o,
        }
 
        if (oid_eq(&common->object.oid, &merge->object.oid)) {
+               struct strbuf sb = STRBUF_INIT;
+
+               if (index_has_changes(&sb)) {
+                       err(o, _("Dirty index: cannot merge (dirty: %s)"),
+                           sb.buf);
+                       return 0;
+               }
                output(o, 0, _("Already up to date!"));
                *result = head;
                return 1;