| 577 | } |
| 578 | |
| 579 | static 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 | |
| 626 | static void no_help_format(const char *opt_mode, enum help_format fmt) |
| 627 | { |
no test coverage detected