git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] fetch-pack.c: show correct command name that fails

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Sep 18, 2013, 13:41 UTC
Message-ID
<1379511678-11611-1-git-send-email-pclouds@gmail.com>

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>
---
 fetch-pack.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/fetch-pack.c b/fetch-pack.c
index 6684348..b259c51 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -688,7 +688,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;
@@ -735,7 +735,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";
@@ -752,7 +752,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;
@@ -770,7 +770,7 @@ 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);
@@ -782,7 +782,7 @@ static int get_pack(struct fetch_pack_args *args,
 			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;
-- 
1.8.2.83.gc99314b
Next: Junio C Hamano
Message 1 of 3 in “fetch-pack.c: show correct command name that fails”
  1. fetch-pack.c: show correct command name that failsNguyễn Thái Ngọc Duy, Sep 18, 2013
  2. Junio C HamanoSep 18, 2013
  3. Jeff KingSep 18, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.