Skip to content

Commit 490cbaa

Browse files
committed
path: expose dotgit detection functions per filesystem
These will be used by the checkout code to detect them for the particular filesystem they're on.
1 parent 177dcfc commit 490cbaa

File tree

2 files changed

+84
-3
lines changed

2 files changed

+84
-3
lines changed

src/path.c

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,17 +1850,56 @@ static int verify_dotgit_generic(const char *name, const char *dotgit_name, cons
18501850
return verify_dotgit_hfs_generic(name, strlen(name), dotgit_name, strlen(dotgit_name));
18511851
}
18521852

1853+
int git_path_is_ntfs_dotgit_modules(const char *name)
1854+
{
1855+
return !verify_dotgit_ntfs_generic(name, "gitmodules", "gi7eba");
1856+
}
1857+
1858+
int git_path_is_hfs_dotgit_modules(const char *name)
1859+
{
1860+
return !verify_dotgit_hfs_generic(name, strlen(name), "gitmodules", CONST_STRLEN("gitmodules"));
1861+
}
1862+
18531863
int git_path_is_dotgit_modules(const char *name)
18541864
{
1855-
return !verify_dotgit_generic(name, "gitmodules", "gi7eba");
1865+
if (git_path_is_hfs_dotgit_modules(name))
1866+
return 1;
1867+
1868+
return git_path_is_ntfs_dotgit_modules(name);
1869+
}
1870+
1871+
int git_path_is_ntfs_dotgit_ignore(const char *name)
1872+
{
1873+
return !verify_dotgit_ntfs_generic(name, "gitignore", "gi250a");
1874+
}
1875+
1876+
int git_path_is_hfs_dotgit_ignore(const char *name)
1877+
{
1878+
return !verify_dotgit_hfs_generic(name, strlen(name), "gitignore", CONST_STRLEN("gitignore"));
18561879
}
18571880

18581881
int git_path_is_dotgit_ignore(const char *name)
18591882
{
1860-
return !verify_dotgit_generic(name, "gitignore", "gi250a");
1883+
if (git_path_is_hfs_dotgit_ignore(name))
1884+
return 1;
1885+
1886+
return git_path_is_ntfs_dotgit_ignore(name);
1887+
}
1888+
1889+
int git_path_is_hfs_dotgit_attributes(const char *name)
1890+
{
1891+
return !verify_dotgit_hfs_generic(name, strlen(name), "gitattributes", CONST_STRLEN("gitattributes"));
1892+
}
1893+
1894+
int git_path_is_ntfs_dotgit_attributes(const char *name)
1895+
{
1896+
return !verify_dotgit_ntfs_generic(name, "gitattributes", "gi7d29");
18611897
}
18621898

18631899
int git_path_is_dotgit_attributes(const char *name)
18641900
{
1865-
return !verify_dotgit_generic(name, "gitattributes", "gi7d29");
1901+
if (git_path_is_hfs_dotgit_attributes(name))
1902+
return 1;
1903+
1904+
return git_path_is_ntfs_dotgit_attributes(name);
18661905
}

src/path.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,18 +651,60 @@ int git_path_normalize_slashes(git_buf *out, const char *path);
651651
*/
652652
extern int git_path_is_dotgit_modules(const char *name);
653653

654+
/**
655+
* Check whether a path component corresponds to a .gitmodules file in NTFS
656+
*
657+
* @param name the path component to check
658+
*/
659+
extern int git_path_is_ntfs_dotgit_modules(const char *name);
660+
661+
/**
662+
* Check whether a path component corresponds to a .gitmodules file in HFS+
663+
*
664+
* @param name the path component to check
665+
*/
666+
extern int git_path_is_hfs_dotgit_modules(const char *name);
667+
654668
/**
655669
* Check whether a path component corresponds to a .gitignore file
656670
*
657671
* @param name the path component to check
658672
*/
659673
extern int git_path_is_dotgit_ignore(const char *name);
660674

675+
/**
676+
* Check whether a path component corresponds to a .gitignore file in NTFS
677+
*
678+
* @param name the path component to check
679+
*/
680+
extern int git_path_is_ntfs_dotgit_ignore(const char *name);
681+
682+
/**
683+
* Check whether a path component corresponds to a .gitignore file in HFS+
684+
*
685+
* @param name the path component to check
686+
*/
687+
extern int git_path_is_hfs_dotgit_ignore(const char *name);
688+
661689
/**
662690
* Check whether a path component corresponds to a .gitignore file
663691
*
664692
* @param name the path component to check
665693
*/
666694
extern int git_path_is_dotgit_attributes(const char *name);
667695

696+
/**
697+
* Check whether a path component corresponds to a .gitattributes file in NTFS
698+
*
699+
* @param name the path component to check
700+
*/
701+
extern int git_path_is_ntfs_dotgit_attributes(const char *name);
702+
703+
/**
704+
* Check whether a path component corresponds to a .gitattributes file in HFS+
705+
*
706+
* @param name the path component to check
707+
*/
708+
extern int git_path_is_hfs_dotgit_attributes(const char *name);
709+
668710
#endif

0 commit comments

Comments
 (0)