merge: reload index before git_merge If the index in memory is different from the index on the disk, previously merge would abort with GIT_ECONFLICT. Reload the index before merging to fix this. Fixes #4203
diff --git a/src/merge.c b/src/merge.c
index 72cfa46..e9616a9 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -3239,6 +3239,9 @@ int git_merge(
assert(repo && their_heads);
+ git_repository_index(&index, repo);
+ git_index_read(index, 0);
+
if (their_heads_len != 1) {
giterr_set(GITERR_MERGE, "can only merge a single branch");
return -1;