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

Function parse_path_pattern

dir.c:697–733  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

695}
696
697void parse_path_pattern(const char **pattern,
698 int *patternlen,
699 unsigned *flags,
700 int *nowildcardlen)
701{
702 const char *p = *pattern;
703 size_t i, len;
704
705 *flags = 0;
706 if (*p == '!') {
707 *flags |= PATTERN_FLAG_NEGATIVE;
708 p++;
709 }
710 len = strlen(p);
711 if (len && p[len - 1] == '/') {
712 len--;
713 *flags |= PATTERN_FLAG_MUSTBEDIR;
714 }
715 for (i = 0; i < len; i++) {
716 if (p[i] == '/')
717 break;
718 }
719 if (i == len)
720 *flags |= PATTERN_FLAG_NODIR;
721 *nowildcardlen = simple_length(p);
722 /*
723 * we should have excluded the trailing slash from 'p' too,
724 * but that's one more allocation. Instead just make sure
725 * nowildcardlen does not exceed real patternlen
726 */
727 if (*nowildcardlen > len)
728 *nowildcardlen = len;
729 if (*p == '*' && no_wildcard(p + 1))
730 *flags |= PATTERN_FLAG_ENDSWITH;
731 *pattern = p;
732 *patternlen = len;
733}
734
735int pl_hashmap_cmp(const void *cmp_data UNUSED,
736 const struct hashmap_entry *a,

Callers 2

add_patternFunction · 0.85
parse_attr_lineFunction · 0.85

Calls 2

simple_lengthFunction · 0.85
no_wildcardFunction · 0.85

Tested by

no test coverage detected