summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Turner <novalis@novalis.org>2021-06-16 13:38:45 -0400
committerDavid Turner <novalis@novalis.org>2021-06-16 13:55:37 -0400
commitb0fd4cf82c4652cba7b9de5aaab6cd95bc5fa925 (patch)
treed2a71a4fa68c9a36f019479b417a81fe3bfc30f2 /tests
parent0d0150d8eb5fe5654af4172fe2f923f5d1317eb7 (diff)
downloadlibgit2-b0fd4cf82c4652cba7b9de5aaab6cd95bc5fa925.tar.gz
Consider files executable only if the user can execute them
This is what git.git does, so we should follow suit.
Diffstat (limited to 'tests')
-rw-r--r--tests/status/worktree.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/status/worktree.c b/tests/status/worktree.c
index d2842485b..d9fce4404 100644
--- a/tests/status/worktree.c
+++ b/tests/status/worktree.c
@@ -605,6 +605,45 @@ void test_status_worktree__filemode_changes(void)
cl_assert_equal_i(0, counts.wrong_sorted_path);
}
+void test_status_worktree__filemode_non755(void)
+{
+ git_repository *repo = cl_git_sandbox_init("filemodes");
+ status_entry_counts counts;
+ git_status_options opts = GIT_STATUS_OPTIONS_INIT;
+ git_buf executable_path = GIT_BUF_INIT;
+ git_buf nonexecutable_path = GIT_BUF_INIT;
+
+ if (!cl_is_chmod_supported())
+ return;
+
+ opts.flags = GIT_STATUS_OPT_INCLUDE_UNTRACKED |
+ GIT_STATUS_OPT_INCLUDE_IGNORED |
+ GIT_STATUS_OPT_INCLUDE_UNMODIFIED;
+
+ git_buf_joinpath(&executable_path, git_repository_workdir(repo), "exec_on");
+ cl_must_pass(p_chmod(git_buf_cstr(&executable_path), 0744));
+ git_buf_dispose(&executable_path);
+
+ git_buf_joinpath(&nonexecutable_path, git_repository_workdir(repo), "exec_off");
+
+ cl_must_pass(p_chmod(git_buf_cstr(&nonexecutable_path), 0655));
+ git_buf_dispose(&nonexecutable_path);
+
+ memset(&counts, 0, sizeof(counts));
+ counts.expected_entry_count = filemode_count;
+ counts.expected_paths = filemode_paths;
+ counts.expected_statuses = filemode_statuses;
+
+ cl_git_pass(
+ git_status_foreach_ext(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);
+}
+
+
static int cb_status__interrupt(const char *p, unsigned int s, void *payload)
{
volatile int *count = (int *)payload;