{"thread":{"id":"2753","subject":"Some Documentation/Usage Notes","startedAt":"2005-12-06T05:21:38Z","lastAt":"2005-12-06T06:25:48Z","messageCount":3,"participants":["Jon Loeliger","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"13242","messageId":"E1EjVGk-00015M-Np@jdl.com","threadId":"2753","inReplyTo":null,"subject":"Some Documentation/Usage Notes","fromName":"Jon Loeliger","fromEmail":"jdl@freescale.com","sentAt":"2005-12-06T05:21:38Z","receivedAt":"2005-12-06T05:21:38Z","isPatch":false,"sender":{"key":"jdl@jdl.com","avatar":"https://gravatar.com/avatar/75ce9a10b151acd2c28ec4ab2136dba7b2ff1634530bd04b155981a749d08a64?d=mp&s=160"},"body":"\nNote to $self -- here are some tidbits ToDo:\n\no   --help  doesn't work on:\n        git-hash-object\n\tgit-init-db\n\tgit-write-tree\n\no   There is an odd <any-file-on-the-filesystem> argment named\n    in the git-hash-object documentation.  Would <file> be better\n    and more consistent?  Or is there some subtlety that I am missing?\n\no   Someone might want to check my --template=<dir> description\n    on git-init-db, or make it clearer.\n\no   Work towards moving uniform description of all environment\n    variables in one includable/referenceable Documentation/ file?\n"},{"id":"13244","messageId":"7v64q27o1s.fsf@assigned-by-dhcp.cox.net","threadId":"2753","inReplyTo":"E1EjVGk-00015M-Np@jdl.com","subject":"Re: Some Documentation/Usage Notes","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-06T06:11:11Z","receivedAt":"2005-12-06T06:11:11Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jon Loeliger <jdl@freescale.com> writes:\n\n> Note to $self -- here are some tidbits ToDo:\n>\n> o   --help  doesn't work on:\n>       git-hash-object\n> \tgit-init-db\n> \tgit-write-tree\n\nNoted.  Thanks.\n\n> o   There is an odd <any-file-on-the-filesystem> argment named\n>     in the git-hash-object documentation.  Would <file> be better\n>     and more consistent?  Or is there some subtlety that I am missing?\n\nThe subtlety is that it is the only parameter to the coreish\ncommand set that happily named a file outside the project\ndirectory (i.e. you can say \"git-hash-object /etc/passwd\" but\nyou cannot say \"git-update-index /etc/passwd\" --- even if your\nrepository is at /.git, you would say \"git-update-index\netc/passwd\" for that). But you are right.  That distinction is\nirrelevant.\n"},{"id":"13245","messageId":"7vvey268sz.fsf@assigned-by-dhcp.cox.net","threadId":"2753","inReplyTo":"E1EjVGk-00015M-Np@jdl.com","subject":"Re: Some Documentation/Usage Notes","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-06T06:25:48Z","receivedAt":"2005-12-06T06:25:48Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jon Loeliger <jdl@freescale.com> writes:\n\n> o   --help  doesn't work on:\n>         git-hash-object\n> \tgit-init-db\n> \tgit-write-tree\n\nSomething like this?\n\n-- >8 --\n[PATCH] misc fixes.\n\n - It was cumbersome to feed hash-object the file '-t' (you\n   could have said \"./-t\", though).  Teach it '--' that\n   terminates the option list, like everybody else.  There is no\n   way to extract usage string from the command either, so teach\n   it \"--help\" as well.\n\n - \"git-init-db junk\" does not complain but just ignores \"junk\".\n   Die with the usage string in such a case.\n\n - \"git-write-tree junk\" complains and dies, but it does not say\n   what option it supports.  Die with the usage string in such a\n   case.\n\n---\ndiff --git a/hash-object.c b/hash-object.c\nindex ccba11c..6227936 100644\n--- a/hash-object.c\n+++ b/hash-object.c\n@@ -31,19 +31,30 @@ int main(int argc, char **argv)\n \tint write_object = 0;\n \tconst char *prefix = NULL;\n \tint prefix_length = -1;\n+\tint no_more_flags = 0;\n \n \tfor (i = 1 ; i < argc; i++) {\n-\t\tif (!strcmp(argv[i], \"-t\")) {\n-\t\t\tif (argc <= ++i)\n-\t\t\t\tdie(hash_object_usage);\n-\t\t\ttype = argv[i];\n-\t\t}\n-\t\telse if (!strcmp(argv[i], \"-w\")) {\n-\t\t\tif (prefix_length < 0) {\n-\t\t\t\tprefix = setup_git_directory();\n-\t\t\t\tprefix_length = prefix ? strlen(prefix) : 0;\n+\t\tif (!no_more_flags && argv[i][0] == '-') {\n+\t\t\tif (!strcmp(argv[i], \"-t\")) {\n+\t\t\t\tif (argc <= ++i)\n+\t\t\t\t\tdie(hash_object_usage);\n+\t\t\t\ttype = argv[i];\n+\t\t\t}\n+\t\t\telse if (!strcmp(argv[i], \"-w\")) {\n+\t\t\t\tif (prefix_length < 0) {\n+\t\t\t\t\tprefix = setup_git_directory();\n+\t\t\t\t\tprefix_length =\n+\t\t\t\t\t\tprefix ? strlen(prefix) : 0;\n+\t\t\t\t}\n+\t\t\t\twrite_object = 1;\n \t\t\t}\n-\t\t\twrite_object = 1;\n+\t\t\telse if (!strcmp(argv[i], \"--\")) {\n+\t\t\t\tno_more_flags = 1;\n+\t\t\t}\n+\t\t\telse if (!strcmp(argv[i], \"--help\"))\n+\t\t\t\tusage(hash_object_usage);\n+\t\t\telse\n+\t\t\t\tdie(hash_object_usage);\n \t\t}\n \t\telse {\n \t\t\tconst char *arg = argv[i];\n@@ -51,6 +62,7 @@ int main(int argc, char **argv)\n \t\t\t\targ = prefix_filename(prefix, prefix_length,\n \t\t\t\t\t\t      arg);\n \t\t\thash_object(arg, type, write_object);\n+\t\t\tno_more_flags = 1;\n \t\t}\n \t}\n \treturn 0;\ndiff --git a/init-db.c b/init-db.c\nindex 8195b68..ead37b5 100644\n--- a/init-db.c\n+++ b/init-db.c\n@@ -237,9 +237,7 @@ int main(int argc, char **argv)\n \n \tfor (i = 1; i < argc; i++, argv++) {\n \t\tchar *arg = argv[1];\n-\t\tif (arg[0] != '-')\n-\t\t\tbreak;\n-\t\telse if (!strncmp(arg, \"--template=\", 11))\n+\t\tif (!strncmp(arg, \"--template=\", 11))\n \t\t\ttemplate_dir = arg+11;\n \t\telse\n \t\t\tdie(init_db_usage);\ndiff --git a/write-tree.c b/write-tree.c\nindex 0aac32f..18507db 100644\n--- a/write-tree.c\n+++ b/write-tree.c\n@@ -83,6 +83,8 @@ static int write_tree(struct cache_entry\n \treturn nr;\n }\n \n+static const char write_tree_usage[] = \"git-write-tree [--missing-ok]\";\n+\n int main(int argc, char **argv)\n {\n \tint i, funny;\n@@ -95,8 +97,10 @@ int main(int argc, char **argv)\n \tif (argc == 2) {\n \t\tif (!strcmp(argv[1], \"--missing-ok\"))\n \t\t\tmissing_ok = 1;\n+\t\telse if (!strcmp(argv[1], \"--help\"))\n+\t\t\tusage(write_tree_usage);\n \t\telse\n-\t\t\tdie(\"unknown option %s\", argv[1]);\n+\t\t\tdie(write_tree_usage);\n \t}\n \t\n \tif (argc > 2)\n"}]}