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

Function check_git_cmd

builtin/help.c:579–624  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

577}
578
579static char *check_git_cmd(const char *cmd)
580{
581 char *alias;
582
583 if (is_git_command(cmd))
584 return xstrdup(cmd);
585
586 alias = alias_lookup(cmd);
587 if (alias) {
588 const char **argv;
589 int count;
590
591 /*
592 * handle_builtin() in git.c rewrites "git cmd --help"
593 * to "git help --exclude-guides cmd", so we can use
594 * exclude_guides to distinguish "git cmd --help" from
595 * "git help cmd". In the latter case, or if cmd is an
596 * alias for a shell command, just print the alias
597 * definition.
598 */
599 if (!exclude_guides || alias[0] == '!') {
600 printf_ln(_("'%s' is aliased to '%s'"), cmd, alias);
601 free(alias);
602 exit(0);
603 }
604 /*
605 * Otherwise, we pretend that the command was "git
606 * word0 --help". We use split_cmdline() to get the
607 * first word of the alias, to ensure that we use the
608 * same rules as when the alias is actually
609 * used. split_cmdline() modifies alias in-place.
610 */
611 fprintf_ln(stderr, _("'%s' is aliased to '%s'"), cmd, alias);
612 count = split_cmdline(alias, &argv);
613 if (count < 0)
614 die(_("bad alias.%s string: %s"), cmd,
615 split_cmdline_strerror(count));
616 free(argv);
617 return alias;
618 }
619
620 if (exclude_guides)
621 return help_unknown_cmd(cmd);
622
623 return xstrdup(cmd);
624}
625
626static void no_help_format(const char *opt_mode, enum help_format fmt)
627{

Callers 1

cmd_helpFunction · 0.85

Calls 9

is_git_commandFunction · 0.85
xstrdupFunction · 0.85
alias_lookupFunction · 0.85
printf_lnFunction · 0.85
fprintf_lnFunction · 0.85
split_cmdlineFunction · 0.85
split_cmdline_strerrorFunction · 0.85
help_unknown_cmdFunction · 0.85
dieFunction · 0.50

Tested by

no test coverage detected