Skip to content

Commit 8858a68

Browse files
committed
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.
1 parent d7fea1e commit 8858a68

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/checkout/head.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,23 @@ void test_checkout_head__do_remove_tracked_subdir(void)
136136
cl_assert(!git_path_isfile("testrepo/subdir/tracked-file"));
137137
cl_assert(git_path_isfile("testrepo/subdir/untracked-file"));
138138
}
139+
140+
void test_checkout_head__typechange_workdir(void)
141+
{
142+
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
143+
git_object *target;
144+
struct stat st;
145+
146+
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
147+
148+
cl_git_pass(git_revparse_single(&target, g_repo, "HEAD"));
149+
cl_git_pass(git_reset(g_repo, target, GIT_RESET_HARD, NULL));
150+
151+
cl_must_pass(p_chmod("testrepo/new.txt", 0755));
152+
cl_git_pass(git_checkout_head(g_repo, &opts));
153+
154+
cl_git_pass(p_stat("testrepo/new.txt", &st));
155+
cl_assert(!GIT_PERMS_IS_EXEC(st.st_mode));
156+
157+
git_object_free(target);
158+
}

0 commit comments

Comments
 (0)