run-command API: move *_tr2() users to "run_processes_parallel()"

Have the users of the "run_processes_parallel_tr2()" function use "run_processes_parallel()" instead. In preceding commits the latter was refactored to take a "struct run_process_parallel_opts" argument, since the only reason for "run_processes_parallel_tr2()" to exist was to take arguments that are now a part of that struct we can do away with it. See ee4512ed481 (trace2: create new combined trace facility, 2019-02-22) for the addition of the "*_tr2()" variant of the function, it was used by every caller except "t/helper/test-run-command.c".. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Oct 12, 2022 at 23:02 UTC 36d69bf77e26793277d2708dd9ddad078e7e67a2
5 files changed +36 -37
builtin/fetch.c
+12 -6
@@ -1953,15 +1953,21 @@ static int fetch_multiple(struct string_list *list, int max_children)
1953
1954 if (max_children != 1 && list->nr != 1) {
1955 struct parallel_fetch_state state = { argv.v, list, 0, 0 };
1956 + const struct run_process_parallel_opts opts = {
1957 + .tr2_category = "fetch",
1958 + .tr2_label = "parallel/fetch",
1959 +
1960 + .processes = max_children,
1961 +
1962 + .get_next_task = &fetch_next_remote,
1963 + .start_failure = &fetch_failed_to_start,
1964 + .task_finished = &fetch_finished,
1965 + .data = &state,
1966 + };
1967
1968 strvec_push(&argv, "--end-of-options");
1958 - run_processes_parallel_tr2(max_children,
1959 - &fetch_next_remote,
1960 - &fetch_failed_to_start,
1961 - &fetch_finished,
1962 - &state,
1963 - "fetch", "parallel/fetch");
1969
1970 + run_processes_parallel(&opts);
1971 result = state.result;
1972 } else
1973 for (i = 0; i < list->nr; i++) {
builtin/submodule--helper.c
+12 -4
@@ -2567,12 +2567,20 @@ static int update_submodules(struct update_data *update_data)
2567 {
2568 int i, ret = 0;
2569 struct submodule_update_clone suc = SUBMODULE_UPDATE_CLONE_INIT;
2570 + const struct run_process_parallel_opts opts = {
2571 + .tr2_category = "submodule",
2572 + .tr2_label = "parallel/update",
2573 +
2574 + .processes = update_data->max_jobs,
2575 +
2576 + .get_next_task = update_clone_get_next_task,
2577 + .start_failure = update_clone_start_failure,
2578 + .task_finished = update_clone_task_finished,
2579 + .data = &suc,
2580 + };
2581
2582 suc.update_data = update_data;
2572 - run_processes_parallel_tr2(suc.update_data->max_jobs, update_clone_get_next_task,
2573 - update_clone_start_failure,
2574 - update_clone_task_finished, &suc, "submodule",
2575 - "parallel/update");
2583 + run_processes_parallel(&opts);
2584
2585 /*
2586 * We saved the output and put it out all at once now.
run-command.c
-18
@@ -1827,24 +1827,6 @@ void run_processes_parallel(const struct run_process_parallel_opts *opts)
1827 trace2_region_leave(tr2_category, tr2_label, NULL);
1828 }
1829
1830 -void run_processes_parallel_tr2(size_t processes, get_next_task_fn get_next_task,
1831 - start_failure_fn start_failure,
1832 - task_finished_fn task_finished, void *pp_cb,
1833 - const char *tr2_category, const char *tr2_label)
1834 -{
1835 - const struct run_process_parallel_opts opts = {
1836 - .tr2_category = tr2_category,
1837 - .tr2_label = tr2_label,
1838 - .processes = processes,
1839 -
1840 - .get_next_task = get_next_task,
1841 - .start_failure = start_failure,
1842 - .task_finished = task_finished,
1843 - };
1844 -
1845 - run_processes_parallel(&opts);
1846 -}
1847 -
1830 int run_auto_maintenance(int quiet)
1831 {
1832 int enabled;
run-command.h
-3
@@ -528,9 +528,6 @@ struct run_process_parallel_opts
528 * conditions due to writing in parallel to stdout and stderr.
529 */
530 void run_processes_parallel(const struct run_process_parallel_opts *opts);
531 -void run_processes_parallel_tr2(size_t processes, get_next_task_fn,
532 - start_failure_fn, task_finished_fn, void *pp_cb,
533 - const char *tr2_category, const char *tr2_label);
531
532 /**
533 * Convenience function which prepares env for a command to be run in a
submodule.c
+12 -6
@@ -1819,6 +1819,17 @@ int fetch_submodules(struct repository *r,
1819 {
1820 int i;
1821 struct submodule_parallel_fetch spf = SPF_INIT;
1822 + const struct run_process_parallel_opts opts = {
1823 + .tr2_category = "submodule",
1824 + .tr2_label = "parallel/fetch",
1825 +
1826 + .processes = max_parallel_jobs,
1827 +
1828 + .get_next_task = get_next_submodule,
1829 + .start_failure = fetch_start_failure,
1830 + .task_finished = fetch_finish,
1831 + .data = &spf,
1832 + };
1833
1834 spf.r = r;
1835 spf.command_line_option = command_line_option;
@@ -1840,12 +1851,7 @@ int fetch_submodules(struct repository *r,
1851
1852 calculate_changed_submodule_paths(r, &spf.changed_submodule_names);
1853 string_list_sort(&spf.changed_submodule_names);
1843 - run_processes_parallel_tr2(max_parallel_jobs,
1844 - get_next_submodule,
1845 - fetch_start_failure,
1846 - fetch_finish,
1847 - &spf,
1848 - "submodule", "parallel/fetch");
1854 + run_processes_parallel(&opts);
1855
1856 if (spf.submodules_with_errors.len > 0)
1857 fprintf(stderr, _("Errors during submodule fetch:\n%s"),