summaryrefslogtreecommitdiff
path: root/tests/object/tree/read.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/object/tree/read.c')
-rw-r--r--tests/object/tree/read.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/object/tree/read.c b/tests/object/tree/read.c
index a0eae11d1..1ba058fc0 100644
--- a/tests/object/tree/read.c
+++ b/tests/object/tree/read.c
@@ -73,3 +73,52 @@ void test_object_tree_read__two(void)
git_object_free(obj);
git_tree_free(tree);
}
+
+#define BIGFILE "bigfile"
+#define BIGFILE_SIZE (off_t)4 * 1024 * 1024 * 1024 /* 4 GiB */
+
+void test_object_tree_read__largefile(void)
+{
+ git_reference *ref;
+ git_commit *commit;
+ git_tree *tree;
+ git_oid oid;
+ const git_tree_entry *entry;
+ git_object *object;
+ git_buf file = GIT_BUF_INIT;
+ int fd;
+ git_index *idx;
+
+ if (!cl_is_env_set("GITTEST_INVASIVE_FS_SIZE"))
+ cl_skip();
+
+ cl_git_pass(git_reference_lookup(&ref, g_repo, "refs/heads/master"));
+ cl_git_pass(git_repository_index(&idx, g_repo));
+
+ cl_git_pass(git_buf_puts(&file, git_repository_workdir(g_repo)));
+ cl_git_pass(git_buf_joinpath(&file, file.ptr, BIGFILE));
+
+ fd = p_open(git_buf_cstr(&file), O_CREAT|O_RDWR, 0644);
+ cl_assert_(fd >= 0, "invalid file descriptor");
+
+ cl_must_pass(p_fallocate(fd, 0, BIGFILE_SIZE));
+ cl_must_pass(p_close(fd));
+
+ cl_git_pass(git_index_add_bypath(idx, BIGFILE));
+ cl_repo_commit_from_index(&oid, g_repo, NULL, 0, "bigfile");
+
+ cl_git_pass(git_commit_lookup(&commit, g_repo, &oid));
+ cl_git_pass(git_commit_tree(&tree, commit));
+
+ entry = git_tree_entry_byname(tree, BIGFILE);
+ cl_assert_(entry, "entry was NULL");
+
+ cl_git_pass(git_tree_entry_to_object(&object, g_repo, entry));
+
+ git_buf_dispose(&file);
+ git_object_free(object);
+ git_tree_free(tree);
+ git_index_free(idx);
+ git_commit_free(commit);
+ git_reference_free(ref);
+}