| 808 | } |
| 809 | |
| 810 | static 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", |
nothing calls this directly
no test coverage detected