diff options
author | Alan Rogers <alan@github.com> | 2014-06-04 04:42:52 +0400 |
---|---|---|
committer | Alan Rogers <alan@github.com> | 2014-06-04 04:42:52 +0400 |
commit | 79d5b5c91683720c9055d1f5ea3f9468ca9356a4 (patch) | |
tree | a2849b48259bcd0abcdf0778c2bbbe19a719b49e /tests/status | |
parent | 523553f902490935084ea39694c06738bfae4a3e (diff) |
Add GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED
and a (failing) test for it.
Diffstat (limited to 'tests/status')
-rw-r--r-- | tests/status/worktree.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/tests/status/worktree.c b/tests/status/worktree.c index 5e1399b8a..e3af0e5a3 100644 --- a/tests/status/worktree.c +++ b/tests/status/worktree.c @@ -936,7 +936,7 @@ void test_status_worktree__update_stat_cache_0(void) git_status_list_free(status); } -void test_status_worktree__nopermissions(void) +void test_status_worktree__unreadable(void) { const char *expected_paths[] = { "no_permission/foo" }; const unsigned int expected_statuses[] = {GIT_STATUS_WT_UNREADABLE}; @@ -967,3 +967,38 @@ void test_status_worktree__nopermissions(void) cl_assert_equal_i(0, counts.wrong_status_flags_count); cl_assert_equal_i(0, counts.wrong_sorted_path); } + +void test_status_worktree__unreadable_as_untracked(void) +{ + const char *expected_paths[] = { "no_permission/foo" }; + const unsigned int expected_statuses[] = {GIT_STATUS_WT_NEW}; + + git_repository *repo = cl_git_sandbox_init("empty_standard_repo"); + git_status_options opts = GIT_STATUS_OPTIONS_INIT; + status_entry_counts counts = {0}; + + /* Create directory with no read permission */ + cl_git_pass(git_futils_mkdir_r("empty_standard_repo/no_permission", NULL, 0777)); + cl_git_mkfile("empty_standard_repo/no_permission/foo", "dummy"); + p_chmod("empty_standard_repo/no_permission", 0644); + + counts.expected_entry_count = 1; + counts.expected_paths = expected_paths; + counts.expected_statuses = expected_statuses; + + opts.show = GIT_STATUS_SHOW_WORKDIR_ONLY; + opts.flags = GIT_STATUS_OPT_DEFAULTS | + GIT_STATUS_OPT_INCLUDE_UNREADABLE | + GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED; + + cl_git_pass( + git_status_foreach_ext(repo, &opts, cb_status__normal, &counts) ); + + /* Restore permissions so we can cleanup :) */ + p_chmod("empty_standard_repo/no_permission", 0777); + + 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); +} + |