{"thread":{"id":"5086","subject":"[PATCH 9/10] Remove cmd_usage() routine and re-organize the help/usage code.","startedAt":"2006-08-02T01:03:44Z","lastAt":"2006-08-04T04:33:13Z","messageCount":7,"participants":["Ramsay Jones","Martin Waitz","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":10},"messages":[{"id":"24543","messageId":"00c201c6b5cf$8089a580$c47eedc1@ramsay1.demon.co.uk","threadId":"5086","inReplyTo":null,"subject":"[PATCH 9/10] Remove cmd_usage() routine and re-organize the help/usage code.","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2006-08-02T01:03:44Z","receivedAt":"2006-08-02T01:03:44Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"The cmd_usage() routine was causing warning messages due to a NULL\nformat parameter being passed in three out of four calls. This is a\nproblem if you want to compile with -Werror. A simple solution is to\nsimply remove the GNU __attribute__ format pragma from the cmd_usage()\ndeclaration in the header file. The function interface was somewhat\nmuddled anyway, so re-write the code to finesse the problem.\n\nSigned-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>\n---\n builtin-help.c |   54\n+++++++++++++++++++++++-------------------------------\n builtin.h      |    7 ++-----\n git.c          |    7 +++++--\n 3 files changed, 30 insertions(+), 38 deletions(-)\n\ndiff --git a/builtin-help.c b/builtin-help.c\nindex 7470faa..006da05 100644\n--- a/builtin-help.c\n+++ b/builtin-help.c\n@@ -9,8 +9,6 @@ #include \"builtin.h\"\n #include \"exec_cmd.h\"\n #include \"common-cmds.h\"\n\n-static const char git_usage[] =\n-\t\"Usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND\n ARGS ]\";\n\n /* most gui terms set COLUMNS (although some don't export it) */\n static int term_columns(void)\n@@ -178,31 +176,6 @@ static void list_common_cmds_help(void)\n \tputs(\"(use 'git help -a' to get a list of all installed git commands)\");\n }\n\n-void cmd_usage(int show_all, const char *exec_path, const char *fmt, ...)\n-{\n-\tif (fmt) {\n-\t\tva_list ap;\n-\n-\t\tva_start(ap, fmt);\n-\t\tprintf(\"git: \");\n-\t\tvprintf(fmt, ap);\n-\t\tva_end(ap);\n-\t\tputchar('\\n');\n-\t}\n-\telse\n-\t\tputs(git_usage);\n-\n-\tif (exec_path) {\n-\t\tputchar('\\n');\n-\t\tif (show_all)\n-\t\t\tlist_commands(exec_path, \"git-*\");\n-\t\telse\n-\t\t\tlist_common_cmds_help();\n-        }\n-\n-\texit(1);\n-}\n-\n static void show_man_page(const char *git_cmd)\n {\n \tconst char *page;\n@@ -221,6 +194,13 @@ static void show_man_page(const char *gi\n \texeclp(\"man\", \"man\", page, NULL);\n }\n\n+void help_unknown_cmd(const char *cmd)\n+{\n+\tprintf(\"git: '%s' is not a git-command\\n\\n\", cmd);\n+\tlist_common_cmds_help();\n+\texit(1);\n+}\n+\n int cmd_version(int argc, const char **argv, char **envp)\n {\n \tprintf(\"git version %s\\n\", git_version_string);\n@@ -230,12 +210,24 @@ int cmd_version(int argc, const char **a\n int cmd_help(int argc, const char **argv, char **envp)\n {\n \tconst char *help_cmd = argv[1];\n-\tif (!help_cmd)\n-\t\tcmd_usage(0, git_exec_path(), NULL);\n-\telse if (!strcmp(help_cmd, \"--all\") || !strcmp(help_cmd, \"-a\"))\n-\t\tcmd_usage(1, git_exec_path(), NULL);\n+\tconst char *exec_path = git_exec_path();\n+\n+\tif (!help_cmd) {\n+\t\tprintf(\"usage: %s\\n\\n\", git_usage_string);\n+\t\tlist_common_cmds_help();\n+\t\texit(1);\n+\t}\n+\n+\telse if (!strcmp(help_cmd, \"--all\") || !strcmp(help_cmd, \"-a\")) {\n+\t\tprintf(\"usage: %s\\n\\n\", git_usage_string);\n+\t\tif(exec_path)\n+\t\t\tlist_commands(exec_path, \"git-*\");\n+\t\texit(1);\n+\t}\n+\n \telse\n \t\tshow_man_page(help_cmd);\n+\n \treturn 0;\n }\n\ndiff --git a/builtin.h b/builtin.h\nindex 7bfff11..b6cf5be 100644\n--- a/builtin.h\n+++ b/builtin.h\n@@ -5,12 +5,9 @@ #include <stdio.h>\n #include <limits.h>\n\n extern const char git_version_string[];\n+extern const char git_usage_string[];\n\n-void cmd_usage(int show_all, const char *exec_path, const char *fmt, ...)\n-#ifdef __GNUC__\n-\t__attribute__((__format__(__printf__, 3, 4), __noreturn__))\n-#endif\n-\t;\n+extern void help_unknown_cmd(const char *cmd);\n\n extern int cmd_help(int argc, const char **argv, char **envp);\n extern int cmd_version(int argc, const char **argv, char **envp);\ndiff --git a/git.c b/git.c\nindex ca8961f..f414df9 100644\n--- a/git.c\n+++ b/git.c\n@@ -14,6 +14,9 @@ #include \"cache.h\"\n\n #include \"builtin.h\"\n\n+const char git_usage_string[] =\n+\t\"git [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND [ ARGS ]\";\n+\n static void prepend_to_path(const char *dir, int len)\n {\n \tconst char *old_path = getenv(\"PATH\");\n@@ -279,7 +282,7 @@ int main(int argc, const char **argv, ch\n \t\t\tputs(git_exec_path());\n \t\t\texit(0);\n \t\t}\n-\t\tcmd_usage(0, NULL, NULL);\n+\t\tusage(git_usage_string);\n \t}\n \targv[0] = cmd;\n\n@@ -312,7 +315,7 @@ int main(int argc, const char **argv, ch\n \t}\n\n \tif (errno == ENOENT)\n-\t\tcmd_usage(0, exec_path, \"'%s' is not a git-command\", cmd);\n+\t\thelp_unknown_cmd(cmd);\n\n \tfprintf(stderr, \"Failed to run command '%s': %s\\n\",\n \t\tcmd, strerror(errno));\n--\n1.4.1\n\n\nFrom 1ce42e2b5b65b03657b3ca9a3b06dc97cc66573c Mon Sep 17 00:00:00 2001\nFrom: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>\nDate: Sun, 30 Jul 2006 22:42:25 +0100\nSubject: [PATCH 9/10] Remove cmd_usage() routine and re-organize the help/usage code.\n\nThe cmd_usage() routine was causing warning messages due to a NULL\nformat parameter being passed in three out of four calls. This is a\nproblem if you want to compile with -Werror. A simple solution is to\nsimply remove the GNU __attribute__ format pragma from the cmd_usage()\ndeclaration in the header file. The function interface was somewhat\nmuddled anyway, so re-write the code to finesse the problem.\n\nSigned-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>\n---\n builtin-help.c |   54 +++++++++++++++++++++++-------------------------------\n builtin.h      |    7 ++-----\n git.c          |    7 +++++--\n 3 files changed, 30 insertions(+), 38 deletions(-)\n\ndiff --git a/builtin-help.c b/builtin-help.c\nindex 7470faa..006da05 100644\n--- a/builtin-help.c\n+++ b/builtin-help.c\n@@ -9,8 +9,6 @@ #include \"builtin.h\"\n #include \"exec_cmd.h\"\n #include \"common-cmds.h\"\n \n-static const char git_usage[] =\n-\t\"Usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND [ ARGS ]\";\n \n /* most gui terms set COLUMNS (although some don't export it) */\n static int term_columns(void)\n@@ -178,31 +176,6 @@ static void list_common_cmds_help(void)\n \tputs(\"(use 'git help -a' to get a list of all installed git commands)\");\n }\n \n-void cmd_usage(int show_all, const char *exec_path, const char *fmt, ...)\n-{\n-\tif (fmt) {\n-\t\tva_list ap;\n-\n-\t\tva_start(ap, fmt);\n-\t\tprintf(\"git: \");\n-\t\tvprintf(fmt, ap);\n-\t\tva_end(ap);\n-\t\tputchar('\\n');\n-\t}\n-\telse\n-\t\tputs(git_usage);\n-\n-\tif (exec_path) {\n-\t\tputchar('\\n');\n-\t\tif (show_all)\n-\t\t\tlist_commands(exec_path, \"git-*\");\n-\t\telse\n-\t\t\tlist_common_cmds_help();\n-        }\n-\n-\texit(1);\n-}\n-\n static void show_man_page(const char *git_cmd)\n {\n \tconst char *page;\n@@ -221,6 +194,13 @@ static void show_man_page(const char *gi\n \texeclp(\"man\", \"man\", page, NULL);\n }\n \n+void help_unknown_cmd(const char *cmd)\n+{\n+\tprintf(\"git: '%s' is not a git-command\\n\\n\", cmd);\n+\tlist_common_cmds_help();\n+\texit(1);\n+}\n+\n int cmd_version(int argc, const char **argv, char **envp)\n {\n \tprintf(\"git version %s\\n\", git_version_string);\n@@ -230,12 +210,24 @@ int cmd_version(int argc, const char **a\n int cmd_help(int argc, const char **argv, char **envp)\n {\n \tconst char *help_cmd = argv[1];\n-\tif (!help_cmd)\n-\t\tcmd_usage(0, git_exec_path(), NULL);\n-\telse if (!strcmp(help_cmd, \"--all\") || !strcmp(help_cmd, \"-a\"))\n-\t\tcmd_usage(1, git_exec_path(), NULL);\n+\tconst char *exec_path = git_exec_path();\n+\n+\tif (!help_cmd) {\n+\t\tprintf(\"usage: %s\\n\\n\", git_usage_string);\n+\t\tlist_common_cmds_help();\n+\t\texit(1);\n+\t}\n+\n+\telse if (!strcmp(help_cmd, \"--all\") || !strcmp(help_cmd, \"-a\")) {\n+\t\tprintf(\"usage: %s\\n\\n\", git_usage_string);\n+\t\tif(exec_path)\n+\t\t\tlist_commands(exec_path, \"git-*\");\n+\t\texit(1);\n+\t}\n+\n \telse\n \t\tshow_man_page(help_cmd);\n+\n \treturn 0;\n }\n \ndiff --git a/builtin.h b/builtin.h\nindex 7bfff11..b6cf5be 100644\n--- a/builtin.h\n+++ b/builtin.h\n@@ -5,12 +5,9 @@ #include <stdio.h>\n #include <limits.h>\n \n extern const char git_version_string[];\n+extern const char git_usage_string[];\n \n-void cmd_usage(int show_all, const char *exec_path, const char *fmt, ...)\n-#ifdef __GNUC__\n-\t__attribute__((__format__(__printf__, 3, 4), __noreturn__))\n-#endif\n-\t;\n+extern void help_unknown_cmd(const char *cmd);\n \n extern int cmd_help(int argc, const char **argv, char **envp);\n extern int cmd_version(int argc, const char **argv, char **envp);\ndiff --git a/git.c b/git.c\nindex ca8961f..f414df9 100644\n--- a/git.c\n+++ b/git.c\n@@ -14,6 +14,9 @@ #include \"cache.h\"\n \n #include \"builtin.h\"\n \n+const char git_usage_string[] =\n+\t\"git [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND [ ARGS ]\";\n+\n static void prepend_to_path(const char *dir, int len)\n {\n \tconst char *old_path = getenv(\"PATH\");\n@@ -279,7 +282,7 @@ int main(int argc, const char **argv, ch\n \t\t\tputs(git_exec_path());\n \t\t\texit(0);\n \t\t}\n-\t\tcmd_usage(0, NULL, NULL);\n+\t\tusage(git_usage_string);\n \t}\n \targv[0] = cmd;\n \n@@ -312,7 +315,7 @@ int main(int argc, const char **argv, ch\n \t}\n \n \tif (errno == ENOENT)\n-\t\tcmd_usage(0, exec_path, \"'%s' is not a git-command\", cmd);\n+\t\thelp_unknown_cmd(cmd);\n \n \tfprintf(stderr, \"Failed to run command '%s': %s\\n\",\n \t\tcmd, strerror(errno));\n-- \n1.4.1\n\n"},{"id":"24560","messageId":"20060802132149.GG16364@admingilde.org","threadId":"5086","inReplyTo":"00c201c6b5cf$8089a580$c47eedc1@ramsay1.demon.co.uk","subject":"Re: [PATCH 9/10] Remove cmd_usage() routine and re-organize the help/usage code.","fromName":"Martin Waitz","fromEmail":"tali@admingilde.org","sentAt":"2006-08-02T13:21:50Z","receivedAt":"2006-08-02T13:21:50Z","isPatch":true,"sender":{"key":"tali@admingilde.org","avatar":"https://gravatar.com/avatar/3f89b03eee362187effabe257898735b475673a12265c398ea9161259ae91553?d=mp&s=160"},"body":"hoi :)\n\nOn Wed, Aug 02, 2006 at 02:03:44AM +0100, Ramsay Jones wrote:\n>  builtin-help.c |   54\n> +++++++++++++++++++++++-------------------------------\n>  builtin.h      |    7 ++-----\n>  git.c          |    7 +++++--\n>  3 files changed, 30 insertions(+), 38 deletions(-)\n\nthis patch is at the tip of \"master\" now, but with one more change:\nbuiltin-help.c           |   54 ++++++++++++++++++++--------------------------\nbuiltin.h                |    7 ++----\ngit.c                    |    7 ++++--\nt/t9100-git-svn-basic.sh |    7 +++---\n4 files changed, 33 insertions(+), 42 deletions(-)\n\ndiff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh\nindex bf1d638..34a3ccd 100755\n--- a/t/t9100-git-svn-basic.sh\n+++ b/t/t9100-git-svn-basic.sh\n@@ -170,7 +170,7 @@ then\n             test -L $SVN_TREE/exec-2.sh\"\n\n        name='modify a symlink to become a file'\n-       git help > help || true\n+       echo git help > help || true\n        rm exec-2.sh\n        cp help exec-2.sh\n        git update-index exec-2.sh\n\nthis looks strange.\n\n-- \nMartin Waitz\n"},{"id":"24576","messageId":"7v4pwvuhlo.fsf@assigned-by-dhcp.cox.net","threadId":"5086","inReplyTo":"20060802132149.GG16364@admingilde.org","subject":"Re: [PATCH 9/10] Remove cmd_usage() routine and re-organize the help/usage code.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-02T18:18:11Z","receivedAt":"2006-08-02T18:18:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Waitz <tali@admingilde.org> writes:\n\n> On Wed, Aug 02, 2006 at 02:03:44AM +0100, Ramsay Jones wrote:\n>>  builtin-help.c |   54\n>> +++++++++++++++++++++++-------------------------------\n>>  builtin.h      |    7 ++-----\n>>  git.c          |    7 +++++--\n>>  3 files changed, 30 insertions(+), 38 deletions(-)\n>\n> this patch is at the tip of \"master\" now, but with one more change:\n>...\n> diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh\n> index bf1d638..34a3ccd 100755\n> --- a/t/t9100-git-svn-basic.sh\n> +++ b/t/t9100-git-svn-basic.sh\n>...\n> this looks strange.\n\nRamsay's patch to cmd_help() broke this test because the test\nrelied on the details of output from \"git help\", which the patch\nsubtly changed.\n\nI considered making the fix for broken test a separate commit,\nbut the fix for the test was simple enough, so I rolled it in,\nwith the additional comment in the log to explain what was going\non -- I suspect the explanation was not clear enough.\n\nI could have committed the fix for the test first and then this\none.\n"},{"id":"24580","messageId":"001e01c6b664$294af180$c47eedc1@ramsay1.demon.co.uk","threadId":"5086","inReplyTo":"20060802132149.GG16364@admingilde.org","subject":"RE: [PATCH 9/10] Remove cmd_usage() routine and re-organize the help/usage code.","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2006-08-02T18:47:53Z","receivedAt":"2006-08-02T18:47:53Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nOn Wed, 2006-08-02 at 14:22 Martin Waitz wrote:\n> hoi :)\n> \n> On Wed, Aug 02, 2006 at 02:03:44AM +0100, Ramsay Jones wrote:\n> >  builtin-help.c |   54\n> > +++++++++++++++++++++++-------------------------------\n> >  builtin.h      |    7 ++-----\n> >  git.c          |    7 +++++--\n> >  3 files changed, 30 insertions(+), 38 deletions(-)\n> \n> this patch is at the tip of \"master\" now, but with one more change:\n> builtin-help.c           |   54 \n> ++++++++++++++++++++--------------------------\n> builtin.h                |    7 ++----\n> git.c                    |    7 ++++--\n> t/t9100-git-svn-basic.sh |    7 +++---\n> 4 files changed, 33 insertions(+), 42 deletions(-)\n> \n> diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh\n> index bf1d638..34a3ccd 100755\n> --- a/t/t9100-git-svn-basic.sh\n> +++ b/t/t9100-git-svn-basic.sh\n> @@ -170,7 +170,7 @@ then\n>              test -L $SVN_TREE/exec-2.sh\"\n> \n>         name='modify a symlink to become a file'\n> -       git help > help || true\n> +       echo git help > help || true\n>         rm exec-2.sh\n>         cp help exec-2.sh\n>         git update-index exec-2.sh\n> \n> this looks strange.\n> \n\nErm, well maybe. I dunno. Junio?\n\nRamsay\n \n"},{"id":"24656","messageId":"000101c6b72a$51601a80$c47eedc1@ramsay1.demon.co.uk","threadId":"5086","inReplyTo":"7v4pwvuhlo.fsf@assigned-by-dhcp.cox.net","subject":"RE: [PATCH 9/10] Remove cmd_usage() routine and re-organize the help/usage code.","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2006-08-03T18:26:20Z","receivedAt":"2006-08-03T18:26:20Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nOn Wed 2006-08-02 at 19:18, Junio C Hamano wrote:\n> \n> Martin Waitz <tali@admingilde.org> writes:\n> \n> > On Wed, Aug 02, 2006 at 02:03:44AM +0100, Ramsay Jones wrote:\n> >>  builtin-help.c |   54\n> >> +++++++++++++++++++++++-------------------------------\n> >>  builtin.h      |    7 ++-----\n> >>  git.c          |    7 +++++--\n> >>  3 files changed, 30 insertions(+), 38 deletions(-)\n> >\n> > this patch is at the tip of \"master\" now, but with one more change:\n> >...\n> > diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh\n> > index bf1d638..34a3ccd 100755\n> > --- a/t/t9100-git-svn-basic.sh\n> > +++ b/t/t9100-git-svn-basic.sh\n> >...\n> > this looks strange.\n> \n> Ramsay's patch to cmd_help() broke this test because the test\n> relied on the details of output from \"git help\", which the patch\n> subtly changed.\n> \n> I considered making the fix for broken test a separate commit,\n> but the fix for the test was simple enough, so I rolled it in,\n> with the additional comment in the log to explain what was going\n> on -- I suspect the explanation was not clear enough.\n> \n> I could have committed the fix for the test first and then this\n> one.\n> \n\nI was surprised and concerned to read that (how did I miss the\nfailing test?), until I found that I didn't have this test! (Phew)\nI assume this is a post 1.4.1 test, and from the name, I suppose\nthey would have mostly failed for me anyway since I don't have\nsvn installed.\n\nIn any event, I'm sorry to have broken your test, I should have\ndocumented the changed behaviour. The change should be limited to\na lower-case usage prefix and a change in exit code from 1 to 129.\nThe change from \"Usage:\" to \"usage:\" was for consistency with every\nother command (ignoring the test-delta program). The exit code\nchange only applies to one of the four original cmd_usage() call\nsites; namely the one changed to a usage() call.  Hmmm, should\nthe other three \"call sites\" change to exit(129) as well?\n\nAny other change in behavior was unintentional. Did I miss\nsomething?\n\nSpeaking of consistency, I noticed some inconsistent command\nnames in various usage strings. I attach a patch (p0011.txt)\nfor your consideration.\n\nDuring one of my \"grep-fests\", I also noticed some calls to\ndie(usage_string) rather than usage(usage_string). Calling die()\nrather than usage() means that a \"fatal: \" (rather than \"usage: \")\nprefix is output prior the usage string, and the exit code\nis 128 (rather than 129).\n\nIt looks like to choice of die() was deliberate, particularly in\nbuiltin-rm.c and hash-object.c since they call both die() and\nusage(). However, It's not clear to me why this choice was made.\n(Which is not to say there isn't a perfectly good reason for the\nchoice; it's just that I don't see it.)\n\nI attach a patch (p0012.txt) which replaces these calls to die()\nwith usage(). Since it is possible, however unlikely, that there\nare some scripts out there that depend on the current behavior,\nyou may not want to apply it.\n\nCheers,\n\nRamsay\n\n\nFrom 564d11cd55388f6a8de82b34b362543f73e0096c Mon Sep 17 00:00:00 2001\nFrom: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>\nDate: Thu, 3 Aug 2006 16:38:39 +0100\nSubject: [PATCH] Fixup command names in some usage strings.\n\nMost usage strings, such as for command xxx, start with \"git-xxx\".\nThis updates the rebels to conform to the general pattern.\n(The git wrapper is an exception to this, of course ...)\n\nSigned-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>\n---\n blame.c        |    2 +-\n builtin-diff.c |    2 +-\n builtin-push.c |    2 +-\n mktag.c        |    2 +-\n mktree.c       |    2 +-\n 5 files changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/blame.c b/blame.c\nindex c86e2fd..2f19b4d 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -20,7 +20,7 @@ #include \"xdiff-interface.h\"\n \n #define DEBUG 0\n \n-static const char blame_usage[] = \"[-c] [-l] [-t] [-S <revs-file>] [--] file [commit]\\n\"\n+static const char blame_usage[] = \"git-blame [-c] [-l] [-t] [-S <revs-file>] [--] file [commit]\\n\"\n \t\"  -c, --compability Use the same output mode as git-annotate (Default: off)\\n\"\n \t\"  -l, --long        Show long commit SHA1 (Default: off)\\n\"\n \t\"  -t, --time        Show raw timestamp (Default: off)\\n\"\ndiff --git a/builtin-diff.c b/builtin-diff.c\nindex 99a2f76..f934dc0 100644\n--- a/builtin-diff.c\n+++ b/builtin-diff.c\n@@ -23,7 +23,7 @@ struct blobinfo {\n };\n \n static const char builtin_diff_usage[] =\n-\"diff <options> <rev>{0,2} -- <path>*\";\n+\"git-diff <options> <rev>{0,2} -- <path>*\";\n \n static int builtin_diff_files(struct rev_info *revs,\n \t\t\t      int argc, const char **argv)\ndiff --git a/builtin-push.c b/builtin-push.c\nindex 66b9407..57db489 100644\n--- a/builtin-push.c\n+++ b/builtin-push.c\n@@ -8,7 +8,7 @@ #include \"builtin.h\"\n \n #define MAX_URI (16)\n \n-static const char push_usage[] = \"git push [--all] [--tags] [--force] <repository> [<refspec>...]\";\n+static const char push_usage[] = \"git-push [--all] [--tags] [--force] <repository> [<refspec>...]\";\n \n static int all = 0, tags = 0, force = 0, thin = 1;\n static const char *execute = NULL;\ndiff --git a/mktag.c b/mktag.c\nindex be41513..1d0cb17 100644\n--- a/mktag.c\n+++ b/mktag.c\n@@ -123,7 +123,7 @@ int main(int argc, char **argv)\n \tunsigned char result_sha1[20];\n \n \tif (argc != 1)\n-\t\tusage(\"cat <signaturefile> | git-mktag\");\n+\t\tusage(\"git-mktag < signaturefile\");\n \n \tsetup_git_directory();\n \ndiff --git a/mktree.c b/mktree.c\nindex ab63cd9..9a6f0d2 100644\n--- a/mktree.c\n+++ b/mktree.c\n@@ -71,7 +71,7 @@ static void write_tree(unsigned char *sh\n \twrite_sha1_file(buffer, offset, tree_type, sha1);\n }\n \n-static const char mktree_usage[] = \"mktree [-z]\";\n+static const char mktree_usage[] = \"git-mktree [-z]\";\n \n int main(int ac, char **av)\n {\n-- \n1.4.1\n\n\n\nFrom d5c3c850036f06c35416b8a515652c248bf4a73a Mon Sep 17 00:00:00 2001\nFrom: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>\nDate: Thu, 3 Aug 2006 16:48:41 +0100\nSubject: [PATCH] Replace some calls to die(usage_str) with usage(usage_str).\n\nThe only change in behaviour should be having a \"usage: \" prefix\non the output string rather than \"fatal: \", and an exit code of\n129 rather than 128.\n\nSigned-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>\n---\n builtin-add.c        |    2 +-\n builtin-init-db.c    |    2 +-\n builtin-rm.c         |    2 +-\n builtin-write-tree.c |    2 +-\n hash-object.c        |    4 ++--\n 5 files changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin-add.c b/builtin-add.c\nindex bfbbb1b..ced84ea 100644\n--- a/builtin-add.c\n+++ b/builtin-add.c\n@@ -158,7 +158,7 @@ int cmd_add(int argc, const char **argv,\n \t\t\tverbose = 1;\n \t\t\tcontinue;\n \t\t}\n-\t\tdie(builtin_add_usage);\n+\t\tusage(builtin_add_usage);\n \t}\n \tgit_config(git_default_config);\n \tpathspec = get_pathspec(prefix, argv + i);\ndiff --git a/builtin-init-db.c b/builtin-init-db.c\nindex 7fdd2fa..85a2afd 100644\n--- a/builtin-init-db.c\n+++ b/builtin-init-db.c\n@@ -267,7 +267,7 @@ int cmd_init_db(int argc, const char **a\n \t\telse if (!strncmp(arg, \"--shared=\", 9))\n \t\t\tshared_repository = git_config_perm(\"arg\", arg+9);\n \t\telse\n-\t\t\tdie(init_db_usage);\n+\t\t\tusage(init_db_usage);\n \t}\n \n \t/*\ndiff --git a/builtin-rm.c b/builtin-rm.c\nindex 4d56a1f..bfacbb2 100644\n--- a/builtin-rm.c\n+++ b/builtin-rm.c\n@@ -81,7 +81,7 @@ int cmd_rm(int argc, const char **argv, \n \t\t\tforce = 1;\n \t\t\tcontinue;\n \t\t}\n-\t\tdie(builtin_rm_usage);\n+\t\tusage(builtin_rm_usage);\n \t}\n \tif (argc <= i)\n \t\tusage(builtin_rm_usage);\ndiff --git a/builtin-write-tree.c b/builtin-write-tree.c\nindex 70e9b6f..bbe1f07 100644\n--- a/builtin-write-tree.c\n+++ b/builtin-write-tree.c\n@@ -74,7 +74,7 @@ int cmd_write_tree(int argc, const char \n \t\telse if (!strncmp(arg, \"--prefix=\", 9))\n \t\t\tprefix = arg + 9;\n \t\telse\n-\t\t\tdie(write_tree_usage);\n+\t\t\tusage(write_tree_usage);\n \t\targc--; argv++;\n \t}\n \ndiff --git a/hash-object.c b/hash-object.c\nindex 43bd93b..bf0b492 100644\n--- a/hash-object.c\n+++ b/hash-object.c\n@@ -46,7 +46,7 @@ int main(int argc, char **argv)\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\t\tusage(hash_object_usage);\n \t\t\t\ttype = argv[i];\n \t\t\t}\n \t\t\telse if (!strcmp(argv[i], \"-w\")) {\n@@ -66,7 +66,7 @@ int main(int argc, char **argv)\n \t\t\t\thash_stdin(type, write_object);\n \t\t\t}\n \t\t\telse\n-\t\t\t\tdie(hash_object_usage);\n+\t\t\t\tusage(hash_object_usage);\n \t\t} \n \t\telse {\n \t\t\tconst char *arg = argv[i];\n-- \n1.4.1\n\n"},{"id":"24662","messageId":"7vr6zxpqfp.fsf@assigned-by-dhcp.cox.net","threadId":"5086","inReplyTo":"000101c6b72a$51601a80$c47eedc1@ramsay1.demon.co.uk","subject":"Re: [PATCH 9/10] Remove cmd_usage() routine and re-organize the help/usage code.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-03T19:30:50Z","receivedAt":"2006-08-03T19:30:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Ramsay Jones\" <ramsay@ramsay1.demon.co.uk> writes:\n\n> In any event, I'm sorry to have broken your test,\n\nDon't worry.  My primary function while wearing the \"maintainer\"\nhat is to catch mistakes like this; even if this test breakage\nslipped through, it would not have been your fault but mine.\n\n> ... I should have\n> documented the changed behaviour. The change should be limited to\n> a lower-case usage prefix and a change in exit code from 1 to 129.\n\nI think both are good changes.  The native usage() exits with 129\nso it would be consistent for the git wrapper to exit with 129\nwhen it gives usage message, and in lowercase.\n\nWill take a look at your patches when I go home (I am at day-job\ntoday).\n"},{"id":"24686","messageId":"7vslkdnmra.fsf@assigned-by-dhcp.cox.net","threadId":"5086","inReplyTo":"000101c6b72a$51601a80$c47eedc1@ramsay1.demon.co.uk","subject":"Re: [PATCH 9/10] Remove cmd_usage() routine and re-organize the help/usage code.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-04T04:33:13Z","receivedAt":"2006-08-04T04:33:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Ramsay Jones\" <ramsay@ramsay1.demon.co.uk> writes:\n\n> Speaking of consistency, I noticed some inconsistent command\n> names in various usage strings. I attach a patch (p0011.txt)\n> for your consideration.\n\nThanks, all look good.\n\n> During one of my \"grep-fests\", I also noticed some calls to\n> die(usage_string) rather than usage(usage_string). Calling die()\n> rather than usage() means that a \"fatal: \" (rather than \"usage: \")\n> prefix is output prior the usage string, and the exit code\n> is 128 (rather than 129).\n>\n> It looks like to choice of die() was deliberate, particularly in\n> builtin-rm.c and hash-object.c since they call both die() and\n> usage(). However, It's not clear to me why this choice was made.\n> (Which is not to say there isn't a perfectly good reason for the\n> choice; it's just that I don't see it.)\n\nI think these were all sloppy coding.  The fix you did with\np0012 look good -- all of them are complaining that the command\nline parsing found something unexpected, so I think usage() is\nmore appropriate.\n"}]}