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:
authorRussell Belfer <rb@github.com>2013-07-03 03:49:57 +0400
committerRussell Belfer <rb@github.com>2013-07-10 23:15:03 +0400
commit125655fe3f0caf8b3d9fff2ec45ec694b34eed04 (patch)
tree677bb10e844cc18726ae2720e49987bd7aedfef0 /tests-clar/diff
parent9564229af42b68d205376853410c55b957546a14 (diff)
Untracked directories with .git should be ignored
This restores a behavior that was accidentally lost during some diff refactoring where an untracked directory that contains a .git item should be treated as IGNORED, not as UNTRACKED. The submodule code already detects this, but the diff code was not handling the scenario right. This also updates a number of existing tests that were actually exercising the behavior but did not have the right expectations in place. It actually makes the new `test_diff_submodules__diff_ignore_options` test feel much better because the "not-a-submodule" entries are now ignored instead of showing up as untracked items. Fixes #1697
Diffstat (limited to 'tests-clar/diff')
-rw-r--r--tests-clar/diff/submodules.c47
-rw-r--r--tests-clar/diff/workdir.c7
2 files changed, 12 insertions, 42 deletions
diff --git a/tests-clar/diff/submodules.c b/tests-clar/diff/submodules.c
index fe9cf1d98..94804db22 100644
--- a/tests-clar/diff/submodules.c
+++ b/tests-clar/diff/submodules.c
@@ -5,36 +5,13 @@
static git_repository *g_repo = NULL;
-static void setup_submodules(void)
-{
- g_repo = cl_git_sandbox_init("submodules");
- cl_fixture_sandbox("testrepo.git");
- rewrite_gitmodules(git_repository_workdir(g_repo));
- p_rename("submodules/testrepo/.gitted", "submodules/testrepo/.git");
-}
-
-static void setup_submodules2(void)
-{
- g_repo = cl_git_sandbox_init("submod2");
-
- cl_fixture_sandbox("submod2_target");
- p_rename("submod2_target/.gitted", "submod2_target/.git");
-
- rewrite_gitmodules(git_repository_workdir(g_repo));
- p_rename("submod2/not-submodule/.gitted", "submod2/not-submodule/.git");
- p_rename("submod2/not/.gitted", "submod2/not/.git");
-}
-
void test_diff_submodules__initialize(void)
{
}
void test_diff_submodules__cleanup(void)
{
- cl_git_sandbox_cleanup();
-
- cl_fixture_cleanup("testrepo.git");
- cl_fixture_cleanup("submod2_target");
+ cleanup_fixture_submodules();
}
static void check_diff_patches_at_line(
@@ -88,7 +65,7 @@ void test_diff_submodules__unmodified_submodule(void)
"<END>"
};
- setup_submodules();
+ g_repo = setup_fixture_submodules();
opts.flags = GIT_DIFF_INCLUDE_IGNORED |
GIT_DIFF_INCLUDE_UNTRACKED |
@@ -115,7 +92,7 @@ void test_diff_submodules__dirty_submodule(void)
"<END>"
};
- setup_submodules();
+ g_repo = setup_fixture_submodules();
cl_git_rewritefile("submodules/testrepo/README", "heyheyhey");
cl_git_mkfile("submodules/testrepo/all_new.txt", "never seen before");
@@ -141,7 +118,7 @@ void test_diff_submodules__dirty_submodule_2(void)
"<END>"
};
- setup_submodules();
+ g_repo = setup_fixture_submodules();
cl_git_pass(git_submodule_reload_all(g_repo));
@@ -190,8 +167,6 @@ void test_diff_submodules__submod2_index_to_wd(void)
git_diff_list *diff = NULL;
static const char *expected[] = {
"<SKIP>", /* .gitmodules */
- NULL, /* not-submodule */
- NULL, /* not */
"diff --git a/sm_changed_file b/sm_changed_file\nindex 4800958..4800958 160000\n--- a/sm_changed_file\n+++ b/sm_changed_file\n@@ -1 +1 @@\n-Subproject commit 480095882d281ed676fe5b863569520e54a7d5c0\n+Subproject commit 480095882d281ed676fe5b863569520e54a7d5c0-dirty\n", /* sm_changed_file */
"diff --git a/sm_changed_head b/sm_changed_head\nindex 4800958..3d9386c 160000\n--- a/sm_changed_head\n+++ b/sm_changed_head\n@@ -1 +1 @@\n-Subproject commit 480095882d281ed676fe5b863569520e54a7d5c0\n+Subproject commit 3d9386c507f6b093471a3e324085657a3c2b4247\n", /* sm_changed_head */
"diff --git a/sm_changed_index b/sm_changed_index\nindex 4800958..4800958 160000\n--- a/sm_changed_index\n+++ b/sm_changed_index\n@@ -1 +1 @@\n-Subproject commit 480095882d281ed676fe5b863569520e54a7d5c0\n+Subproject commit 480095882d281ed676fe5b863569520e54a7d5c0-dirty\n", /* sm_changed_index */
@@ -200,7 +175,7 @@ void test_diff_submodules__submod2_index_to_wd(void)
"<END>"
};
- setup_submodules2();
+ g_repo = setup_fixture_submod2();
opts.flags = GIT_DIFF_INCLUDE_UNTRACKED;
opts.old_prefix = "a"; opts.new_prefix = "b";
@@ -221,7 +196,7 @@ void test_diff_submodules__submod2_head_to_index(void)
"<END>"
};
- setup_submodules2();
+ g_repo = setup_fixture_submod2();
cl_git_pass(git_repository_head_tree(&head, g_repo));
@@ -261,7 +236,7 @@ void test_diff_submodules__invalid_cache(void)
"<END>"
};
- setup_submodules2();
+ g_repo = setup_fixture_submod2();
opts.flags = GIT_DIFF_INCLUDE_UNTRACKED;
opts.old_prefix = "a"; opts.new_prefix = "b";
@@ -390,8 +365,6 @@ void test_diff_submodules__diff_ignore_options(void)
git_config *cfg;
static const char *expected_normal[] = {
"<SKIP>", /* .gitmodules */
- NULL, /* not-submodule */
- NULL, /* not */
"diff --git a/sm_changed_file b/sm_changed_file\nindex 4800958..4800958 160000\n--- a/sm_changed_file\n+++ b/sm_changed_file\n@@ -1 +1 @@\n-Subproject commit 480095882d281ed676fe5b863569520e54a7d5c0\n+Subproject commit 480095882d281ed676fe5b863569520e54a7d5c0-dirty\n", /* sm_changed_file */
"diff --git a/sm_changed_head b/sm_changed_head\nindex 4800958..3d9386c 160000\n--- a/sm_changed_head\n+++ b/sm_changed_head\n@@ -1 +1 @@\n-Subproject commit 480095882d281ed676fe5b863569520e54a7d5c0\n+Subproject commit 3d9386c507f6b093471a3e324085657a3c2b4247\n", /* sm_changed_head */
"diff --git a/sm_changed_index b/sm_changed_index\nindex 4800958..4800958 160000\n--- a/sm_changed_index\n+++ b/sm_changed_index\n@@ -1 +1 @@\n-Subproject commit 480095882d281ed676fe5b863569520e54a7d5c0\n+Subproject commit 480095882d281ed676fe5b863569520e54a7d5c0-dirty\n", /* sm_changed_index */
@@ -401,20 +374,16 @@ void test_diff_submodules__diff_ignore_options(void)
};
static const char *expected_ignore_all[] = {
"<SKIP>", /* .gitmodules */
- NULL, /* not-submodule */
- NULL, /* not */
"<END>"
};
static const char *expected_ignore_dirty[] = {
"<SKIP>", /* .gitmodules */
- NULL, /* not-submodule */
- NULL, /* not */
"diff --git a/sm_changed_head b/sm_changed_head\nindex 4800958..3d9386c 160000\n--- a/sm_changed_head\n+++ b/sm_changed_head\n@@ -1 +1 @@\n-Subproject commit 480095882d281ed676fe5b863569520e54a7d5c0\n+Subproject commit 3d9386c507f6b093471a3e324085657a3c2b4247\n", /* sm_changed_head */
"diff --git a/sm_missing_commits b/sm_missing_commits\nindex 4800958..5e49635 160000\n--- a/sm_missing_commits\n+++ b/sm_missing_commits\n@@ -1 +1 @@\n-Subproject commit 480095882d281ed676fe5b863569520e54a7d5c0\n+Subproject commit 5e4963595a9774b90524d35a807169049de8ccad\n", /* sm_missing_commits */
"<END>"
};
- setup_submodules2();
+ g_repo = setup_fixture_submod2();
opts.flags = GIT_DIFF_INCLUDE_UNTRACKED;
opts.old_prefix = "a"; opts.new_prefix = "b";
diff --git a/tests-clar/diff/workdir.c b/tests-clar/diff/workdir.c
index 6a2504d09..c7fac1e48 100644
--- a/tests-clar/diff/workdir.c
+++ b/tests-clar/diff/workdir.c
@@ -776,6 +776,7 @@ void test_diff_workdir__submodules(void)
opts.flags =
GIT_DIFF_INCLUDE_UNTRACKED |
+ GIT_DIFF_INCLUDE_IGNORED |
GIT_DIFF_RECURSE_UNTRACKED_DIRS |
GIT_DIFF_INCLUDE_UNTRACKED_CONTENT;
@@ -806,7 +807,7 @@ void test_diff_workdir__submodules(void)
* only significant difference is that those Added items will show up
* as Untracked items in the pure libgit2 diff.
*
- * Then add in the two extra untracked items "not" and "not-submodule"
+ * Then add in the two extra ignored items "not" and "not-submodule"
* to get the 12 files reported here.
*/
@@ -815,8 +816,8 @@ void test_diff_workdir__submodules(void)
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_DELETED]);
cl_assert_equal_i(2, exp.file_status[GIT_DELTA_MODIFIED]);
- cl_assert_equal_i(0, exp.file_status[GIT_DELTA_IGNORED]);
- cl_assert_equal_i(10, exp.file_status[GIT_DELTA_UNTRACKED]);
+ cl_assert_equal_i(2, exp.file_status[GIT_DELTA_IGNORED]);
+ cl_assert_equal_i(8, exp.file_status[GIT_DELTA_UNTRACKED]);
/* the following numbers match "git diff 873585" exactly */