1
0
mirror of https://github.com/git/git synced 2024-07-05 00:58:49 +00:00

merge-recursive: always roll back lock in merge_recursive_generic()

If we return early, or if `active_cache_changed` is false, we forget to
roll back the lockfile.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Martin Ågren 2018-02-28 20:07:56 +01:00 committed by Junio C Hamano
parent 6481652432
commit 51d3f43d2f

View File

@ -2218,12 +2218,15 @@ int merge_recursive_generic(struct merge_options *o,
hold_locked_index(&lock, LOCK_DIE_ON_ERROR);
clean = merge_recursive(o, head_commit, next_commit, ca,
result);
if (clean < 0)
if (clean < 0) {
rollback_lock_file(&lock);
return clean;
}
if (active_cache_changed &&
write_locked_index(&the_index, &lock, COMMIT_LOCK))
return err(o, _("Unable to write index."));
rollback_lock_file(&lock);
return clean ? 0 : 1;
}