Make some strbuf_*() struct strbuf arguments const.
[gitweb.git] / builtin-upload-archive.c
index 115a12dc13a09e9bfd4c965ca632709e0f1cd89b..371400d49a5ff9f6ce297d7af07eb3fd6426c9ee 100644 (file)
@@ -1,14 +1,11 @@
 /*
  * Copyright (c) 2006 Franck Bui-Huu
  */
-#include <time.h>
 #include "cache.h"
 #include "builtin.h"
 #include "archive.h"
 #include "pkt-line.h"
 #include "sideband.h"
-#include <sys/wait.h>
-#include <sys/poll.h>
 
 static const char upload_archive_usage[] =
        "git-upload-archive <repo>";
@@ -33,7 +30,7 @@ static int run_upload_archive(int argc, const char **argv, const char *prefix)
        if (argc != 2)
                usage(upload_archive_usage);
 
-       if (strlen(argv[1]) > sizeof(buf))
+       if (strlen(argv[1]) + 1 > sizeof(buf))
                die("insanely long repository name");
 
        strcpy(buf, argv[1]); /* enter-repo smudges its argument */
@@ -94,7 +91,7 @@ static void process_input(int child_fd, int band)
        char buf[16384];
        ssize_t sz = read(child_fd, buf, sizeof(buf));
        if (sz < 0) {
-               if (errno != EINTR)
+               if (errno != EAGAIN && errno != EINTR)
                        error_clnt("read error: %s\n", strerror(errno));
                return;
        }
@@ -160,7 +157,8 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix)
                if (pfd[1].revents & POLLIN)
                        /* Status stream ready */
                        process_input(pfd[1].fd, 2);
-               if ((pfd[0].revents | pfd[1].revents) == POLLIN)
+               /* Always finish to read data when available */
+               if ((pfd[0].revents | pfd[1].revents) & POLLIN)
                        continue;
 
                if (waitpid(writer, &status, 0) < 0)