Merge branch 'en/dirty-merge-fixes'
The recursive merge strategy did not properly ensure there was no change between HEAD and the index before performing its operation, which has been corrected. * en/dirty-merge-fixes: merge: fix misleading pre-merge check documentation merge-recursive: enforce rule that index matches head before merging t6044: add more testcases with staged changes before a merge is invoked merge-recursive: fix assumption that head tree being merged is HEAD merge-recursive: make sure when we say we abort that we actually abort t6044: add a testcase for index matching head, when head doesn't match HEAD t6044: verify that merges expected to abort actually abort index_has_changes(): avoid assuming operating on the_index read-cache.c: move index_has_changes() from merge.c
This commit is contained in:
@ -3281,6 +3281,13 @@ int merge_trees(struct merge_options *o,
|
||||
struct tree **result)
|
||||
{
|
||||
int code, clean;
|
||||
struct strbuf sb = STRBUF_INIT;
|
||||
|
||||
if (!o->call_depth && index_has_changes(&the_index, head, &sb)) {
|
||||
err(o, _("Your local changes to the following files would be overwritten by merge:\n %s"),
|
||||
sb.buf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (o->subtree_shift) {
|
||||
merge = shift_tree_object(head, merge, o->subtree_shift);
|
||||
@ -3288,13 +3295,6 @@ int merge_trees(struct merge_options *o,
|
||||
}
|
||||
|
||||
if (oid_eq(&common->object.oid, &merge->object.oid)) {
|
||||
struct strbuf sb = STRBUF_INIT;
|
||||
|
||||
if (!o->call_depth && 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;
|
||||
|
Reference in New Issue
Block a user