| 521 | } |
| 522 | |
| 523 | static 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 | |
| 558 | static void strbuf_to_cone_pattern(struct strbuf *line, struct pattern_list *pl) |
| 559 | { |
no test coverage detected