Commit bb9e3797ba08c8cb0e88b2e1dc63959fa8f084a9

Greg Collinge 2017-11-11T17:20:16

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
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;