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

[PATCHv3 1/2] read-tree: convert unhelpful usage()'s to helpful die()'s

From
Stephen Boyd <bebarino@gmail.com>
Date
Jun 26, 2009, 05:14 UTC
Message-ID
<1245993250-8213-1-git-send-email-bebarino@gmail.com>
In-Reply-To
<1245817672-25483-1-git-send-email-bebarino@gmail.com>

Printing the usage message when encountering bad option combinations is not very helpful. Instead, die with a message which tells the user exactly what combination is invalid.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---
Added --prefix and --reset to the second die message.
 builtin-read-tree.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index 82e25ea..17c9631 100644
--- a/builtin-read-tree.c
+++ b/builtin-read-tree.c
@@ -145,9 +145,8 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
 			continue;
 		}
 
-		/* using -u and -i at the same time makes no sense */
 		if (1 < opts.index_only + opts.update)
-			usage(read_tree_usage);
+			die("-u and -i at the same time makes no sense");
 
 		if (get_sha1(arg, sha1))
 			die("Not a valid object name %s", arg);
@@ -156,7 +155,8 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
 		stage++;
 	}
 	if ((opts.update||opts.index_only) && !opts.merge)
-		usage(read_tree_usage);
+		die("%s is meaningless without -m, --reset, or --prefix",
+		    opts.update ? "-u" : "-i");
 	if ((opts.dir && !opts.update))
 		die("--exclude-per-directory is meaningless unless -u");
 	if (opts.merge && !opts.index_only)
-- 
1.6.3.3.334.g916e1
Previous: Stephen BoydNext: Stephen Boyd
Message 8 of 12 in “read-tree: convert unhelpful usage()'s to helpful die()'s”
  1. 1/2 read-tree: convert unhelpful usage()'s to helpful die()'sStephen Boyd, Jun 24, 2009
  2. 2/2 read-tree: migrate to parse-optionsStephen Boyd, Jun 24, 2009
  3. Junio C HamanoJun 24, 2009
  4. Stephen BoydJun 25, 2009
  5. 2/2 read-tree: migrate to parse-optionsStephen Boyd, Jun 25, 2009
  6. Johannes SixtJun 25, 2009
  7. Stephen BoydJun 26, 2009
  8. 1/2 read-tree: convert unhelpful usage()'s to helpful die()'sStephen Boyd, Jun 26, 2009
  9. 2/2 read-tree: migrate to parse-optionsStephen Boyd, Jun 26, 2009
  10. Stephen BoydJun 26, 2009
  11. Junio C HamanoJun 26, 2009
  12. Stephen BoydJun 27, 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.