MCPcopy Create free account
hub / github.com/git/git / git_fnmatch

Function git_fnmatch

dir.c:159–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157}
158
159int git_fnmatch(const struct pathspec_item *item,
160 const char *pattern, const char *string,
161 int prefix)
162{
163 if (prefix > 0) {
164 if (ps_strncmp(item, pattern, string, prefix))
165 return WM_NOMATCH;
166 pattern += prefix;
167 string += prefix;
168 }
169 if (item->flags & PATHSPEC_ONESTAR) {
170 int pattern_len = strlen(++pattern);
171 int string_len = strlen(string);
172 return string_len < pattern_len ||
173 ps_strcmp(item, pattern,
174 string + string_len - pattern_len);
175 }
176 if (item->magic & PATHSPEC_GLOB)
177 return wildmatch(pattern, string,
178 WM_PATHNAME |
179 (item->magic & PATHSPEC_ICASE ? WM_CASEFOLD : 0));
180 else
181 /* wildmatch has not learned no FNM_PATHNAME mode yet */
182 return wildmatch(pattern, string,
183 item->magic & PATHSPEC_ICASE ? WM_CASEFOLD : 0);
184}
185
186static int fnmatch_icase_mem(const char *pattern, int patternlen,
187 const char *string, int stringlen,

Callers 2

do_matchFunction · 0.85
match_pathspec_itemFunction · 0.85

Calls 3

ps_strncmpFunction · 0.85
ps_strcmpFunction · 0.85
wildmatchFunction · 0.85

Tested by

no test coverage detected