Skip to content

Commit f43f0fe

Browse files
committed
Merge branch 'js/mingw-loosen-overstrict-tree-entry-checks' into next
An earlier update to Git for Windows declared that a tree object is invalid if it has a path component with backslash in it, which was overly strict, which has been corrected. The only protection the Windows users need is to prevent such path (or any path that their filesystem cannot check out) from entering the index. * js/mingw-loosen-overstrict-tree-entry-checks: mingw: safeguard better against backslashes in file names
2 parents 2dd1b2c + 49e268e commit f43f0fe

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

read-cache.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ static int verify_dotfile(const char *rest, unsigned mode)
959959

960960
int verify_path(const char *path, unsigned mode)
961961
{
962-
char c;
962+
char c = 0;
963963

964964
if (has_dos_drive_prefix(path))
965965
return 0;
@@ -974,6 +974,7 @@ int verify_path(const char *path, unsigned mode)
974974
if (is_dir_sep(c)) {
975975
inside:
976976
if (protect_hfs) {
977+
977978
if (is_hfs_dotgit(path))
978979
return 0;
979980
if (S_ISLNK(mode)) {
@@ -982,6 +983,10 @@ int verify_path(const char *path, unsigned mode)
982983
}
983984
}
984985
if (protect_ntfs) {
986+
#ifdef GIT_WINDOWS_NATIVE
987+
if (c == '\\')
988+
return 0;
989+
#endif
985990
if (is_ntfs_dotgit(path))
986991
return 0;
987992
if (S_ISLNK(mode)) {
@@ -1278,11 +1283,6 @@ static int add_index_entry_with_check(struct index_state *istate, struct cache_e
12781283
int skip_df_check = option & ADD_CACHE_SKIP_DFCHECK;
12791284
int new_only = option & ADD_CACHE_NEW_ONLY;
12801285

1281-
#ifdef GIT_WINDOWS_NATIVE
1282-
if (protect_ntfs && strchr(ce->name, '\\'))
1283-
return error(_("filename in tree entry contains backslash: '%s'"), ce->name);
1284-
#endif
1285-
12861286
if (!(option & ADD_CACHE_KEEP_CACHE_TREE))
12871287
cache_tree_invalidate_path(istate, ce->name);
12881288

t/t7415-submodule-names.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ test_expect_success MINGW 'prevent git~1 squatting on Windows' '
209209
hash="$(echo x | git hash-object -w --stdin)" &&
210210
test_must_fail git update-index --add \
211211
--cacheinfo 160000,$rev,d\\a 2>err &&
212-
test_i18ngrep backslash err &&
212+
test_i18ngrep "Invalid path" err &&
213213
git -c core.protectNTFS=false update-index --add \
214214
--cacheinfo 100644,$modules,.gitmodules \
215215
--cacheinfo 160000,$rev,c \

0 commit comments

Comments
 (0)