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

Function insert_recursive_pattern

builtin/sparse-checkout.c:523–556  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

521}
522
523static void insert_recursive_pattern(struct pattern_list *pl, struct strbuf *path)
524{
525 struct pattern_entry *e = xmalloc(sizeof(*e));
526 e->patternlen = path->len;
527 e->pattern = strbuf_detach(path, NULL);
528 hashmap_entry_init(&e->ent, fspathhash(e->pattern));
529
530 hashmap_add(&pl->recursive_hashmap, &e->ent);
531
532 while (e->patternlen) {
533 char *slash = strrchr(e->pattern, '/');
534 char *oldpattern = e->pattern;
535 size_t newlen;
536 struct pattern_entry *dup;
537
538 if (!slash || slash == e->pattern)
539 break;
540
541 newlen = slash - e->pattern;
542 e = xmalloc(sizeof(struct pattern_entry));
543 e->patternlen = newlen;
544 e->pattern = xstrndup(oldpattern, newlen);
545 hashmap_entry_init(&e->ent, fspathhash(e->pattern));
546
547 dup = hashmap_get_entry(&pl->parent_hashmap, e, ent, NULL);
548 if (!dup) {
549 hashmap_add(&pl->parent_hashmap, &e->ent);
550 } else {
551 free(e->pattern);
552 free(e);
553 e = dup;
554 }
555 }
556}
557
558static void strbuf_to_cone_pattern(struct strbuf *line, struct pattern_list *pl)
559{

Callers 2

strbuf_to_cone_patternFunction · 0.85
add_patterns_cone_modeFunction · 0.85

Calls 6

strbuf_detachFunction · 0.85
hashmap_entry_initFunction · 0.85
fspathhashFunction · 0.85
hashmap_addFunction · 0.85
xstrndupFunction · 0.85
xmallocFunction · 0.50

Tested by

no test coverage detected