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

Function cmd_run

scalar.c:810–871  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

808}
809
810static int cmd_run(int argc, const char **argv)
811{
812 struct option options[] = {
813 OPT_END(),
814 };
815 struct {
816 const char *arg, *task;
817 } tasks[] = {
818 { "config", NULL },
819 { "commit-graph", "commit-graph" },
820 { "fetch", "prefetch" },
821 { "loose-objects", "loose-objects" },
822 { "pack-files", "incremental-repack" },
823 { NULL, NULL }
824 };
825 struct strbuf buf = STRBUF_INIT;
826 const char *usagestr[] = { NULL, NULL };
827 int i;
828
829 strbuf_addstr(&buf, N_("scalar run <task> [<enlistment>]\nTasks:\n"));
830 for (i = 0; tasks[i].arg; i++)
831 strbuf_addf(&buf, "\t%s\n", tasks[i].arg);
832 usagestr[0] = buf.buf;
833
834 argc = parse_options(argc, argv, NULL, options,
835 usagestr, 0);
836
837 if (!argc)
838 usage_with_options(usagestr, options);
839
840 if (!strcmp("all", argv[0])) {
841 i = -1;
842 } else {
843 for (i = 0; tasks[i].arg && strcmp(tasks[i].arg, argv[0]); i++)
844 ; /* keep looking for the task */
845
846 if (i > 0 && !tasks[i].arg) {
847 error(_("no such task: '%s'"), argv[0]);
848 usage_with_options(usagestr, options);
849 }
850 }
851
852 argc--;
853 argv++;
854 setup_enlistment_directory(argc, argv, usagestr, options, NULL);
855 strbuf_release(&buf);
856
857 if (i == 0)
858 return register_dir(1);
859
860 if (i > 0)
861 return run_git("maintenance", "run",
862 "--task", tasks[i].task, NULL);
863
864 if (register_dir(1))
865 return -1;
866 for (i = 1; tasks[i].arg; i++)
867 if (run_git("maintenance", "run",

Callers

nothing calls this directly

Calls 9

strbuf_addstrFunction · 0.85
strbuf_addfFunction · 0.85
parse_optionsFunction · 0.85
usage_with_optionsFunction · 0.85
errorFunction · 0.85
strbuf_releaseFunction · 0.85
register_dirFunction · 0.85
run_gitFunction · 0.85

Tested by

no test coverage detected