git-am: Add colon before the subject that is printed out as being applied
[gitweb.git] / builtin-upload-archive.c
index 0596865679d79e1f02877ea47fb910a7c771f38f..13a6c6203eff7d8dc96a56fa5709dc9eb69da0a6 100644 (file)
@@ -1,28 +1,26 @@
 /*
  * 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>";
+       "git upload-archive <repo>";
 
 static const char deadchild[] =
-"git-upload-archive: archiver died with error";
+"git upload-archive: archiver died with error";
 
 static const char lostchild[] =
-"git-upload-archive: archiver process was lost";
+"git upload-archive: archiver process was lost";
 
 
 static int run_upload_archive(int argc, const char **argv, const char *prefix)
 {
-       struct archiver ar;
+       const struct archiver *ar;
+       struct archiver_args args;
        const char *sent_argv[MAX_ARGS];
        const char *arg_cmd = "argument ";
        char *p, buf[4096];
@@ -33,7 +31,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 */
@@ -68,12 +66,12 @@ static int run_upload_archive(int argc, const char **argv, const char *prefix)
        sent_argv[sent_argc] = NULL;
 
        /* parse all options sent by the client */
-       treeish_idx = parse_archive_args(sent_argc, sent_argv, &ar);
+       treeish_idx = parse_archive_args(sent_argc, sent_argv, &ar, &args);
 
-       parse_treeish_arg(sent_argv + treeish_idx, &ar.args, prefix);
-       parse_pathspec_arg(sent_argv + treeish_idx + 1, &ar.args);
+       parse_treeish_arg(sent_argv + treeish_idx, &args, prefix);
+       parse_pathspec_arg(sent_argv + treeish_idx + 1, &args);
 
-       return ar.write_archive(&ar.args);
+       return ar->write_archive(&args);
 }
 
 static void error_clnt(const char *fmt, ...)
@@ -94,7 +92,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;
        }