Skip to content

Commit 357f8e6

Browse files
avargitster
authored andcommitted
run-command.c: don't copy "ungroup" to "struct parallel_processes"
As with the *_fn members removed in the preceding commit, let's not copy the "ungroup" member of the "struct run_process_parallel_opts" over to the "struct parallel_processes". Now that we're passing the "opts" down there's no reason to do so. This makes the code easier to follow, as we have a "const" attribute on the "struct run_process_parallel_opts", but not "struct parallel_processes". We do not alter the "ungroup" argument, so storing it in the non-const structure would make this control flow less obvious. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fa93951 commit 357f8e6

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

run-command.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,7 +1515,6 @@ struct parallel_processes {
15151515
struct pollfd *pfd;
15161516

15171517
unsigned shutdown : 1;
1518-
const unsigned ungroup : 1;
15191518

15201519
size_t output_owner;
15211520
struct strbuf buffered_output; /* of finished children */
@@ -1552,7 +1551,7 @@ static void pp_init(struct parallel_processes *pp,
15521551
BUG("you need to specify a get_next_task function");
15531552

15541553
CALLOC_ARRAY(pp->children, n);
1555-
if (!pp->ungroup)
1554+
if (!opts->ungroup)
15561555
CALLOC_ARRAY(pp->pfd, n);
15571556

15581557
for (size_t i = 0; i < n; i++) {
@@ -1609,32 +1608,32 @@ static int pp_start_one(struct parallel_processes *pp,
16091608
BUG("bookkeeping is hard");
16101609

16111610
code = opts->get_next_task(&pp->children[i].process,
1612-
pp->ungroup ? NULL : &pp->children[i].err,
1611+
opts->ungroup ? NULL : &pp->children[i].err,
16131612
pp->data,
16141613
&pp->children[i].data);
16151614
if (!code) {
1616-
if (!pp->ungroup) {
1615+
if (!opts->ungroup) {
16171616
strbuf_addbuf(&pp->buffered_output, &pp->children[i].err);
16181617
strbuf_reset(&pp->children[i].err);
16191618
}
16201619
return 1;
16211620
}
1622-
if (!pp->ungroup) {
1621+
if (!opts->ungroup) {
16231622
pp->children[i].process.err = -1;
16241623
pp->children[i].process.stdout_to_stderr = 1;
16251624
}
16261625
pp->children[i].process.no_stdin = 1;
16271626

16281627
if (start_command(&pp->children[i].process)) {
16291628
if (opts->start_failure)
1630-
code = opts->start_failure(pp->ungroup ? NULL :
1629+
code = opts->start_failure(opts->ungroup ? NULL :
16311630
&pp->children[i].err,
16321631
pp->data,
16331632
pp->children[i].data);
16341633
else
16351634
code = 0;
16361635

1637-
if (!pp->ungroup) {
1636+
if (!opts->ungroup) {
16381637
strbuf_addbuf(&pp->buffered_output, &pp->children[i].err);
16391638
strbuf_reset(&pp->children[i].err);
16401639
}
@@ -1705,7 +1704,7 @@ static int pp_collect_finished(struct parallel_processes *pp,
17051704
code = finish_command(&pp->children[i].process);
17061705

17071706
if (opts->task_finished)
1708-
code = opts->task_finished(code, pp->ungroup ? NULL :
1707+
code = opts->task_finished(code, opts->ungroup ? NULL :
17091708
&pp->children[i].err, pp->data,
17101709
pp->children[i].data);
17111710
else
@@ -1722,7 +1721,7 @@ static int pp_collect_finished(struct parallel_processes *pp,
17221721
pp->pfd[i].fd = -1;
17231722
child_process_init(&pp->children[i].process);
17241723

1725-
if (pp->ungroup) {
1724+
if (opts->ungroup) {
17261725
; /* no strbuf_*() work to do here */
17271726
} else if (i != pp->output_owner) {
17281727
strbuf_addbuf(&pp->buffered_output, &pp->children[i].err);
@@ -1761,7 +1760,6 @@ void run_processes_parallel(const struct run_process_parallel_opts *opts)
17611760
.max_processes = opts->processes,
17621761
.data = opts->data,
17631762
.buffered_output = STRBUF_INIT,
1764-
.ungroup = opts->ungroup,
17651763
};
17661764
/* options */
17671765
const char *tr2_category = opts->tr2_category;

0 commit comments

Comments
 (0)