{"thread":{"id":"187","subject":"[PATCH] Usage-string fixes.","startedAt":"2005-04-21T02:38:33Z","lastAt":"2005-04-21T02:38:33Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"1080","messageId":"7v1x94hn12.fsf@assigned-by-dhcp.cox.net","threadId":"187","inReplyTo":null,"subject":"[PATCH] Usage-string fixes.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-04-21T02:38:33Z","receivedAt":"2005-04-21T02:38:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Usage string fixes to make maintenance easier (only one instance\nof a string to update not multiple copies).  I've spotted and\ncorrected inconsistent usage text in diff-tree while doing this.\n\nAlso diff-cache and read-tree usage text have been corrected to\nmatch their up-to-date features.  Earlier, neither \"--cached\"\nform of diff-cache nor \"-m single-merge\" form of read-tree were\ndescribed. \n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n commit-tree.c |   14 ++++++--------\n diff-cache.c  |    6 ++++--\n diff-tree.c   |    6 ++++--\n read-tree.c   |   10 ++++++----\n 4 files changed, 20 insertions(+), 16 deletions(-)\n\n\n--- ../git.linus/commit-tree.c\t2005-04-20 19:00:38.000000000 -0700\n+++ ../git.junio/commit-tree.c\t2005-04-20 11:41:45.000000000 -0700\n@@ -268,15 +268,13 @@\n }\n \n /*\n- * Having more than two parents may be strange, but hey, there's\n- * no conceptual reason why the file format couldn't accept multi-way\n- * merges. It might be the \"union\" of several packages, for example.\n- *\n- * I don't really expect that to happen, but this is here to make\n- * it clear that _conceptually_ it's ok..\n+ * Having more than two parents is not strange at all, and this is\n+ * how multi-way merges are represented.\n  */\n #define MAXPARENT (16)\n \n+static char *commit_tree_usage = \"commit-tree <sha1> [-p <sha1>]* < changelog\";\n+\n int main(int argc, char **argv)\n {\n \tint i, len;\n@@ -296,14 +294,14 @@\n \tunsigned int size;\n \n \tif (argc < 2 || get_sha1_hex(argv[1], tree_sha1) < 0)\n-\t\tusage(\"commit-tree <sha1> [-p <sha1>]* < changelog\");\n+\t\tusage(commit_tree_usage);\n \n \tcheck_valid(tree_sha1, \"tree\");\n \tfor (i = 2; i < argc; i += 2) {\n \t\tchar *a, *b;\n \t\ta = argv[i]; b = argv[i+1];\n \t\tif (!b || strcmp(a, \"-p\") || get_sha1_hex(b, parent_sha1[parents]))\n-\t\t\tusage(\"commit-tree <sha1> [-p <sha1>]* < changelog\");\n+\t\t\tusage(commit_tree_usage);\n \t\tcheck_valid(parent_sha1[parents], \"commit\");\n \t\tparents++;\n \t}\n\n\n--- ../git.linus/diff-cache.c\t2005-04-20 19:00:38.000000000 -0700\n+++ ../git.junio/diff-cache.c\t2005-04-20 19:14:25.000000000 -0700\n@@ -215,6 +215,8 @@\n \treturn 0;\n }\n \n+static char *diff_cache_usage = \"diff-cache [-r] [-z] [--cached] <tree sha1>\";\n+\n int main(int argc, char **argv)\n {\n \tunsigned char tree_sha1[20];\n@@ -238,11 +240,11 @@\n \t\t\tcached_only = 1;\n \t\t\tcontinue;\n \t\t}\n-\t\tusage(\"diff-cache [-r] [-z] <tree sha1>\");\n+\t\tusage(diff_cache_usage);\n \t}\n \n \tif (argc != 2 || get_sha1_hex(argv[1], tree_sha1))\n-\t\tusage(\"diff-cache [-r] [-z] <tree sha1>\");\n+\t\tusage(diff_cache_usage);\n \n \ttree = read_tree_with_tree_or_commit_sha1(tree_sha1, &size, 0);\n \tif (!tree)\n\n\n--- ../git.linus/diff-tree.c\t2005-04-20 19:00:38.000000000 -0700\n+++ ../git.junio/diff-tree.c\t2005-04-20 19:14:55.000000000 -0700\n@@ -178,6 +178,8 @@\n \treturn retval;\n }\n \n+static char *diff_tree_usage = \"diff-tree [-r] [-z] <tree sha1> <tree sha1>\";\n+\n int main(int argc, char **argv)\n {\n \tunsigned char old[20], new[20];\n@@ -194,10 +196,10 @@\n \t\t\tline_termination = '\\0';\n \t\t\tcontinue;\n \t\t}\n-\t\tusage(\"diff-tree [-r] [-z] <tree sha1> <tree sha1>\");\n+\t\tusage(diff_tree_usage);\n \t}\n \n \tif (argc != 3 || get_sha1_hex(argv[1], old) || get_sha1_hex(argv[2], new))\n-\t\tusage(\"diff-tree <tree sha1> <tree sha1>\");\n+\t\tusage(diff_tree_usage);\n \treturn diff_tree_sha1(old, new, \"\");\n }\n\n\n\n--- ../git.linus/read-tree.c\t2005-04-20 19:00:38.000000000 -0700\n+++ ../git.junio/read-tree.c\t2005-04-20 19:15:33.000000000 -0700\n@@ -217,6 +217,8 @@\n \t}\n }\n \n+static char *read_tree_usage = \"read-tree (<sha> | -m <sha1> [<sha2> <sha3>])\";\n+\n int main(int argc, char **argv)\n {\n \tint i, newfd, merge;\n@@ -236,20 +238,20 @@\n \t\tif (!strcmp(arg, \"-m\")) {\n \t\t\tint i;\n \t\t\tif (stage)\n-\t\t\t\tusage(\"-m needs to come first\");\n+\t\t\t\tdie(\"-m needs to come first\");\n \t\t\tread_cache();\n \t\t\tfor (i = 0; i < active_nr; i++) {\n \t\t\t\tif (ce_stage(active_cache[i]))\n-\t\t\t\t\tusage(\"you need to resolve your current index first\");\n+\t\t\t\t\tdie(\"you need to resolve your current index first\");\n \t\t\t}\n \t\t\tstage = 1;\n \t\t\tmerge = 1;\n \t\t\tcontinue;\n \t\t}\n \t\tif (get_sha1_hex(arg, sha1) < 0)\n-\t\t\tusage(\"read-tree [-m] <sha1>\");\n+\t\t\tusage(read_tree_usage);\n \t\tif (stage > 3)\n-\t\t\tusage(\"can't merge more than two trees\");\n+\t\t\tusage(read_tree_usage);\n \t\tif (read_tree(sha1, \"\", 0) < 0)\n \t\t\tdie(\"failed to unpack tree object %s\", arg);\n \t\tstage++;\n \n\n"}]}