diff --git a/receive-pack.c b/receive-pack.c
index cbe37e7..1873506 100644
--- a/receive-pack.c
+++ b/receive-pack.c
@@ -173,7 +173,7 @@ static void run_update_post_hook(struct
argc++;
}
argv[argc] = NULL;
- run_command_v_opt(argc, argv, RUN_COMMAND_NO_STDIO);
+ run_command_v(argc, argv);
}
/*
diff --git a/run-command.c b/run-command.c
index 8bf5922..38cd6cb 100644
--- a/run-command.c
+++ b/run-command.c
@@ -2,19 +2,23 @@
#include "run-command.h"
#include <sys/wait.h>
-int run_command_v_opt(int argc, char **argv, int flags)
+int run_command_v(int argc, char **argv)
{
- pid_t pid = fork();
+
+ pid_t pid = (pid_t)-1;
+
+ /* Because each process has independent buffering, if you
+ * don't flush before the fork, it can seem like the new
+ * output for the child occurs before the old output of the
+ * parent which can be confusing at times. */
+ fflush(stdout);
+ fflush(stderr);
+
+ pid = fork();
if (pid < 0)
return -ERR_RUN_COMMAND_FORK;
if (!pid) {
- if (flags & RUN_COMMAND_NO_STDIO) {
- int fd = open("/dev/null", O_RDWR);
- dup2(fd, 0);
- dup2(fd, 1);
- close(fd);
- }
execvp(argv[0], (char *const*) argv);
die("exec %s failed.", argv[0]);
}@@ -42,11 +46,6 @@ int run_command_v_opt(int argc, char **a
}
}
-int run_command_v(int argc, char **argv)
-{
- return run_command_v_opt(argc, argv, 0);
-}
-
int run_command(const char *cmd, ...)
{
int argc;@@ -65,5 +64,5 @@ int run_command(const char *cmd, ...)
va_end(param);
if (MAX_RUN_COMMAND_ARGS <= argc)
return error("too many args to run %s", cmd);
- return run_command_v_opt(argc, argv, 0);
+ return run_command_v(argc, argv);
}diff --git a/run-command.h b/run-command.h
index 2469eea..5ee0972 100644
--- a/run-command.h
+++ b/run-command.h
@@ -11,9 +11,6 @@ enum {
ERR_RUN_COMMAND_WAITPID_NOEXIT,
};
-#define RUN_COMMAND_NO_STDIO 1
-
-int run_command_v_opt(int argc, char **argv, int opt);
int run_command_v(int argc, char **argv);
int run_command(const char *cmd, ...);
diff --git a/send-pack.c b/send-pack.c
index 6ce0d9f..5a99ba9 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -319,8 +319,15 @@ int main(int argc, char **argv)
if (pid < 0)
return 1;
ret = send_pack(fd[0], fd[1], nr_heads, heads);
- close(fd[0]);
+
+ /* Close our side of the conversation. Wait for the child to
+ * close its side of the conversation (copying the remainder
+ * to our stdout). Note that copy_fd() has the side effect of
+ * closing fd[0]. */
close(fd[1]);
+ copy_fd(fd[0], fileno(stdout));
+
finish_connect(pid);
+
return ret;
}
diff --git a/templates/hooks--post-update b/templates/hooks--post-update
index bcba893..d470dcc 100644
--- a/templates/hooks--post-update
+++ b/templates/hooks--post-update
@@ -5,4 +5,8 @@
#
# To enable this hook, make this file executable by "chmod +x post-update".
+# If your stdout and stderr messages are interleaved, uncomment the
+# following line.
+#exec 1>&2
+
exec git-update-server-info
diff --git a/templates/hooks--update b/templates/hooks--update
index 6db555f..6199deb 100644
--- a/templates/hooks--update
+++ b/templates/hooks--update
@@ -8,6 +8,10 @@
# (2) make this file executable by "chmod +x update".
#
+# If your stdout and stderr messages are interleaved, uncomment the
+# following line.
+#exec 1>&2
+
recipient="commit-list@example.com"
if expr "$2" : '0*$' >/dev/null
--
0.99.9.GIT