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

[PATCH] Improve usage messages

From
Matthias Urlichs <smurf@smurf.noris.de>
Date
Apr 21, 2005, 12:41 UTC
Message-ID
<20050421124152.A28137F87D@smurf.noris.de>

This patch adds somewhat-improved usage messages to some of Linus' programs. Specifically, they now handle -? / --help.

Signed-Off-By: Matthias Urlichs <smurf@smurf.noris.de>
Index: check-files.c
===================================================================
--- 42a073eb6b5bb397a3e8768a032463a7fa02e6b9/check-files.c  (mode:100644 sha1:7d16691aa9d51b5b4670d5837b3527ee7c7da79c)
+++ 265515f9c4f089b1b61e9d2312c4b3babe189618/check-files.c  (mode:100644 sha1:be904b13659a60eab31787b010a64f2274048a9f)
@@ -40,6 +40,8 @@
 {
 	int i;
 
+	if(argc == 2 && (!strcmp(argv[1],"-?") || !strcmp(argv[1],"--help")))
+		usage("check-files filename...");
 	read_cache();
 	for (i = 1; i < argc ; i++)
 		check_file(argv[i]);
Index: diff-tree.c
===================================================================
--- 42a073eb6b5bb397a3e8768a032463a7fa02e6b9/diff-tree.c  (mode:100644 sha1:b0122e42631410fa579115f025efc3cab777cde6)
+++ 265515f9c4f089b1b61e9d2312c4b3babe189618/diff-tree.c  (mode:100644 sha1:03fcc2fae2f0b06f3834f0b6e0d8762e70f49f51)
@@ -193,6 +193,11 @@
 	}
 }
 
+static const char diff_tree_usage[] = 
+	"diff-tree [ -r (recurse) | -z (\\0-terminate) ]"
+		"\n\t<tree sha1> <tree sha1>";
+
+
 int main(int argc, char **argv)
 {
 	unsigned char old[20], new[20];
@@ -209,11 +214,11 @@
 			line_termination = '\0';
 			continue;
 		}
-		usage("diff-tree [-r] [-z] <tree sha1> <tree sha1>");
+		usage(diff_tree_usage);
 	}
 
 	if (argc != 3 || get_sha1_hex(argv[1], old) || get_sha1_hex(argv[2], new))
-		usage("diff-tree [-r] [-z] <tree sha1> <tree sha1>");
+		usage(diff_tree_usage);
 	commit_to_tree(old);
 	commit_to_tree(new);
 	return diff_tree_sha1(old, new, "");
--- 42a073eb6b5bb397a3e8768a032463a7fa02e6b9/init-db.c  (mode:100644 sha1:dad06351ca35d0d2f68cd9e719c49805386f96fa)
+++ 265515f9c4f089b1b61e9d2312c4b3babe189618/init-db.c  (mode:100644 sha1:4afd436e719b347cdf6b4420c9d926e453f1f95b)
@@ -26,6 +26,9 @@
 	char *sha1_dir, *path;
 	int len, i;
 
+	if(argc != 1)
+		usage("init-db");
+
 	safe_create_dir(".git");
 
 	sha1_dir = getenv(DB_ENVIRONMENT);
--- 42a073eb6b5bb397a3e8768a032463a7fa02e6b9/write-tree.c  (mode:100644 sha1:827809dbddbff6dd8cf842641f6db5ad2f3ae07a)
+++ 265515f9c4f089b1b61e9d2312c4b3babe189618/write-tree.c  (mode:100644 sha1:55fe1c75c3065c8d5bef34f4f2e7af7aa147ea9d)
@@ -101,9 +101,13 @@
 int main(int argc, char **argv)
 {
 	int i, unmerged;
-	int entries = read_cache();
+	int entries;
 	unsigned char sha1[20];
 
+	if(argc != 1)
+		usage("write-tree");
+
+	entries = read_cache();
 	if (entries <= 0)
 		die("write-tree: no cache contents to write");
 
Next: Petr Baudis
Message 1 of 4 in “Improve usage messages”
  1. Improve usage messagesMatthias Urlichs, Apr 21, 2005
  2. Petr BaudisApr 21, 2005
  3. David GreavesApr 21, 2005
  4. Junio C HamanoApr 21, 2005

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.