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

Function modify_pattern_list

builtin/sparse-checkout.c:686–723  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

684}
685
686static 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
725static void sanitize_paths(struct repository *repo,
726 struct strvec *args,

Callers 2

sparse_checkout_addFunction · 0.85
sparse_checkout_setFunction · 0.85

Calls 8

xcallocFunction · 0.85
add_patterns_cone_modeFunction · 0.85
add_patterns_literalFunction · 0.85
add_patterns_from_inputFunction · 0.85
clear_pattern_listFunction · 0.85
repo_config_valuesClass · 0.70
set_configFunction · 0.70

Tested by

no test coverage detected