mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-03 17:55:01 +00:00
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.
This commit is contained in:
parent
dd83e60212
commit
f1a7906fdf
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user