summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Roben <adam@roben.org>2012-06-27 12:09:08 -0400
committerAdam Roben <adam@roben.org>2012-06-27 12:09:08 -0400
commit01b3253502a67be5170bc138321ddbf0750a635f (patch)
tree10833f40e1473c79751ebff9da085798a2548afb
parented754a75e145352c02da62b5d56df5866d7eec26 (diff)
downloadlibgit2-filename-containing-bracket.tar.gz
Add a test for getting status of files containing bracketsfilename-containing-bracket
This test fails currently.
-rw-r--r--tests-clar/status/worktree.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/tests-clar/status/worktree.c b/tests-clar/status/worktree.c
index 3670b72a8..04ca788fa 100644
--- a/tests-clar/status/worktree.c
+++ b/tests-clar/status/worktree.c
@@ -517,6 +517,69 @@ void test_status_worktree__status_file_with_clean_index_and_empty_workdir(void)
cl_git_pass(p_unlink("my-index"));
}
+void test_status_worktree__bracket_in_filename(void)
+{
+ git_repository *repo;
+ git_index *index;
+ status_entry_single result;
+ unsigned int status_flags;
+
+#define FILE_WITH_BRACKET "LICENSE[1].md"
+
+ cl_git_pass(git_repository_init(&repo, "with_bracket", 0));
+ cl_git_mkfile("with_bracket/" FILE_WITH_BRACKET, "I have a bracket in my name\n");
+
+ /* file is new to working directory */
+
+ memset(&result, 0, sizeof(result));
+ cl_git_pass(git_status_foreach(repo, cb_status__single, &result));
+ cl_assert_equal_i(1, result.count);
+ cl_assert(result.status == GIT_STATUS_WT_NEW);
+
+ cl_git_pass(git_status_file(&status_flags, repo, FILE_WITH_BRACKET));
+ cl_assert(status_flags == GIT_STATUS_WT_NEW);
+
+ /* ignore the file */
+
+ cl_git_rewritefile("with_bracket/.gitignore", "*.md\n.gitignore\n");
+
+ memset(&result, 0, sizeof(result));
+ cl_git_pass(git_status_foreach(repo, cb_status__single, &result));
+ cl_assert_equal_i(2, result.count);
+ cl_assert(result.status == GIT_STATUS_IGNORED);
+
+ cl_git_pass(git_status_file(&status_flags, repo, FILE_WITH_BRACKET));
+ cl_assert(status_flags == GIT_STATUS_IGNORED);
+
+ /* don't ignore the file */
+
+ cl_git_rewritefile("with_bracket/.gitignore", ".gitignore\n");
+
+ memset(&result, 0, sizeof(result));
+ cl_git_pass(git_status_foreach(repo, cb_status__single, &result));
+ cl_assert_equal_i(2, result.count);
+ cl_assert(result.status == GIT_STATUS_WT_NEW);
+
+ cl_git_pass(git_status_file(&status_flags, repo, FILE_WITH_BRACKET));
+ cl_assert(status_flags == GIT_STATUS_WT_NEW);
+
+ /* add the file to the index */
+
+ cl_git_pass(git_repository_index(&index, repo));
+ cl_git_pass(git_index_add(index, FILE_WITH_BRACKET, 0));
+ cl_git_pass(git_index_write(index));
+
+ memset(&result, 0, sizeof(result));
+ cl_git_pass(git_status_foreach(repo, cb_status__single, &result));
+ cl_assert_equal_i(2, result.count);
+ cl_assert(result.status == GIT_STATUS_INDEX_NEW);
+
+ cl_git_pass(git_status_file(&status_flags, repo, FILE_WITH_BRACKET));
+ cl_assert(status_flags == GIT_STATUS_INDEX_NEW);
+
+ git_index_free(index);
+ git_repository_free(repo);
+}
void test_status_worktree__space_in_filename(void)
{