void test_diff_workdir__filemode_changes_with_filemode_false(void) { git_config *cfg; git_diff_list *diff = NULL; diff_expects exp; if (!cl_is_chmod_supported()) return; g_repo = cl_git_sandbox_init("issue_592"); cl_git_pass(git_repository_config(&cfg, g_repo)); cl_git_pass(git_config_set_bool(cfg, "core.filemode", false)); /* test once with no mods */ cl_git_pass(git_diff_workdir_to_index(g_repo, NULL, &diff)); memset(&exp, 0, sizeof(exp)); cl_git_pass(git_diff_foreach( diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn)); cl_assert_equal_i(0, exp.files); cl_assert_equal_i(0, exp.file_mods); cl_assert_equal_i(0, exp.hunks); git_diff_list_free(diff); /* chmod file and test again */ cl_assert(cl_toggle_filemode("issue_592/a.txt")); cl_git_pass(git_diff_workdir_to_index(g_repo, NULL, &diff)); memset(&exp, 0, sizeof(exp)); cl_git_pass(git_diff_foreach( diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn)); cl_assert_equal_i(0, exp.files); cl_assert_equal_i(0, exp.file_mods); cl_assert_equal_i(0, exp.hunks); git_diff_list_free(diff); cl_assert(cl_toggle_filemode("issue_592/a.txt")); git_config_free(cfg); }
bool cl_is_chmod_supported(void) { static int _is_supported = -1; if (_is_supported < 0) { cl_git_mkfile("filemode.t", "Test if filemode can be modified"); _is_supported = cl_toggle_filemode("filemode.t"); cl_must_pass(p_unlink("filemode.t")); } return _is_supported; }