path: protect NTFS everywhere Enable core.protectNTFS by default everywhere and in every codepath, not just on checkout.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
diff --git a/src/checkout.c b/src/checkout.c
index 5b20ede..5cfa728 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -1271,7 +1271,7 @@ static int checkout_verify_paths(
int action,
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 (!git_path_isvalid(repo, delta->old_file.path, delta->old_file.mode, flags)) {
diff --git a/src/path.c b/src/path.c
index 5ac3bf0..7241a35 100644
--- a/src/path.c
+++ b/src/path.c
@@ -1832,7 +1832,7 @@ GIT_INLINE(unsigned int) dotgit_flags(
git_repository *repo,
unsigned int flags)
{
- int protectHFS = 0, protectNTFS = 0;
+ int protectHFS = 0, protectNTFS = 1;
int error = 0;
flags |= GIT_PATH_REJECT_DOT_GIT_LITERAL;
@@ -1841,16 +1841,12 @@ GIT_INLINE(unsigned int) dotgit_flags(
protectHFS = 1;
#endif
-#ifdef GIT_WIN32
- protectNTFS = 1;
-#endif
-
if (repo && !protectHFS)
error = git_repository__configmap_lookup(&protectHFS, repo, GIT_CONFIGMAP_PROTECTHFS);
if (!error && protectHFS)
flags |= GIT_PATH_REJECT_DOT_GIT_HFS;
- if (repo && !protectNTFS)
+ if (repo)
error = git_repository__configmap_lookup(&protectNTFS, repo, GIT_CONFIGMAP_PROTECTNTFS);
if (!error && protectNTFS)
flags |= GIT_PATH_REJECT_DOT_GIT_NTFS;
diff --git a/src/repository.h b/src/repository.h
index 1e02bcc..bafdb58 100644
--- a/src/repository.h
+++ b/src/repository.h
@@ -113,7 +113,7 @@ typedef enum {
/* core.protectHFS */
GIT_PROTECTHFS_DEFAULT = GIT_CONFIGMAP_FALSE,
/* core.protectNTFS */
- GIT_PROTECTNTFS_DEFAULT = GIT_CONFIGMAP_FALSE,
+ GIT_PROTECTNTFS_DEFAULT = GIT_CONFIGMAP_TRUE,
/* core.fsyncObjectFiles */
GIT_FSYNCOBJECTFILES_DEFAULT = GIT_CONFIGMAP_FALSE,
} git_configmap_value;
diff --git a/tests/index/tests.c b/tests/index/tests.c
index 9acc155..c793b44 100644
--- a/tests/index/tests.c
+++ b/tests/index/tests.c
@@ -765,6 +765,21 @@ void test_index_tests__honors_protect_filesystems(void)
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)
{
git_repository *repo;