Merge branch 'jk/submodule-c-credential'
[gitweb.git] / run-command.c
index 019f6d19a5a10718bd4aa94cf1076312e0297016..8c7115ade496e5bbaf1b584199da8f3ab21fa087 100644 (file)
@@ -625,6 +625,11 @@ int in_async(void)
        return !pthread_equal(main_thread, pthread_self());
 }
 
+void NORETURN async_exit(int code)
+{
+       pthread_exit((void *)(intptr_t)code);
+}
+
 #else
 
 static struct {
@@ -670,6 +675,11 @@ int in_async(void)
        return process_is_async;
 }
 
+void NORETURN async_exit(int code)
+{
+       exit(code);
+}
+
 #endif
 
 int start_async(struct async *async)
@@ -892,35 +902,18 @@ struct parallel_processes {
        struct strbuf buffered_output; /* of finished children */
 };
 
-static int default_start_failure(struct child_process *cp,
-                                struct strbuf *err,
+static int default_start_failure(struct strbuf *out,
                                 void *pp_cb,
                                 void *pp_task_cb)
 {
-       int i;
-
-       strbuf_addstr(err, "Starting a child failed:");
-       for (i = 0; cp->argv[i]; i++)
-               strbuf_addf(err, " %s", cp->argv[i]);
-
        return 0;
 }
 
 static int default_task_finished(int result,
-                                struct child_process *cp,
-                                struct strbuf *err,
+                                struct strbuf *out,
                                 void *pp_cb,
                                 void *pp_task_cb)
 {
-       int i;
-
-       if (!result)
-               return 0;
-
-       strbuf_addf(err, "A child failed with return code %d:", result);
-       for (i = 0; cp->argv[i]; i++)
-               strbuf_addf(err, " %s", cp->argv[i]);
-
        return 0;
 }
 
@@ -1001,7 +994,7 @@ static void pp_cleanup(struct parallel_processes *pp)
         * When get_next_task added messages to the buffer in its last
         * iteration, the buffered output is non empty.
         */
-       fputs(pp->buffered_output.buf, stderr);
+       strbuf_write(&pp->buffered_output, stderr);
        strbuf_release(&pp->buffered_output);
 
        sigchain_pop_common();
@@ -1038,8 +1031,7 @@ static int pp_start_one(struct parallel_processes *pp)
        pp->children[i].process.no_stdin = 1;
 
        if (start_command(&pp->children[i].process)) {
-               code = pp->start_failure(&pp->children[i].process,
-                                        &pp->children[i].err,
+               code = pp->start_failure(&pp->children[i].err,
                                         pp->data,
                                         &pp->children[i].data);
                strbuf_addbuf(&pp->buffered_output, &pp->children[i].err);
@@ -1087,7 +1079,7 @@ static void pp_output(struct parallel_processes *pp)
        int i = pp->output_owner;
        if (pp->children[i].state == GIT_CP_WORKING &&
            pp->children[i].err.len) {
-               fputs(pp->children[i].err.buf, stderr);
+               strbuf_write(&pp->children[i].err, stderr);
                strbuf_reset(&pp->children[i].err);
        }
 }
@@ -1107,7 +1099,7 @@ static int pp_collect_finished(struct parallel_processes *pp)
 
                code = finish_command(&pp->children[i].process);
 
-               code = pp->task_finished(code, &pp->children[i].process,
+               code = pp->task_finished(code,
                                         &pp->children[i].err, pp->data,
                                         &pp->children[i].data);
 
@@ -1125,11 +1117,11 @@ static int pp_collect_finished(struct parallel_processes *pp)
                        strbuf_addbuf(&pp->buffered_output, &pp->children[i].err);
                        strbuf_reset(&pp->children[i].err);
                } else {
-                       fputs(pp->children[i].err.buf, stderr);
+                       strbuf_write(&pp->children[i].err, stderr);
                        strbuf_reset(&pp->children[i].err);
 
                        /* Output all other finished child processes */
-                       fputs(pp->buffered_output.buf, stderr);
+                       strbuf_write(&pp->buffered_output, stderr);
                        strbuf_reset(&pp->buffered_output);
 
                        /*