MCPcopy Index your code
hub / github.com/git/git / verify_path_internal

Function verify_path_internal

read-cache.c:988–1049  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

986}
987
988static enum verify_path_result verify_path_internal(const char *path,
989 unsigned mode)
990{
991 char c = 0;
992
993 if (has_dos_drive_prefix(path))
994 return PATH_INVALID;
995
996 if (!is_valid_path(path))
997 return PATH_INVALID;
998
999 goto inside;
1000 for (;;) {
1001 if (!c)
1002 return PATH_OK;
1003 if (is_dir_sep(c)) {
1004inside:
1005 if (protect_hfs) {
1006
1007 if (is_hfs_dotgit(path))
1008 return PATH_INVALID;
1009 if (S_ISLNK(mode)) {
1010 if (is_hfs_dotgitmodules(path))
1011 return PATH_INVALID;
1012 }
1013 }
1014 if (protect_ntfs) {
1015#if defined GIT_WINDOWS_NATIVE || defined __CYGWIN__
1016 if (c == '\\')
1017 return PATH_INVALID;
1018#endif
1019 if (is_ntfs_dotgit(path))
1020 return PATH_INVALID;
1021 if (S_ISLNK(mode)) {
1022 if (is_ntfs_dotgitmodules(path))
1023 return PATH_INVALID;
1024 }
1025 }
1026
1027 c = *path++;
1028 if ((c == '.' && !verify_dotfile(path, mode)) ||
1029 is_dir_sep(c))
1030 return PATH_INVALID;
1031 /*
1032 * allow terminating directory separators for
1033 * sparse directory entries.
1034 */
1035 if (c == '\0')
1036 return S_ISDIR(mode) ? PATH_DIR_WITH_SEP :
1037 PATH_INVALID;
1038 } else if (c == '\\' && protect_ntfs) {
1039 if (is_ntfs_dotgit(path))
1040 return PATH_INVALID;
1041 if (S_ISLNK(mode)) {
1042 if (is_ntfs_dotgitmodules(path))
1043 return PATH_INVALID;
1044 }
1045 }

Callers 3

verify_pathFunction · 0.85
make_cache_entryFunction · 0.85

Calls 5

is_hfs_dotgitFunction · 0.85
is_hfs_dotgitmodulesFunction · 0.85
is_ntfs_dotgitFunction · 0.85
is_ntfs_dotgitmodulesFunction · 0.85
verify_dotfileFunction · 0.85

Tested by

no test coverage detected