Commit 2b2dfe80 by Carlos Martín Nieto

index: include TYPECHANGE in the diff

Without this option, we would not be able to catch exec bit changes.
parent 0a78a52e
...@@ -2681,8 +2681,9 @@ static int index_apply_to_wd_diff(git_index *index, int action, const git_strarr ...@@ -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) if ((error = git_pathspec__init(&ps, paths)) < 0)
return error; return error;
opts.flags = GIT_DIFF_INCLUDE_TYPECHANGE;
if (action == INDEX_ACTION_ADDALL) { 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) if (flags == GIT_INDEX_ADD_FORCE)
opts.flags |= GIT_DIFF_INCLUDE_IGNORED; opts.flags |= GIT_DIFF_INCLUDE_IGNORED;
} }
......
...@@ -193,6 +193,19 @@ void test_index_addall__repo_lifecycle(void) ...@@ -193,6 +193,19 @@ void test_index_addall__repo_lifecycle(void)
cl_repo_commit_from_index(NULL, g_repo, NULL, 0, "first commit"); cl_repo_commit_from_index(NULL, g_repo, NULL, 0, "first commit");
check_status(g_repo, 0, 0, 0, 3, 0, 0, 1); 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 */ /* attempt to add an ignored file - does nothing */
strs[0] = "file.foo"; strs[0] = "file.foo";
cl_git_pass(git_index_add_all(index, &paths, 0, NULL, NULL)); cl_git_pass(git_index_add_all(index, &paths, 0, NULL, NULL));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment