summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2018-02-19 22:09:27 +0000
committerEdward Thomson <ethomson@edwardthomson.com>2018-02-20 14:26:03 +0000
commit8858a68404c889c810a06f9564086b1b9c3ab887 (patch)
treea4dd71c8f6413103c31aa596f0aac2444a49050e
parentd7fea1e1a72eaa32673b25c0e9713daf82735c3f (diff)
downloadlibgit2-8858a68404c889c810a06f9564086b1b9c3ab887.tar.gz
checkout test: ensure workdir perms are updated
When the working directory has changed 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.
-rw-r--r--tests/checkout/head.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/checkout/head.c b/tests/checkout/head.c
index ded86df33..82f93f430 100644
--- a/tests/checkout/head.c
+++ b/tests/checkout/head.c
@@ -136,3 +136,23 @@ void test_checkout_head__do_remove_tracked_subdir(void)
cl_assert(!git_path_isfile("testrepo/subdir/tracked-file"));
cl_assert(git_path_isfile("testrepo/subdir/untracked-file"));
}
+
+void test_checkout_head__typechange_workdir(void)
+{
+ git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
+ git_object *target;
+ 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_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);
+}