fetch-pack.c: show correct command name that fails
When --shallow-file is added to the command line, it has to be before the subcommand name, the first argument won't be the command name any more. Stop assuming that and keep track of the command name explicitly. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Sep 18, 2013 at 20:41 UTC
4727f671b834a565343ed1af613654ba4d6ececc
1 file changed
+5
-5
fetch-pack.c
+5
-5
@@ -688,7 +688,7 @@ static int get_pack(struct fetch_pack_args *args,
688
const char *argv[22];
689
char keep_arg[256];
690
char hdr_arg[256];
691
- const char **av;
691
+ const char **av, *cmd_name;
692
int do_keep = args->keep_pack;
693
struct child_process cmd;
694
@@ -734,7 +734,7 @@ static int get_pack(struct fetch_pack_args *args,
734
if (do_keep) {
735
if (pack_lockfile)
736
cmd.out = -1;
737
- *av++ = "index-pack";
737
+ *av++ = cmd_name = "index-pack";
738
*av++ = "--stdin";
739
if (!args->quiet && !args->no_progress)
740
*av++ = "-v";
@@ -749,7 +749,7 @@ static int get_pack(struct fetch_pack_args *args,
749
}
750
}
751
else {
752
- *av++ = "unpack-objects";
752
+ *av++ = cmd_name = "unpack-objects";
753
if (args->quiet || args->no_progress)
754
*av++ = "-q";
755
}
@@ -766,14 +766,14 @@ static int get_pack(struct fetch_pack_args *args,
766
cmd.in = demux.out;
767
cmd.git_cmd = 1;
768
if (start_command(&cmd))
769
- die("fetch-pack: unable to fork off %s", argv[0]);
769
+ die("fetch-pack: unable to fork off %s", cmd_name);
770
if (do_keep && pack_lockfile) {
771
*pack_lockfile = index_pack_lockfile(cmd.out);
772
close(cmd.out);
773
}
774
775
if (finish_command(&cmd))
776
- die("%s failed", argv[0]);
776
+ die("%s failed", cmd_name);
777
if (use_sideband && finish_async(&demux))
778
die("error in sideband demultiplexer");
779
return 0;