summaryrefslogtreecommitdiff
path: root/tests/clone
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-03-12 01:09:13 +0100
committerCarlos Martín Nieto <cmn@dwim.me>2015-03-17 20:50:39 +0100
commitd23fb5c943c3f4accd8b5176db1b78d377bfec54 (patch)
treedd0ec9995b4b18f555573ee58a4c19986401e9f4 /tests/clone
parent9bbc8f350b80a5a6e94651ec667cf9e5d545b317 (diff)
downloadlibgit2-d23fb5c943c3f4accd8b5176db1b78d377bfec54.tar.gz
clone: add failing test for local transport with a tag
When there is a tag, we must make sure that we get all referenced objects from this tag as well. This failing test shows that e.g. when there is a tagged tree, we insert the top tree but do not descend, thus causing the clone to have broken links.
Diffstat (limited to 'tests/clone')
-rw-r--r--tests/clone/nonetwork.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/clone/nonetwork.c b/tests/clone/nonetwork.c
index 2a3157739..e4794fc14 100644
--- a/tests/clone/nonetwork.c
+++ b/tests/clone/nonetwork.c
@@ -246,6 +246,51 @@ void test_clone_nonetwork__can_detached_head(void)
cl_fixture_cleanup("./foo1");
}
+void test_clone_nonetwork__clone_tag_to_tree(void)
+{
+ git_repository *stage;
+ git_index_entry entry;
+ git_index *index;
+ git_odb *odb;
+ git_oid tree_id;
+ git_tree *tree;
+ git_reference *tag;
+ git_tree_entry *tentry;
+ const char *file_path = "some/deep/path.txt";
+ const char *file_content = "some content\n";
+ const char *tag_name = "refs/tags/tree-tag";
+
+ stage = cl_git_sandbox_init("testrepo.git");
+ cl_git_pass(git_repository_odb(&odb, stage));
+ cl_git_pass(git_index_new(&index));
+
+ memset(&entry, 0, sizeof(git_index_entry));
+ entry.path = file_path;
+ entry.mode = GIT_FILEMODE_BLOB;
+ cl_git_pass(git_odb_write(&entry.id, odb, file_content, strlen(file_content), GIT_OBJ_BLOB));
+
+ cl_git_pass(git_index_add(index, &entry));
+ cl_git_pass(git_index_write_tree_to(&tree_id, index, stage));
+ cl_git_pass(git_reference_create(&tag, stage, tag_name, &tree_id, 0, NULL));
+ git_reference_free(tag);
+ git_odb_free(odb);
+ git_index_free(index);
+
+ g_options.local = GIT_CLONE_NO_LOCAL;
+ cl_git_pass(git_clone(&g_repo, cl_git_path_url(git_repository_path(stage)), "./foo", &g_options));
+ git_repository_free(stage);
+
+ cl_git_pass(git_reference_lookup(&tag, g_repo, tag_name));
+ cl_git_pass(git_tree_lookup(&tree, g_repo, git_reference_target(tag)));
+ git_reference_free(tag);
+
+ cl_git_pass(git_tree_entry_bypath(&tentry, tree, file_path));
+ git_tree_entry_free(tentry);
+ git_tree_free(tree);
+
+ cl_fixture_cleanup("testrepo.git");
+}
+
static void assert_correct_reflog(const char *name)
{
git_reflog *log;