summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott J. Goldman <scottjg@github.com>2012-11-18 16:59:42 -0800
committerScott J. Goldman <scottjg@github.com>2012-11-18 16:59:42 -0800
commit1876360f813da8e6aba763baded5dcb004d9999c (patch)
tree66b2cef0220d13f6543f1b0e3a2d56e42e759f43
parent0d778b1a892d53161b4392ed75adcb3dcfe1a3df (diff)
downloadlibgit2-filename-validation.tar.gz
Add a test for invalid filenames while writing tree from indexfilename-validation
-rw-r--r--tests-clar/index/tests.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests-clar/index/tests.c b/tests-clar/index/tests.c
index d3f6f2582..3b71b704d 100644
--- a/tests-clar/index/tests.c
+++ b/tests-clar/index/tests.c
@@ -261,3 +261,30 @@ void test_index_tests__add_from_workdir_to_a_bare_repository_returns_EBAREPO(voi
git_index_free(index);
git_repository_free(bare_repo);
}
+
+/* Test that writing an invalid filename fails */
+void test_index_tests__write_invalid_filename(void)
+{
+ git_repository *repo;
+ git_index *index;
+ git_oid expected;
+
+ p_mkdir("read_tree", 0700);
+
+ cl_git_pass(git_repository_init(&repo, "./read_tree", 0));
+ cl_git_pass(git_repository_index(&index, repo));
+
+ cl_assert(git_index_entrycount(index) == 0);
+
+ cl_git_mkfile("./read_tree/.git/hello", NULL);
+
+ cl_git_pass(git_index_add_from_workdir(index, ".git/hello"));
+
+ /* write-tree */
+ cl_git_fail(git_index_write_tree(&expected, index));
+
+ git_index_free(index);
+ git_repository_free(repo);
+
+ cl_fixture_cleanup("read_tree");
+}