X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=builtin-archive.c;h=187491bc172571b783a0be4f4dfa3d94d58bb0fe;hb=401de4057ac83d473f8bead9b11d00b6371bd6a0;hp=2df1a84b85207961a44ce2c81665c5d473e20a9c;hpb=66f3b35fde42b9a235d8fd1c4d4a80f94bfd6a41;p=git.git diff --git a/builtin-archive.c b/builtin-archive.c index 2df1a84b8..187491bc1 100644 --- a/builtin-archive.c +++ b/builtin-archive.c @@ -2,7 +2,6 @@ * Copyright (c) 2006 Franck Bui-Huu * Copyright (c) 2006 Rene Scharfe */ -#include #include "cache.h" #include "builtin.h" #include "archive.h" @@ -36,7 +35,7 @@ static int run_remote_archiver(const char *remote, int argc, 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; @@ -46,7 +45,7 @@ static int run_remote_archiver(const char *remote, int argc, } url = xstrdup(remote); - pid = git_connect(fd, url, exec); + pid = git_connect(fd, url, exec, 0); if (pid < 0) return pid; @@ -63,7 +62,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,6 +74,7 @@ static int run_remote_archiver(const char *remote, int argc, /* Now, start reading from fd[0] and spit it out to stdout */ rv = recv_sideband("archive", fd[0], 1, 2); close(fd[0]); + close(fd[1]); rv |= finish_connect(pid); return !!rv; @@ -138,7 +138,6 @@ void parse_treeish_arg(const char **argv, struct archiver_args *ar_args, if (err || !S_ISDIR(mode)) die("current working directory is untracked"); - free(tree); tree = parse_tree_indirect(tree_sha1); } ar_args->tree = tree; @@ -150,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; @@ -167,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; } @@ -191,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); @@ -219,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; @@ -249,7 +246,7 @@ int cmd_archive(int argc, const char **argv, const char *prefix) if (remote) return run_remote_archiver(remote, argc, argv); - setlinebuf(stderr); + setvbuf(stderr, NULL, _IOLBF, BUFSIZ); memset(&ar, 0, sizeof(ar)); tree_idx = parse_archive_args(argc, argv, &ar);