summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-05-12 12:07:33 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2015-05-14 15:23:12 +0200
commit2b2dfe80f065f284aa53351d7203e31cf001cf8a (patch)
treeb893926ac9dd724269ad7095f72335809e947a98
parent0a78a52ed9c6945151536d0f19aa39b081a4a8ac (diff)
downloadlibgit2-2b2dfe80f065f284aa53351d7203e31cf001cf8a.tar.gz
index: include TYPECHANGE in the diff
Without this option, we would not be able to catch exec bit changes.
-rw-r--r--src/index.c3
-rw-r--r--tests/index/addall.c13
2 files changed, 15 insertions, 1 deletions
diff --git a/src/index.c b/src/index.c
index 3d0f4d14d..8f0976d13 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 a7e2583b2..f13b768ce 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));