git-send-email: ssh/login style password requests
[gitweb.git] / builtin-archive.c
index f613ac25164beadb4874d8a07b6bbac62796a530..c2e0c1ea5a676f30baa52151d9e6a2a94d4cd091 100644 (file)
@@ -10,6 +10,7 @@
 #include "exec_cmd.h"
 #include "pkt-line.h"
 #include "sideband.h"
+#include "attr.h"
 
 static const char archive_usage[] = \
 "git-archive --format=<fmt> [--prefix=<prefix>/] [--verbose] [<extra>] <tree-ish> [path...]";
@@ -29,13 +30,13 @@ static int run_remote_archiver(const char *remote, int argc,
 {
        char *url, buf[LARGE_PACKET_MAX];
        int fd[2], i, len, rv;
-       pid_t pid;
+       struct child_process *conn;
        const char *exec = "git-upload-archive";
        int exec_at = 0;
 
        for (i = 1; i < argc; i++) {
                const char *arg = argv[i];
-               if (!strncmp("--exec=", arg, 7)) {
+               if (!prefixcmp(arg, "--exec=")) {
                        if (exec_at)
                                die("multiple --exec specified");
                        exec = arg + 7;
@@ -45,9 +46,7 @@ static int run_remote_archiver(const char *remote, int argc,
        }
 
        url = xstrdup(remote);
-       pid = git_connect(fd, url, exec);
-       if (pid < 0)
-               return pid;
+       conn = git_connect(fd, url, exec, 0);
 
        for (i = 1; i < argc; i++) {
                if (i == exec_at)
@@ -62,7 +61,7 @@ static int run_remote_archiver(const char *remote, int argc,
        if (buf[len-1] == '\n')
                buf[--len] = 0;
        if (strcmp(buf, "ACK")) {
-               if (len > 5 && !strncmp(buf, "NACK ", 5))
+               if (len > 5 && !prefixcmp(buf, "NACK "))
                        die("git-archive: NACK %s", buf + 5);
                die("git-archive: protocol error");
        }
@@ -75,7 +74,7 @@ static int run_remote_archiver(const char *remote, int argc,
        rv = recv_sideband("archive", fd[0], 1, 2);
        close(fd[0]);
        close(fd[1]);
-       rv |= finish_connect(pid);
+       rv |= finish_connect(conn);
 
        return !!rv;
 }
@@ -109,7 +108,7 @@ void parse_treeish_arg(const char **argv, struct archiver_args *ar_args,
        const unsigned char *commit_sha1;
        time_t archive_time;
        struct tree *tree;
-       struct commit *commit;
+       const struct commit *commit;
        unsigned char sha1[20];
 
        if (get_sha1(name, sha1))
@@ -142,6 +141,7 @@ void parse_treeish_arg(const char **argv, struct archiver_args *ar_args,
        }
        ar_args->tree = tree;
        ar_args->commit_sha1 = commit_sha1;
+       ar_args->commit = commit;
        ar_args->time = archive_time;
 }
 
@@ -149,7 +149,7 @@ int parse_archive_args(int argc, const char **argv, struct archiver *ar)
 {
        const char *extra_argv[MAX_EXTRA_ARGS];
        int extra_argc = 0;
-       const char *format = NULL; /* might want to default to "tar" */
+       const char *format = "tar";
        const char *base = "";
        int verbose = 0;
        int i;
@@ -166,11 +166,11 @@ int parse_archive_args(int argc, const char **argv, struct archiver *ar)
                        verbose = 1;
                        continue;
                }
-               if (!strncmp(arg, "--format=", 9)) {
+               if (!prefixcmp(arg, "--format=")) {
                        format = arg + 9;
                        continue;
                }
-               if (!strncmp(arg, "--prefix=", 9)) {
+               if (!prefixcmp(arg, "--prefix=")) {
                        base = arg + 9;
                        continue;
                }
@@ -190,8 +190,6 @@ int parse_archive_args(int argc, const char **argv, struct archiver *ar)
        /* We need at least one parameter -- tree-ish */
        if (argc - 1 < i)
                usage(archive_usage);
-       if (!format)
-               die("You must specify an archive format");
        if (init_archiver(format, ar) < 0)
                die("Unknown archive format '%s'", format);
 
@@ -218,7 +216,7 @@ static const char *extract_remote_arg(int *ac, const char **av)
                if (!strcmp(arg, "--"))
                        no_more_options = 1;
                if (!no_more_options) {
-                       if (!strncmp(arg, "--remote=", 9)) {
+                       if (!prefixcmp(arg, "--remote=")) {
                                if (remote)
                                        die("Multiple --remote specified");
                                remote = arg + 9;