diff options
author | Russell Belfer <rb@github.com> | 2013-03-26 03:40:16 +0400 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-03-26 03:40:16 +0400 |
commit | 0c289dd7c6831f4f402f9581b46d0c920053abf9 (patch) | |
tree | 9bfb8c6b15ccea8a8ad673b4f6eb74e1459684e8 /tests-clar/status | |
parent | f17951d6ea4ba18c68716a89d7b7464e40ec98f7 (diff) |
Recursing into ignored dirs for diff and status
This implements working versions of GIT_DIFF_RECURSE_IGNORED_DIRS
and GIT_STATUS_OPT_RECURSE_IGNORED_DIRS along with some tests for
the newly available behaviors. This is not turned on by default
for status, but can be accessed via the options to the extended
version of the command.
Diffstat (limited to 'tests-clar/status')
-rw-r--r-- | tests-clar/status/ignore.c | 63 |
1 files changed, 59 insertions, 4 deletions
diff --git a/tests-clar/status/ignore.c b/tests-clar/status/ignore.c index e2e4aaf18..d40af7e05 100644 --- a/tests-clar/status/ignore.c +++ b/tests-clar/status/ignore.c @@ -199,7 +199,6 @@ void test_status_ignore__subdirectories(void) cl_git_pass(git_status_should_ignore(&ignored, g_repo, "ignore_me")); cl_assert(ignored); - /* So, interestingly, as per the comment in diff_from_iterators() the * following file is ignored, but in a way so that it does not show up * in status even if INCLUDE_IGNORED is used. This actually matches @@ -207,11 +206,12 @@ void test_status_ignore__subdirectories(void) * status -uall --ignored" then the following file and directory will * not show up in the output at all. */ - - cl_git_pass( - git_futils_mkdir_r("empty_standard_repo/test/ignore_me", NULL, 0775)); + cl_git_pass(git_futils_mkdir_r( + "empty_standard_repo/test/ignore_me", NULL, 0775)); cl_git_mkfile( "empty_standard_repo/test/ignore_me/file", "I'm going to be ignored!"); + cl_git_mkfile( + "empty_standard_repo/test/ignore_me/file2", "Me, too!"); memset(&st, 0, sizeof(st)); cl_git_pass(git_status_foreach(g_repo, cb_status__single, &st)); @@ -225,6 +225,61 @@ void test_status_ignore__subdirectories(void) cl_assert(ignored); } +void test_status_ignore__subdirectories_recursion(void) +{ + /* Let's try again with recursing into ignored dirs turned on */ + git_status_options opts = GIT_STATUS_OPTIONS_INIT; + status_entry_counts counts; + static const char *paths[] = { + ".gitignore", + "ignore_me", + "test/ignore_me/and_me/file", + "test/ignore_me/file", + "test/ignore_me/file2", + }; + static const unsigned int statuses[] = { + GIT_STATUS_WT_NEW, + GIT_STATUS_IGNORED, + GIT_STATUS_IGNORED, + GIT_STATUS_IGNORED, + GIT_STATUS_IGNORED, + }; + + opts.flags = GIT_STATUS_OPT_INCLUDE_IGNORED | + GIT_STATUS_OPT_RECURSE_IGNORED_DIRS | + GIT_STATUS_OPT_INCLUDE_UNTRACKED | + GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS; + + g_repo = cl_git_sandbox_init("empty_standard_repo"); + + cl_git_rewritefile("empty_standard_repo/.gitignore", "ignore_me\n"); + + cl_git_mkfile( + "empty_standard_repo/ignore_me", "I'm going to be ignored!"); + cl_git_pass(git_futils_mkdir_r( + "empty_standard_repo/test/ignore_me", NULL, 0775)); + cl_git_mkfile( + "empty_standard_repo/test/ignore_me/file", "I'm going to be ignored!"); + cl_git_mkfile( + "empty_standard_repo/test/ignore_me/file2", "Me, too!"); + cl_git_pass(git_futils_mkdir_r( + "empty_standard_repo/test/ignore_me/and_me", NULL, 0775)); + cl_git_mkfile( + "empty_standard_repo/test/ignore_me/and_me/file", "Deeply ignored"); + + memset(&counts, 0x0, sizeof(status_entry_counts)); + counts.expected_entry_count = 5; + counts.expected_paths = paths; + counts.expected_statuses = statuses; + + cl_git_pass(git_status_foreach_ext( + g_repo, &opts, cb_status__normal, &counts)); + + cl_assert_equal_i(counts.expected_entry_count, counts.entry_count); + cl_assert_equal_i(0, counts.wrong_status_flags_count); + cl_assert_equal_i(0, counts.wrong_sorted_path); +} + void test_status_ignore__adding_internal_ignores(void) { int ignored; |