builtin/commit.c: extract ignore_non_trailer() helper function
[gitweb.git] / fetch-pack.c
index aff4f5abab667d054c9ab1b925e4877a4fd8d243..fab5e801755a9152aa19baf72b609052e1b32035 100644 (file)
@@ -9,6 +9,7 @@
 #include "fetch-pack.h"
 #include "remote.h"
 #include "run-command.h"
+#include "connect.h"
 #include "transport.h"
 #include "version.h"
 #include "prio-queue.h"
@@ -506,7 +507,7 @@ static void filter_refs(struct fetch_pack_args *args,
                next = ref->next;
 
                if (!memcmp(ref->name, "refs/", 5) &&
-                   check_refname_format(ref->name + 5, 0))
+                   check_refname_format(ref->name, 0))
                        ; /* trash */
                else {
                        while (i < nr_sought) {
@@ -658,7 +659,7 @@ static int get_pack(struct fetch_pack_args *args,
        const char *argv[22];
        char keep_arg[256];
        char hdr_arg[256];
-       const char **av;
+       const char **av, *cmd_name;
        int do_keep = args->keep_pack;
        struct child_process cmd;
        int ret;
@@ -705,7 +706,7 @@ static int get_pack(struct fetch_pack_args *args,
        if (do_keep) {
                if (pack_lockfile)
                        cmd.out = -1;
-               *av++ = "index-pack";
+               *av++ = cmd_name = "index-pack";
                *av++ = "--stdin";
                if (!args->quiet && !args->no_progress)
                        *av++ = "-v";
@@ -722,7 +723,7 @@ static int get_pack(struct fetch_pack_args *args,
                        *av++ = "--check-self-contained-and-connected";
        }
        else {
-               *av++ = "unpack-objects";
+               *av++ = cmd_name = "unpack-objects";
                if (args->quiet || args->no_progress)
                        *av++ = "-q";
                args->check_self_contained_and_connected = 0;
@@ -740,19 +741,23 @@ static int get_pack(struct fetch_pack_args *args,
        cmd.in = demux.out;
        cmd.git_cmd = 1;
        if (start_command(&cmd))
-               die("fetch-pack: unable to fork off %s", argv[0]);
+               die("fetch-pack: unable to fork off %s", cmd_name);
        if (do_keep && pack_lockfile) {
                *pack_lockfile = index_pack_lockfile(cmd.out);
                close(cmd.out);
        }
 
+       if (!use_sideband)
+               /* Closed by start_command() */
+               xd[0] = -1;
+
        ret = finish_command(&cmd);
        if (!ret || (args->check_self_contained_and_connected && ret == 1))
                args->self_contained_and_connected =
                        args->check_self_contained_and_connected &&
                        ret == 0;
        else
-               die("%s failed", argv[0]);
+               die("%s failed", cmd_name);
        if (use_sideband && finish_async(&demux))
                die("error in sideband demultiplexer");
        return 0;