Code

match_refs: search ref list tail internally
[git.git] / shell.c
diff --git a/shell.c b/shell.c
index 0f6a727a8c267cdeb3a93c30bc688bb64ecd8003..b968be79f487f8d93e205fd0a844a206e24f21f8 100644 (file)
--- a/shell.c
+++ b/shell.c
@@ -40,6 +40,7 @@ static struct commands {
 } cmd_list[] = {
        { "git-receive-pack", do_generic_cmd },
        { "git-upload-pack", do_generic_cmd },
+       { "git-upload-archive", do_generic_cmd },
        { "cvs", do_cvs_cmd },
        { NULL },
 };
@@ -48,6 +49,19 @@ int main(int argc, char **argv)
 {
        char *prog;
        struct commands *cmd;
+       int devnull_fd;
+
+       /*
+        * Always open file descriptors 0/1/2 to avoid clobbering files
+        * in die().  It also avoids not messing up when the pipes are
+        * dup'ed onto stdin/stdout/stderr in the child processes we spawn.
+        */
+       devnull_fd = open("/dev/null", O_RDWR);
+       while (devnull_fd >= 0 && devnull_fd <= 2)
+               devnull_fd = dup(devnull_fd);
+       if (devnull_fd == -1)
+               die("opening /dev/null failed (%s)", strerror(errno));
+       close (devnull_fd);
 
        /*
         * Special hack to pretend to be a CVS server