| 684 | } |
| 685 | |
| 686 | static int modify_pattern_list(struct repository *repo, |
| 687 | struct strvec *args, int use_stdin, |
| 688 | enum modify_type m) |
| 689 | { |
| 690 | int result; |
| 691 | int changed_config = 0; |
| 692 | struct pattern_list *pl = xcalloc(1, sizeof(*pl)); |
| 693 | struct repo_config_values *cfg = repo_config_values(the_repository); |
| 694 | |
| 695 | switch (m) { |
| 696 | case ADD: |
| 697 | if (cfg->core_sparse_checkout_cone) |
| 698 | add_patterns_cone_mode(args->nr, args->v, pl, use_stdin); |
| 699 | else |
| 700 | add_patterns_literal(args->nr, args->v, pl, use_stdin); |
| 701 | break; |
| 702 | |
| 703 | case REPLACE: |
| 704 | add_patterns_from_input(pl, args->nr, args->v, |
| 705 | use_stdin ? stdin : NULL); |
| 706 | break; |
| 707 | } |
| 708 | |
| 709 | if (!cfg->apply_sparse_checkout) { |
| 710 | set_config(repo, MODE_ALL_PATTERNS); |
| 711 | cfg->apply_sparse_checkout = 1; |
| 712 | changed_config = 1; |
| 713 | } |
| 714 | |
| 715 | result = write_patterns_and_update(repo, pl); |
| 716 | |
| 717 | if (result && changed_config) |
| 718 | set_config(repo, MODE_NO_PATTERNS); |
| 719 | |
| 720 | clear_pattern_list(pl); |
| 721 | free(pl); |
| 722 | return result; |
| 723 | } |
| 724 | |
| 725 | static void sanitize_paths(struct repository *repo, |
| 726 | struct strvec *args, |
no test coverage detected