diff options
author | Edward Thomson <ethomson@microsoft.com> | 2015-05-19 01:15:17 +0300 |
---|---|---|
committer | Edward Thomson <ethomson@microsoft.com> | 2015-05-28 16:44:18 +0300 |
commit | 191e97a02b3360820177ed7642116796551ce1f6 (patch) | |
tree | 2fe934a99dc08468b22344d074d1915e2d69440a /tests/status | |
parent | b22369efa243022ff42582b559ddb6c6e05af2b1 (diff) |
diff conflicts: don't include incorrect ID
Since a diff entry only concerns a single entry, zero the information
for the index side of a conflict. (The index entry would otherwise
erroneously include the lowest-stage index entry - generally the
ancestor of a conflict.)
Test that during status, the index side of the conflict is empty.
Diffstat (limited to 'tests/status')
-rw-r--r-- | tests/status/worktree.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/status/worktree.c b/tests/status/worktree.c index 9be0a4172..e272c0a10 100644 --- a/tests/status/worktree.c +++ b/tests/status/worktree.c @@ -645,6 +645,52 @@ void test_status_worktree__conflicted_item(void) git_index_free(index); } +void test_status_worktree__conflict_has_no_oid(void) +{ + git_repository *repo = cl_git_sandbox_init("status"); + git_index *index; + git_index_entry entry = {0}; + git_status_list *statuslist; + const git_status_entry *status; + git_oid zero_id = {0}; + + entry.mode = 0100644; + entry.path = "modified_file"; + git_oid_fromstr(&entry.id, "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"); + + cl_git_pass(git_repository_index(&index, repo)); + cl_git_pass(git_index_conflict_add(index, &entry, &entry, &entry)); + + git_status_list_new(&statuslist, repo, NULL); + + cl_assert_equal_i(16, git_status_list_entrycount(statuslist)); + + status = git_status_byindex(statuslist, 2); + + cl_assert_equal_i(GIT_STATUS_CONFLICTED, status->status); + cl_assert_equal_s("modified_file", status->head_to_index->old_file.path); + cl_assert(!git_oid_equal(&zero_id, &status->head_to_index->old_file.id)); + cl_assert(0 != status->head_to_index->old_file.mode); + cl_assert_equal_s("modified_file", status->head_to_index->new_file.path); + cl_assert_equal_oid(&zero_id, &status->head_to_index->new_file.id); + cl_assert_equal_i(0, status->head_to_index->new_file.mode); + cl_assert_equal_i(0, status->head_to_index->new_file.size); + + cl_assert_equal_s("modified_file", status->index_to_workdir->old_file.path); + cl_assert_equal_oid(&zero_id, &status->index_to_workdir->old_file.id); + cl_assert_equal_i(0, status->index_to_workdir->old_file.mode); + cl_assert_equal_i(0, status->index_to_workdir->old_file.size); + cl_assert_equal_s("modified_file", status->index_to_workdir->new_file.path); + cl_assert( + !git_oid_equal(&zero_id, &status->index_to_workdir->new_file.id) || + !(status->index_to_workdir->new_file.flags & GIT_DIFF_FLAG_VALID_ID)); + cl_assert(0 != status->index_to_workdir->new_file.mode); + cl_assert(0 != status->index_to_workdir->new_file.size); + + git_index_free(index); + git_status_list_free(statuslist); +} + static void stage_and_commit(git_repository *repo, const char *path) { git_index *index; |