summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-11-06 11:47:50 +0100
committerCarlos Martín Nieto <cmn@dwim.me>2014-11-07 08:33:27 +0100
commitf1a7906fdf0657fba88449bdab07237847f36670 (patch)
tree07898233baeaae810cec3993fe20c51fec18199d /tests
parentdd83e6021261192ac143076c7784c654ed1ad33c (diff)
downloadlibgit2-f1a7906fdf0657fba88449bdab07237847f36670.tar.gz
submodules: add failing test for stale module entries
We consider an entry in .gitmodules to mean that we have a submodule at a particular path, even if HEAD^{tree} and the index do not contain any reference to it. We should ignore that submodule entry and simply consider that path to be a regular directory.
Diffstat (limited to 'tests')
-rw-r--r--tests/status/submodules.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/status/submodules.c b/tests/status/submodules.c
index 63cf73f36..b0bb4524f 100644
--- a/tests/status/submodules.c
+++ b/tests/status/submodules.c
@@ -476,3 +476,51 @@ void test_status_submodules__broken_stuff_that_git_allows(void)
cl_assert_equal_i(7, counts.entry_count);
}
+void test_status_submodules__entry_but_dir_tracked(void)
+{
+ git_repository *repo;
+ git_status_list *status;
+ git_diff *diff;
+ git_index *index;
+ git_tree *tree;
+
+ cl_git_pass(git_repository_init(&repo, "mixed-submodule", 0));
+ cl_git_mkfile("mixed-submodule/.gitmodules", "[submodule \"sub\"]\n path = sub\n url = ../foo\n");
+ cl_git_pass(p_mkdir("mixed-submodule/sub", 0777));
+ cl_git_mkfile("mixed-submodule/sub/file", "");
+
+ /* Create the commit with sub/file as a file, and an entry for sub in the modules list */
+ {
+ git_oid tree_id, commit_id;
+ git_signature *sig;
+ git_reference *ref;
+
+ cl_git_pass(git_repository_index(&index, repo));
+ cl_git_pass(git_index_add_bypath(index, ".gitmodules"));
+ cl_git_pass(git_index_add_bypath(index, "sub/file"));
+ cl_git_pass(git_index_write(index));
+ cl_git_pass(git_index_write_tree(&tree_id, index));
+ cl_git_pass(git_signature_now(&sig, "Sloppy Submoduler", "sloppy@example.com"));
+ cl_git_pass(git_tree_lookup(&tree, repo, &tree_id));
+ cl_git_pass(git_commit_create(&commit_id, repo, NULL, sig, sig, NULL, "message", tree, 0, NULL));
+ cl_git_pass(git_reference_create(&ref, repo, "refs/heads/master", &commit_id, 1, sig, "commit: foo"));
+ git_reference_free(ref);
+ git_signature_free(sig);
+ }
+
+ cl_git_pass(git_diff_tree_to_index(&diff, repo, tree, index, NULL));
+ cl_assert_equal_i(0, git_diff_num_deltas(diff));
+ git_diff_free(diff);
+
+ cl_git_pass(git_diff_index_to_workdir(&diff, repo, index, NULL));
+ cl_assert_equal_i(0, git_diff_num_deltas(diff));
+ git_diff_free(diff);
+
+ cl_git_pass(git_status_list_new(&status, repo, NULL));
+ cl_assert_equal_i(0, git_status_list_entrycount(status));
+
+ git_status_list_free(status);
+ git_index_free(index);
+ git_tree_free(tree);
+ git_repository_free(repo);
+}