summaryrefslogtreecommitdiff
path: root/convert.c
diff options
context:
space:
mode:
authorErik Faye-Lund <kusmabite@gmail.com>2010-02-05 12:57:38 -0800
committerJunio C Hamano <gitster@pobox.com>2010-02-05 20:57:22 -0800
commitae6a5609c025d9ac79e54a3a052704e25d885314 (patch)
treec74d50beebc5c7bfe2f5ca9e335c45c534243af7 /convert.c
parent4f41b611481bad08319966f7787fc7c4c7bfaa52 (diff)
downloadgit-ae6a5609c025d9ac79e54a3a052704e25d885314.tar.gz
run-command: support custom fd-set in async
This patch adds the possibility to supply a set of non-0 file descriptors for async process communication instead of the default-created pipe. Additionally, we now support bi-directional communiction with the async procedure, by giving the async function both read and write file descriptors. To retain compatiblity and similar "API feel" with start_command, we require start_async callers to set .out = -1 to get a readable file descriptor. If either of .in or .out is 0, we supply no file descriptor to the async process. [sp: Note: Erik started this patch, and a huge bulk of it is his work. All bugs were introduced later by Shawn.] Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'convert.c')
-rw-r--r--convert.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/convert.c b/convert.c
index 491e7141b4..e70ee094a7 100644
--- a/convert.c
+++ b/convert.c
@@ -241,7 +241,7 @@ struct filter_params {
const char *cmd;
};
-static int filter_buffer(int fd, void *data)
+static int filter_buffer(int in, int out, void *data)
{
/*
* Spawn cmd and feed the buffer contents through its stdin.
@@ -254,7 +254,7 @@ static int filter_buffer(int fd, void *data)
memset(&child_process, 0, sizeof(child_process));
child_process.argv = argv;
child_process.in = -1;
- child_process.out = fd;
+ child_process.out = out;
if (start_command(&child_process))
return error("cannot fork to run external filter %s", params->cmd);
@@ -291,6 +291,7 @@ static int apply_filter(const char *path, const char *src, size_t len,
memset(&async, 0, sizeof(async));
async.proc = filter_buffer;
async.data = &params;
+ async.out = -1;
params.src = src;
params.size = len;
params.cmd = cmd;