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

Re: [PATCH] clone: detect extra arguments

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Oct 30, 2009, 11:19 UTC
Message-ID
<20091030111919.GA13242@progeny.tock>
In-Reply-To
<20091029160614.GB7622@sigill.intra.peff.net>
Jeff King wrote:
> Should we maybe be showing the usage in this case?
Sounds reasonable.  How about this patch on top?
-- %< --
Subject: [PATCH] clone: print usage on wrong number of arguments

git clone's short usage string is only 22 lines, so an error message plus usage string still fits comfortably on an 80x24 terminal.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 builtin-clone.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/builtin-clone.c b/builtin-clone.c
index 76ad581..736d9e1 100644
--- a/builtin-clone.c
+++ b/builtin-clone.c
@@ -378,10 +378,12 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 			     builtin_clone_usage, 0);
 
 	if (argc > 2)
-		die("Too many arguments.");
+		usage_msg_opt("Too many arguments.",
+			builtin_clone_usage, builtin_clone_options);
 
 	if (argc == 0)
-		die("You must specify a repository to clone.");
+		usage_msg_opt("You must specify a repository to clone.",
+			builtin_clone_usage, builtin_clone_options);
 
 	if (option_mirror)
 		option_bare = 1;
-- 
1.6.5.2
Previous: Jeff KingNext: Jeff King
Message 3 of 6 in “clone: detect extra arguments”
  1. clone: detect extra argumentsJonathan Nieder, Oct 29, 2009
  2. Jeff KingOct 29, 2009
  3. Jonathan NiederOct 30, 2009
  4. Jeff KingOct 30, 2009
  5. Jeff KingOct 30, 2009
  6. Johan HerlandOct 31, 2009

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.