| 748 | #endif |
| 749 | |
| 750 | static void handle_builtin(struct strvec *args) |
| 751 | { |
| 752 | const char *cmd; |
| 753 | struct cmd_struct *builtin; |
| 754 | |
| 755 | strip_extension(args); |
| 756 | cmd = args->v[0]; |
| 757 | |
| 758 | /* Turn "git cmd --help" into "git help --exclude-guides cmd" */ |
| 759 | if (args->nr > 1 && !strcmp(args->v[1], "--help")) { |
| 760 | const char *exclude_guides_arg[] = { "--exclude-guides" }; |
| 761 | |
| 762 | strvec_replace(args, 1, args->v[0]); |
| 763 | strvec_replace(args, 0, "help"); |
| 764 | cmd = "help"; |
| 765 | strvec_splice(args, 2, 0, exclude_guides_arg, |
| 766 | ARRAY_SIZE(exclude_guides_arg)); |
| 767 | } |
| 768 | |
| 769 | builtin = get_builtin(cmd); |
| 770 | if (builtin) { |
| 771 | const char **argv_copy = NULL; |
| 772 | int ret; |
| 773 | |
| 774 | /* |
| 775 | * `run_builtin()` will modify the argv array, so we need to |
| 776 | * create a shallow copy such that we can free all of its |
| 777 | * strings. |
| 778 | */ |
| 779 | if (args->nr) |
| 780 | DUP_ARRAY(argv_copy, args->v, args->nr + 1); |
| 781 | |
| 782 | ret = run_builtin(builtin, args->nr, argv_copy, the_repository); |
| 783 | strvec_clear(args); |
| 784 | free(argv_copy); |
| 785 | exit(ret); |
| 786 | } |
| 787 | } |
| 788 | |
| 789 | static void execv_dashed_external(const char **argv) |
| 790 | { |
no test coverage detected