From b8acb775e25c76f07dac8855ad0a88b37f7b2f17 Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Thu, 7 Mar 2013 22:15:40 +0100 Subject: Added some tests for issue #1397 Signed-off-by: Sven Strickroth --- tests-clar/diff/tree.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests-clar/diff/tree.c') diff --git a/tests-clar/diff/tree.c b/tests-clar/diff/tree.c index e86f8d538..06e649979 100644 --- a/tests-clar/diff/tree.c +++ b/tests-clar/diff/tree.c @@ -431,3 +431,28 @@ void test_diff_tree__regular_blob_mode_changed_to_executable_file(void) cl_assert_equal_i(0, expect.file_status[GIT_DELTA_ADDED]); cl_assert_equal_i(0, expect.file_status[GIT_DELTA_TYPECHANGE]); } + +void test_diff_tree__issue_1397(void) +{ + // this test shows, that it is not needed + git_config *cfg; + g_repo = cl_git_sandbox_init("issue_1397"); + + cl_git_pass(git_repository_config(&cfg, g_repo)); + cl_git_pass(git_config_set_bool(cfg, "core.autocrlf", true)); + git_config_free(cfg); + + cl_assert((a = resolve_commit_oid_to_tree(g_repo, "8a7ef04")) != NULL); + cl_assert((b = resolve_commit_oid_to_tree(g_repo, "7f483a7")) != NULL); + + cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, &opts)); + + cl_git_pass(git_diff_foreach( + diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &expect)); + + cl_assert_equal_i(1, expect.files); + cl_assert_equal_i(0, expect.file_status[GIT_DELTA_DELETED]); + cl_assert_equal_i(1, expect.file_status[GIT_DELTA_MODIFIED]); + cl_assert_equal_i(0, expect.file_status[GIT_DELTA_ADDED]); + cl_assert_equal_i(0, expect.file_status[GIT_DELTA_TYPECHANGE]); +} -- cgit v1.2.1 From 1098cfaecae823ede02881f995f18aee2908b89f Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Fri, 22 Mar 2013 14:52:29 -0700 Subject: Test fixes and cleanup This fixes some places where the new tests were leaving the test area in a bad state or were freeing data they should not free. It also removes code that is extraneous to the core issue and fixes an invalid SHA being looked up in one of the tests (which was failing, but for the wrong reason). --- tests-clar/diff/tree.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'tests-clar/diff/tree.c') diff --git a/tests-clar/diff/tree.c b/tests-clar/diff/tree.c index 06e649979..850feefde 100644 --- a/tests-clar/diff/tree.c +++ b/tests-clar/diff/tree.c @@ -434,13 +434,11 @@ void test_diff_tree__regular_blob_mode_changed_to_executable_file(void) void test_diff_tree__issue_1397(void) { - // this test shows, that it is not needed - git_config *cfg; + /* this test shows that it is not needed */ + g_repo = cl_git_sandbox_init("issue_1397"); - cl_git_pass(git_repository_config(&cfg, g_repo)); - cl_git_pass(git_config_set_bool(cfg, "core.autocrlf", true)); - git_config_free(cfg); + cl_repo_set_bool(g_repo, "core.autocrlf", true); cl_assert((a = resolve_commit_oid_to_tree(g_repo, "8a7ef04")) != NULL); cl_assert((b = resolve_commit_oid_to_tree(g_repo, "7f483a7")) != NULL); -- cgit v1.2.1