MCPcopy Index your code
hub / github.com/git/git / git_unknown_cmd_config

Function git_unknown_cmd_config

help.c:572–614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

570}
571
572static int git_unknown_cmd_config(const char *var, const char *value,
573 const struct config_context *ctx,
574 void *cb)
575{
576 struct help_unknown_cmd_config *cfg = cb;
577 const char *subsection, *key;
578 size_t subsection_len;
579
580 if (!strcmp(var, "help.autocorrect")) {
581 int v = parse_autocorrect(value);
582
583 if (!v) {
584 v = git_config_int(var, value, ctx->kvi);
585 if (v < 0 || v == 1)
586 v = AUTOCORRECT_IMMEDIATELY;
587 }
588
589 cfg->autocorrect = v;
590 }
591
592 /* Also use aliases for command lookup */
593 if (!parse_config_key(var, "alias", &subsection, &subsection_len,
594 &key)) {
595 size_t key_len = strlen(key);
596
597 if (subsection) {
598 /* [alias "name"] command = value */
599 if (!strcmp(key, "command"))
600 add_cmdname(&cfg->aliases, subsection,
601 subsection_len);
602 else {
603 key = var + strlen("alias.");
604 key_len = strlen(key);
605 add_cmdname(&cfg->aliases, key, key_len);
606 }
607 } else {
608 /* alias.name = value */
609 add_cmdname(&cfg->aliases, key, key_len);
610 }
611 }
612
613 return 0;
614}
615
616static int levenshtein_compare(const void *p1, const void *p2)
617{

Callers

nothing calls this directly

Calls 4

parse_autocorrectFunction · 0.85
git_config_intFunction · 0.85
parse_config_keyFunction · 0.85
add_cmdnameFunction · 0.85

Tested by

no test coverage detected