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

Function add_patterns_from_input

builtin/sparse-checkout.c:576–627  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

574}
575
576static 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
629enum modify_type {
630 REPLACE,

Callers 4

add_patterns_cone_modeFunction · 0.85
add_patterns_literalFunction · 0.85
modify_pattern_listFunction · 0.85

Calls 11

hashmap_initFunction · 0.85
strbuf_getlineFunction · 0.85
unquote_c_styleFunction · 0.85
strbuf_swapFunction · 0.85
strbuf_to_cone_patternFunction · 0.85
strbuf_releaseFunction · 0.85
strbuf_setlenFunction · 0.85
strbuf_addstrFunction · 0.85
add_patternFunction · 0.85
repo_config_valuesClass · 0.70
dieFunction · 0.50

Tested by

no test coverage detected