index: include TYPECHANGE in the diff Without this option, we would not be able to catch exec bit changes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
diff --git a/src/index.c b/src/index.c
index 3d0f4d1..8f0976d 100644
--- a/src/index.c
+++ b/src/index.c
@@ -2681,8 +2681,9 @@ static int index_apply_to_wd_diff(git_index *index, int action, const git_strarr
if ((error = git_pathspec__init(&ps, paths)) < 0)
return error;
+ opts.flags = GIT_DIFF_INCLUDE_TYPECHANGE;
if (action == INDEX_ACTION_ADDALL) {
- opts.flags = GIT_DIFF_INCLUDE_UNTRACKED | GIT_DIFF_RECURSE_IGNORED_DIRS;
+ opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED | GIT_DIFF_RECURSE_IGNORED_DIRS;
if (flags == GIT_INDEX_ADD_FORCE)
opts.flags |= GIT_DIFF_INCLUDE_IGNORED;
}
diff --git a/tests/index/addall.c b/tests/index/addall.c
index a7e2583..f13b768 100644
--- a/tests/index/addall.c
+++ b/tests/index/addall.c
@@ -193,6 +193,19 @@ void test_index_addall__repo_lifecycle(void)
cl_repo_commit_from_index(NULL, g_repo, NULL, 0, "first commit");
check_status(g_repo, 0, 0, 0, 3, 0, 0, 1);
+ if (cl_repo_get_bool(g_repo, "core.filemode")) {
+ cl_git_pass(git_index_update_all(index, NULL, NULL, NULL));
+ cl_must_pass(p_chmod(TEST_DIR "/file.zzz", 0777));
+ cl_git_pass(git_index_update_all(index, NULL, NULL, NULL));
+ check_status(g_repo, 0, 0, 1, 3, 0, 0, 1);
+
+ /* go back to what we had before */
+ cl_must_pass(p_chmod(TEST_DIR "/file.zzz", 0666));
+ cl_git_pass(git_index_update_all(index, NULL, NULL, NULL));
+ check_status(g_repo, 0, 0, 0, 3, 0, 0, 1);
+ }
+
+
/* attempt to add an ignored file - does nothing */
strs[0] = "file.foo";
cl_git_pass(git_index_add_all(index, &paths, 0, NULL, NULL));