diff options
author | Etiene Dalcol <dalcol@etiene.net> | 2017-11-11 15:53:18 +0000 |
---|---|---|
committer | Etiene Dalcol <dalcol@etiene.net> | 2017-11-11 19:31:42 +0000 |
commit | 5248a1a5836707c33f2543f46f9e2254c03628cd (patch) | |
tree | 7e8cfbe4fa9eabd6e70695441f1e3af786fcc8c4 | |
parent | bb9e3797ba08c8cb0e88b2e1dc63959fa8f084a9 (diff) | |
download | libgit2-5248a1a5836707c33f2543f46f9e2254c03628cd.tar.gz |
tests: add test case for index reloads on merge
Adds a test case for the issue #4203, when diverging indexes
on memory and disk cause git merge to abort with GIT_ECONFLICT
-rw-r--r-- | tests/merge/workdir/simple.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/merge/workdir/simple.c b/tests/merge/workdir/simple.c index 964532e46..097ab71c5 100644 --- a/tests/merge/workdir/simple.c +++ b/tests/merge/workdir/simple.c @@ -168,6 +168,35 @@ void test_merge_workdir_simple__automerge(void) git_index_free(index); } +void test_merge_workdir_simple__index_reload(void) +{ + git_repository *tmp_repo; + git_annotated_commit *their_heads[1]; + git_oid their_oid; + git_index_entry entry = {{0}}; + git_index *tmp_index; + + cl_git_pass(git_repository_open(&tmp_repo, git_repository_workdir(repo))); + cl_git_pass(git_repository_index(&tmp_index, tmp_repo)); + cl_git_pass(git_index_read(repo_index, 0)); + + entry.mode = GIT_FILEMODE_BLOB; + cl_git_pass(git_oid_fromstr(&entry.id, "11deab00b2d3a6f5a3073988ac050c2d7b6655e2")); + entry.path = "automergeable.txt"; + cl_git_pass(git_index_add(repo_index, &entry)); + + cl_git_pass(git_index_add_bypath(tmp_index, "automergeable.txt")); + cl_git_pass(git_index_write(tmp_index)); + + cl_git_pass(git_oid_fromstr(&their_oid, THEIRS_SIMPLE_OID)); + cl_git_pass(git_annotated_commit_lookup(&their_heads[0], repo, &their_oid)); + cl_git_pass(git_merge(repo, (const git_annotated_commit **)their_heads, 1, NULL, NULL)); + + git_index_free(tmp_index); + git_repository_free(tmp_repo); + git_annotated_commit_free(their_heads[0]); +} + void test_merge_workdir_simple__automerge_crlf(void) { #ifdef GIT_WIN32 |