Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-05-19 00:01:37 +0300
committerEdward Thomson <ethomson@microsoft.com>2015-05-28 16:44:14 +0300
commitb22369efa243022ff42582b559ddb6c6e05af2b1 (patch)
tree752901b45885cc77fcb9d6ebedc7b452a1ef8e14
parentbb815157da1b3545d475a678e4db5292f6a723b2 (diff)
diff conflicts: test index to workdir w/ conflicts
-rw-r--r--tests/diff/workdir.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/diff/workdir.c b/tests/diff/workdir.c
index 963be9481..460f1b592 100644
--- a/tests/diff/workdir.c
+++ b/tests/diff/workdir.c
@@ -68,6 +68,51 @@ void test_diff_workdir__to_index(void)
git_diff_free(diff);
}
+void test_diff_workdir__to_index_with_conflicts(void)
+{
+ git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
+ git_diff *diff = NULL;
+ git_index *index;
+ git_index_entry our_entry = {0}, their_entry = {0};
+ diff_expects exp = {0};
+
+ g_repo = cl_git_sandbox_init("status");
+
+ opts.context_lines = 3;
+ opts.interhunk_lines = 1;
+
+ /* Adding an entry that represents a rename gets two files in conflict */
+ our_entry.path = "subdir/modified_file";
+ our_entry.mode = 0100644;
+
+ their_entry.path = "subdir/rename_conflict";
+ their_entry.mode = 0100644;
+
+ cl_git_pass(git_repository_index(&index, g_repo));
+ cl_git_pass(git_index_conflict_add(index, NULL, &our_entry, &their_entry));
+
+ cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, index, &opts));
+
+ cl_git_pass(diff_foreach_via_iterator(
+ diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+
+ cl_assert_equal_i(9, exp.files);
+ cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
+ cl_assert_equal_i(4, exp.file_status[GIT_DELTA_DELETED]);
+ cl_assert_equal_i(3, exp.file_status[GIT_DELTA_MODIFIED]);
+ cl_assert_equal_i(2, exp.file_status[GIT_DELTA_CONFLICTED]);
+
+ cl_assert_equal_i(7, exp.hunks);
+
+ cl_assert_equal_i(12, exp.lines);
+ cl_assert_equal_i(4, exp.line_ctxt);
+ cl_assert_equal_i(3, exp.line_adds);
+ cl_assert_equal_i(5, exp.line_dels);
+
+ git_diff_free(diff);
+ git_index_free(index);
+}
+
void test_diff_workdir__to_index_with_assume_unchanged(void)
{
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;