| 574 | } |
| 575 | |
| 576 | static void add_patterns_from_input(struct pattern_list *pl, |
| 577 | int argc, const char **argv, |
| 578 | FILE *file) |
| 579 | { |
| 580 | int i; |
| 581 | struct repo_config_values *cfg = repo_config_values(the_repository); |
| 582 | |
| 583 | if (cfg->core_sparse_checkout_cone) { |
| 584 | struct strbuf line = STRBUF_INIT; |
| 585 | |
| 586 | hashmap_init(&pl->recursive_hashmap, pl_hashmap_cmp, NULL, 0); |
| 587 | hashmap_init(&pl->parent_hashmap, pl_hashmap_cmp, NULL, 0); |
| 588 | pl->use_cone_patterns = 1; |
| 589 | |
| 590 | if (file) { |
| 591 | struct strbuf unquoted = STRBUF_INIT; |
| 592 | while (!strbuf_getline(&line, file)) { |
| 593 | if (line.buf[0] == '"') { |
| 594 | strbuf_reset(&unquoted); |
| 595 | if (unquote_c_style(&unquoted, line.buf, NULL)) |
| 596 | die(_("unable to unquote C-style string '%s'"), |
| 597 | line.buf); |
| 598 | |
| 599 | strbuf_swap(&unquoted, &line); |
| 600 | } |
| 601 | |
| 602 | strbuf_to_cone_pattern(&line, pl); |
| 603 | } |
| 604 | |
| 605 | strbuf_release(&unquoted); |
| 606 | } else { |
| 607 | for (i = 0; i < argc; i++) { |
| 608 | strbuf_setlen(&line, 0); |
| 609 | strbuf_addstr(&line, argv[i]); |
| 610 | strbuf_to_cone_pattern(&line, pl); |
| 611 | } |
| 612 | } |
| 613 | strbuf_release(&line); |
| 614 | } else { |
| 615 | if (file) { |
| 616 | struct strbuf line = STRBUF_INIT; |
| 617 | |
| 618 | while (!strbuf_getline(&line, file)) |
| 619 | add_pattern(line.buf, empty_base, 0, pl, 0); |
| 620 | |
| 621 | strbuf_release(&line); |
| 622 | } else { |
| 623 | for (i = 0; i < argc; i++) |
| 624 | add_pattern(argv[i], empty_base, 0, pl, 0); |
| 625 | } |
| 626 | } |
| 627 | } |
| 628 | |
| 629 | enum modify_type { |
| 630 | REPLACE, |
no test coverage detected