Commit 31541e5f by Edward Thomson Committed by Patrick Steinhardt

path: protect NTFS everywhere

Enable core.protectNTFS by default everywhere and in every codepath, not
just on checkout.
parent dbee08cf
...@@ -1273,7 +1273,7 @@ static int checkout_verify_paths( ...@@ -1273,7 +1273,7 @@ static int checkout_verify_paths(
int action, int action,
git_diff_delta *delta) git_diff_delta *delta)
{ {
unsigned int flags = GIT_PATH_REJECT_WORKDIR_DEFAULTS | GIT_PATH_REJECT_DOT_GIT_NTFS; unsigned int flags = GIT_PATH_REJECT_WORKDIR_DEFAULTS;
if (action & CHECKOUT_ACTION__REMOVE) { if (action & CHECKOUT_ACTION__REMOVE) {
if (!git_path_isvalid(repo, delta->old_file.path, delta->old_file.mode, flags)) { if (!git_path_isvalid(repo, delta->old_file.path, delta->old_file.mode, flags)) {
......
...@@ -1817,7 +1817,7 @@ GIT_INLINE(unsigned int) dotgit_flags( ...@@ -1817,7 +1817,7 @@ GIT_INLINE(unsigned int) dotgit_flags(
git_repository *repo, git_repository *repo,
unsigned int flags) unsigned int flags)
{ {
int protectHFS = 0, protectNTFS = 0; int protectHFS = 0, protectNTFS = 1;
int error = 0; int error = 0;
flags |= GIT_PATH_REJECT_DOT_GIT_LITERAL; flags |= GIT_PATH_REJECT_DOT_GIT_LITERAL;
...@@ -1826,16 +1826,12 @@ GIT_INLINE(unsigned int) dotgit_flags( ...@@ -1826,16 +1826,12 @@ GIT_INLINE(unsigned int) dotgit_flags(
protectHFS = 1; protectHFS = 1;
#endif #endif
#ifdef GIT_WIN32
protectNTFS = 1;
#endif
if (repo && !protectHFS) if (repo && !protectHFS)
error = git_repository__cvar(&protectHFS, repo, GIT_CVAR_PROTECTHFS); error = git_repository__cvar(&protectHFS, repo, GIT_CVAR_PROTECTHFS);
if (!error && protectHFS) if (!error && protectHFS)
flags |= GIT_PATH_REJECT_DOT_GIT_HFS; flags |= GIT_PATH_REJECT_DOT_GIT_HFS;
if (repo && !protectNTFS) if (repo)
error = git_repository__cvar(&protectNTFS, repo, GIT_CVAR_PROTECTNTFS); error = git_repository__cvar(&protectNTFS, repo, GIT_CVAR_PROTECTNTFS);
if (!error && protectNTFS) if (!error && protectNTFS)
flags |= GIT_PATH_REJECT_DOT_GIT_NTFS; flags |= GIT_PATH_REJECT_DOT_GIT_NTFS;
......
...@@ -110,7 +110,7 @@ typedef enum { ...@@ -110,7 +110,7 @@ typedef enum {
/* core.protectHFS */ /* core.protectHFS */
GIT_PROTECTHFS_DEFAULT = GIT_CVAR_FALSE, GIT_PROTECTHFS_DEFAULT = GIT_CVAR_FALSE,
/* core.protectNTFS */ /* core.protectNTFS */
GIT_PROTECTNTFS_DEFAULT = GIT_CVAR_FALSE, GIT_PROTECTNTFS_DEFAULT = GIT_CVAR_TRUE,
/* core.fsyncObjectFiles */ /* core.fsyncObjectFiles */
GIT_FSYNCOBJECTFILES_DEFAULT = GIT_CVAR_FALSE, GIT_FSYNCOBJECTFILES_DEFAULT = GIT_CVAR_FALSE,
} git_cvar_value; } git_cvar_value;
......
...@@ -652,6 +652,21 @@ void test_index_tests__honors_protect_filesystems(void) ...@@ -652,6 +652,21 @@ void test_index_tests__honors_protect_filesystems(void)
cl_fixture_cleanup("invalid"); cl_fixture_cleanup("invalid");
} }
void test_index_tests__protectntfs_on_by_default(void)
{
git_repository *repo;
p_mkdir("invalid", 0700);
cl_git_pass(git_repository_init(&repo, "./invalid", 0));
assert_write_fails(repo, ".git./hello");
assert_write_fails(repo, "git~1/hello");
git_repository_free(repo);
cl_fixture_cleanup("invalid");
}
void test_index_tests__remove_entry(void) void test_index_tests__remove_entry(void)
{ {
git_repository *repo; git_repository *repo;
......
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