summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2018-02-19 22:10:44 +0000
committerEdward Thomson <ethomson@edwardthomson.com>2018-02-20 14:26:03 +0000
commit4e4771dcc77c6f26b4a0b296d68f7b310cad0076 (patch)
tree652b0a17785915c0e090a60f20c9eb349ad2e0ac /tests
parent8858a68404c889c810a06f9564086b1b9c3ab887 (diff)
downloadlibgit2-4e4771dcc77c6f26b4a0b296d68f7b310cad0076.tar.gz
checkout test: further ensure workdir perms are updatedethomson/checkout_typechange_with_index_and_wd
When both the index _and_ the working directory has changed permissions on a file permissions on a file - but only the permissions, such that the contents of the file are identical - ensure that `git_checkout` updates the permissions to match the checkout target.
Diffstat (limited to 'tests')
-rw-r--r--tests/checkout/head.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/checkout/head.c b/tests/checkout/head.c
index 82f93f430..46b22570d 100644
--- a/tests/checkout/head.c
+++ b/tests/checkout/head.c
@@ -156,3 +156,28 @@ void test_checkout_head__typechange_workdir(void)
git_object_free(target);
}
+
+void test_checkout_head__typechange_index_and_workdir(void)
+{
+ git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
+ git_object *target;
+ git_index *index;
+ struct stat st;
+
+ opts.checkout_strategy = GIT_CHECKOUT_FORCE;
+
+ cl_git_pass(git_revparse_single(&target, g_repo, "HEAD"));
+ cl_git_pass(git_reset(g_repo, target, GIT_RESET_HARD, NULL));
+
+ cl_must_pass(p_chmod("testrepo/new.txt", 0755));
+ cl_git_pass(git_repository_index(&index, g_repo));
+ cl_git_pass(git_index_add_bypath(index, "new.txt"));
+ cl_git_pass(git_index_write(index));
+ cl_git_pass(git_checkout_head(g_repo, &opts));
+
+ cl_git_pass(p_stat("testrepo/new.txt", &st));
+ cl_assert(!GIT_PERMS_IS_EXEC(st.st_mode));
+
+ git_object_free(target);
+ git_index_free(index);
+}