File tree Expand file tree Collapse file tree 2 files changed +123
-0
lines changed
Expand file tree Collapse file tree 2 files changed +123
-0
lines changed Original file line number Diff line number Diff line change @@ -1841,3 +1841,16 @@ int git_path_normalize_slashes(git_buf *out, const char *path)
18411841
18421842 return 0 ;
18431843}
1844+
1845+ static int verify_dotgit_generic (const char * name , const char * dotgit_name , const char * shortname_pfix )
1846+ {
1847+ if (!verify_dotgit_ntfs_generic (name , dotgit_name , shortname_pfix ))
1848+ return false;
1849+
1850+ return verify_dotgit_hfs_generic (name , strlen (name ), dotgit_name , strlen (dotgit_name ));
1851+ }
1852+
1853+ int git_path_is_dotgit_modules (const char * name )
1854+ {
1855+ return !verify_dotgit_generic (name , "gitmodules" , "gi7eba" );
1856+ }
Original file line number Diff line number Diff line change 1+ #include "clar_libgit2.h"
2+ #include "path.h"
3+
4+ #include "git2/sys/path.h"
5+
6+ static char * gitmodules_altnames [] = {
7+ ".gitmodules" ,
8+
9+ ".git\u200cmodules" ,
10+
11+ ".Gitmodules" ,
12+ ".gitmoduleS" ,
13+
14+ ".gitmodules " ,
15+ ".gitmodules." ,
16+ ".gitmodules " ,
17+ ".gitmodules. " ,
18+ ".gitmodules ." ,
19+ ".gitmodules.." ,
20+ ".gitmodules " ,
21+ ".gitmodules. " ,
22+ ".gitmodules . " ,
23+ ".gitmodules ." ,
24+
25+ ".Gitmodules " ,
26+ ".Gitmodules." ,
27+ ".Gitmodules " ,
28+ ".Gitmodules. " ,
29+ ".Gitmodules ." ,
30+ ".Gitmodules.." ,
31+ ".Gitmodules " ,
32+ ".Gitmodules. " ,
33+ ".Gitmodules . " ,
34+ ".Gitmodules ." ,
35+
36+ "GITMOD~1" ,
37+ "gitmod~1" ,
38+ "GITMOD~2" ,
39+ "gitmod~3" ,
40+ "GITMOD~4" ,
41+
42+ "GITMOD~1 " ,
43+ "gitmod~2." ,
44+ "GITMOD~3 " ,
45+ "gitmod~4. " ,
46+ "GITMOD~1 ." ,
47+ "gitmod~2 " ,
48+ "GITMOD~3. " ,
49+ "gitmod~4 . " ,
50+
51+ "GI7EBA~1" ,
52+ "gi7eba~9" ,
53+
54+ "GI7EB~10" ,
55+ "GI7EB~11" ,
56+ "GI7EB~99" ,
57+ "GI7EB~10" ,
58+ "GI7E~100" ,
59+ "GI7E~101" ,
60+ "GI7E~999" ,
61+ "~1000000" ,
62+ "~9999999" ,
63+ };
64+
65+ static char * gitmodules_not_altnames [] = {
66+ ".gitmodules x" ,
67+ ".gitmodules .x" ,
68+
69+ " .gitmodules" ,
70+
71+ "..gitmodules" ,
72+
73+ "gitmodules" ,
74+
75+ ".gitmodule" ,
76+
77+ ".gitmodules x " ,
78+ ".gitmodules .x" ,
79+
80+ "GI7EBA~" ,
81+ "GI7EBA~0" ,
82+ "GI7EBA~~1" ,
83+ "GI7EBA~X" ,
84+ "Gx7EBA~1" ,
85+ "GI7EBX~1" ,
86+
87+ "GI7EB~1" ,
88+ "GI7EB~01" ,
89+ "GI7EB~1" ,
90+ };
91+
92+ void test_path_dotgit__dotgit_modules (void )
93+ {
94+ size_t i ;
95+ cl_assert_equal_i (1 , git_path_is_dotgit_modules (".gitmodules" ));
96+ cl_assert_equal_i (1 , git_path_is_dotgit_modules (".git\xe2\x80\x8cmodules" ));
97+
98+ for (i = 0 ; i < ARRAY_SIZE (gitmodules_altnames ); i ++ ) {
99+ const char * name = gitmodules_altnames [i ];
100+ if (!git_path_is_dotgit_modules (name ))
101+ cl_fail (name );
102+ }
103+
104+ for (i = 0 ; i < ARRAY_SIZE (gitmodules_not_altnames ); i ++ ) {
105+ const char * name = gitmodules_not_altnames [i ];
106+ if (git_path_is_dotgit_modules (name ))
107+ cl_fail (name );
108+ }
109+
110+ }
You can’t perform that action at this time.
0 commit comments