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

Function add_pattern_to_hashsets

dir.c:793–931  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

791}
792
793static void add_pattern_to_hashsets(struct pattern_list *pl, struct path_pattern *given)
794{
795 struct pattern_entry *translated;
796 char *truncated;
797 char *data = NULL;
798 const char *prev, *cur, *next;
799
800 if (!pl->use_cone_patterns)
801 return;
802
803 if (given->flags & PATTERN_FLAG_NEGATIVE &&
804 given->flags & PATTERN_FLAG_MUSTBEDIR &&
805 !strcmp(given->pattern, "/*")) {
806 pl->full_cone = 0;
807 return;
808 }
809
810 if (!given->flags && !strcmp(given->pattern, "/*")) {
811 pl->full_cone = 1;
812 return;
813 }
814
815 if (given->patternlen < 2 ||
816 *given->pattern != '/' ||
817 strstr(given->pattern, "**")) {
818 /* Not a cone pattern. */
819 warning(_("unrecognized pattern: '%s'"), given->pattern);
820 goto clear_hashmaps;
821 }
822
823 if (!(given->flags & PATTERN_FLAG_MUSTBEDIR) &&
824 strcmp(given->pattern, "/*")) {
825 /* Not a cone pattern. */
826 warning(_("unrecognized pattern: '%s'"), given->pattern);
827 goto clear_hashmaps;
828 }
829
830 prev = given->pattern;
831 cur = given->pattern + 1;
832 next = given->pattern + 2;
833
834 while (*cur) {
835 /* Watch for glob characters '*', '\', '[', '?' */
836 if (!is_glob_special(*cur))
837 goto increment;
838
839 /* But only if *prev != '\\' */
840 if (*prev == '\\')
841 goto increment;
842
843 /* But allow the initial '\' */
844 if (*cur == '\\' &&
845 is_glob_special(*next))
846 goto increment;
847
848 /* But a trailing '/' then '*' is fine */
849 if (*prev == '/' &&
850 *cur == '*' &&

Callers 1

add_patternFunction · 0.85

Calls 7

warningFunction · 0.85
dup_and_filter_patternFunction · 0.85
hashmap_entry_initFunction · 0.85
fspathhashFunction · 0.85
hashmap_addFunction · 0.85
xmallocFunction · 0.70

Tested by

no test coverage detected