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

Function handle_builtin

git.c:750–787  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

748#endif
749
750static 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
789static void execv_dashed_external(const char **argv)
790{

Callers 2

run_argvFunction · 0.85
cmd_mainFunction · 0.85

Calls 6

strip_extensionFunction · 0.85
strvec_replaceFunction · 0.85
strvec_spliceFunction · 0.85
get_builtinFunction · 0.85
run_builtinFunction · 0.85
strvec_clearFunction · 0.85

Tested by

no test coverage detected