Skip to content

Commit 5248a1a

Browse files
committed
tests: add test case for index reloads on merge
Adds a test case for the issue libgit2#4203, when diverging indexes on memory and disk cause git merge to abort with GIT_ECONFLICT
1 parent bb9e379 commit 5248a1a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/merge/workdir/simple.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,35 @@ void test_merge_workdir_simple__automerge(void)
168168
git_index_free(index);
169169
}
170170

171+
void test_merge_workdir_simple__index_reload(void)
172+
{
173+
git_repository *tmp_repo;
174+
git_annotated_commit *their_heads[1];
175+
git_oid their_oid;
176+
git_index_entry entry = {{0}};
177+
git_index *tmp_index;
178+
179+
cl_git_pass(git_repository_open(&tmp_repo, git_repository_workdir(repo)));
180+
cl_git_pass(git_repository_index(&tmp_index, tmp_repo));
181+
cl_git_pass(git_index_read(repo_index, 0));
182+
183+
entry.mode = GIT_FILEMODE_BLOB;
184+
cl_git_pass(git_oid_fromstr(&entry.id, "11deab00b2d3a6f5a3073988ac050c2d7b6655e2"));
185+
entry.path = "automergeable.txt";
186+
cl_git_pass(git_index_add(repo_index, &entry));
187+
188+
cl_git_pass(git_index_add_bypath(tmp_index, "automergeable.txt"));
189+
cl_git_pass(git_index_write(tmp_index));
190+
191+
cl_git_pass(git_oid_fromstr(&their_oid, THEIRS_SIMPLE_OID));
192+
cl_git_pass(git_annotated_commit_lookup(&their_heads[0], repo, &their_oid));
193+
cl_git_pass(git_merge(repo, (const git_annotated_commit **)their_heads, 1, NULL, NULL));
194+
195+
git_index_free(tmp_index);
196+
git_repository_free(tmp_repo);
197+
git_annotated_commit_free(their_heads[0]);
198+
}
199+
171200
void test_merge_workdir_simple__automerge_crlf(void)
172201
{
173202
#ifdef GIT_WIN32

0 commit comments

Comments
 (0)