{"thread":{"id":"21527","subject":"[PATCH] Let 'git <command> -h' show usage without a git dir","startedAt":"2009-11-08T07:11:52Z","lastAt":"2009-11-11T01:58:33Z","messageCount":39,"participants":["Jonathan Nieder","Junio C Hamano","Tay Ray Chuan","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"127064","messageId":"20091108071152.GA20741@progeny.tock","threadId":"21527","inReplyTo":"20080125173149.GA10287@edna.gwendoline.at","subject":"[PATCH] Let 'git <command> -h' show usage without a git dir","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-08T07:11:52Z","receivedAt":"2009-11-08T07:11:52Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nGerfried Fuchs wrote:\n\n>  I really wonder why \"git <command> -h\" depends on being inside a\n> repository. I noticed it with \"git diff -h\" (add, branch does that, too):\n> \n> #v+\n> ~/git> git tag -h\n> usage: git-tag [-n [<num>]] -l [<pattern>] | [-a | -s | -u <key-id>] [-f | -d | -v] [-m <msg> | -F <file>] <tagname> [<head>]\n> ~/git> cd\n> ~> git tag -h\n> fatal: Not a git repository\n> ~>\n> #v-\n \nThis is a nuisance, I agree.\n\nSo how about something like this patch?  This just avoids looking for\na .git directory if the only option to a subcommand is '-h'.\n\n-- %< --\nSubject: [PATCH] Let 'git <command> -h' show usage without a git dir\n\nThere is no need for \"git <command> -h\" to depend on being inside\na repository.\n\nReported by Gerfried Fuchs through http://bugs.debian.org/462557\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nTested with all builtins and non-builtins written in C.  Some commands\ndo not show usage with '-h' and have been left unchanged.\n\n git.c            |   48 ++++++++++++++++++++++++++++++------------------\n http-fetch.c     |   13 ++++++++++++-\n index-pack.c     |    5 +++++\n pack-redundant.c |    5 +++++\n 4 files changed, 52 insertions(+), 19 deletions(-)\n\ndiff --git a/git.c b/git.c\nindex bd2c5fe..bfa9518 100644\n--- a/git.c\n+++ b/git.c\n@@ -220,6 +220,11 @@ const char git_version_string[] = GIT_VERSION;\n  * RUN_SETUP for reading from the configuration file.\n  */\n #define NEED_WORK_TREE\t(1<<2)\n+/*\n+ * Let RUN_SETUP, USE_PAGER, and NEED_WORK_TREE take effect even if\n+ * passed the -h option.\n+ */\n+#define H_IS_NOT_HELP\t(1<<3)\n \n struct cmd_struct {\n \tconst char *cmd;\n@@ -229,21 +234,25 @@ struct cmd_struct {\n \n static int run_builtin(struct cmd_struct *p, int argc, const char **argv)\n {\n-\tint status;\n+\tint status, help;\n \tstruct stat st;\n \tconst char *prefix;\n \n \tprefix = NULL;\n-\tif (p->option & RUN_SETUP)\n-\t\tprefix = setup_git_directory();\n-\n-\tif (use_pager == -1 && p->option & RUN_SETUP)\n-\t\tuse_pager = check_pager_config(p->cmd);\n-\tif (use_pager == -1 && p->option & USE_PAGER)\n-\t\tuse_pager = 1;\n+\thelp = argc == 2 && !(p->option & H_IS_NOT_HELP) &&\n+\t\t!strcmp(argv[1], \"-h\");\n+\tif (!help) {\n+\t\tif (p->option & RUN_SETUP && !help)\n+\t\t\tprefix = setup_git_directory();\n+\n+\t\tif (use_pager == -1 && p->option & RUN_SETUP)\n+\t\t\tuse_pager = check_pager_config(p->cmd);\n+\t\tif (use_pager == -1 && p->option & USE_PAGER)\n+\t\t\tuse_pager = 1;\n+\t}\n \tcommit_pager_choice();\n \n-\tif (p->option & NEED_WORK_TREE)\n+\tif (!help && p->option & NEED_WORK_TREE)\n \t\tsetup_work_tree();\n \n \ttrace_argv_printf(argv, \"trace: built-in: git\");\n@@ -278,7 +287,8 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"annotate\", cmd_annotate, RUN_SETUP },\n \t\t{ \"apply\", cmd_apply },\n \t\t{ \"archive\", cmd_archive },\n-\t\t{ \"bisect--helper\", cmd_bisect__helper, RUN_SETUP | NEED_WORK_TREE },\n+\t\t{ \"bisect--helper\", cmd_bisect__helper,\n+\t\t\tRUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"blame\", cmd_blame, RUN_SETUP },\n \t\t{ \"branch\", cmd_branch, RUN_SETUP },\n \t\t{ \"bundle\", cmd_bundle },\n@@ -288,12 +298,12 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t\tRUN_SETUP | NEED_WORK_TREE},\n \t\t{ \"check-ref-format\", cmd_check_ref_format },\n \t\t{ \"check-attr\", cmd_check_attr, RUN_SETUP },\n-\t\t{ \"cherry\", cmd_cherry, RUN_SETUP },\n+\t\t{ \"cherry\", cmd_cherry, RUN_SETUP | H_IS_NOT_HELP },\n \t\t{ \"cherry-pick\", cmd_cherry_pick, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"clone\", cmd_clone },\n \t\t{ \"clean\", cmd_clean, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"commit\", cmd_commit, RUN_SETUP | NEED_WORK_TREE },\n-\t\t{ \"commit-tree\", cmd_commit_tree, RUN_SETUP },\n+\t\t{ \"commit-tree\", cmd_commit_tree, RUN_SETUP | H_IS_NOT_HELP },\n \t\t{ \"config\", cmd_config },\n \t\t{ \"count-objects\", cmd_count_objects, RUN_SETUP },\n \t\t{ \"describe\", cmd_describe, RUN_SETUP },\n@@ -304,7 +314,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"fast-export\", cmd_fast_export, RUN_SETUP },\n \t\t{ \"fetch\", cmd_fetch, RUN_SETUP },\n \t\t{ \"fetch-pack\", cmd_fetch_pack, RUN_SETUP },\n-\t\t{ \"fetch--tool\", cmd_fetch__tool, RUN_SETUP },\n+\t\t{ \"fetch--tool\", cmd_fetch__tool, RUN_SETUP | H_IS_NOT_HELP },\n \t\t{ \"fmt-merge-msg\", cmd_fmt_merge_msg, RUN_SETUP },\n \t\t{ \"for-each-ref\", cmd_for_each_ref, RUN_SETUP },\n \t\t{ \"format-patch\", cmd_format_patch, RUN_SETUP },\n@@ -312,7 +322,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"fsck-objects\", cmd_fsck, RUN_SETUP },\n \t\t{ \"gc\", cmd_gc, RUN_SETUP },\n \t\t{ \"get-tar-commit-id\", cmd_get_tar_commit_id },\n-\t\t{ \"grep\", cmd_grep, RUN_SETUP | USE_PAGER },\n+\t\t{ \"grep\", cmd_grep, RUN_SETUP | USE_PAGER | H_IS_NOT_HELP },\n \t\t{ \"help\", cmd_help },\n \t\t{ \"init\", cmd_init_db },\n \t\t{ \"init-db\", cmd_init_db },\n@@ -325,9 +335,11 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"merge\", cmd_merge, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"merge-base\", cmd_merge_base, RUN_SETUP },\n \t\t{ \"merge-file\", cmd_merge_file },\n-\t\t{ \"merge-ours\", cmd_merge_ours, RUN_SETUP },\n-\t\t{ \"merge-recursive\", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },\n-\t\t{ \"merge-subtree\", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },\n+\t\t{ \"merge-ours\", cmd_merge_ours, RUN_SETUP | H_IS_NOT_HELP },\n+\t\t{ \"merge-recursive\", cmd_merge_recursive,\n+\t\t\tRUN_SETUP | NEED_WORK_TREE | H_IS_NOT_HELP },\n+\t\t{ \"merge-subtree\", cmd_merge_recursive,\n+\t\t\tRUN_SETUP | NEED_WORK_TREE | H_IS_NOT_HELP },\n \t\t{ \"mktree\", cmd_mktree, RUN_SETUP },\n \t\t{ \"mv\", cmd_mv, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"name-rev\", cmd_name_rev, RUN_SETUP },\n@@ -368,7 +380,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"whatchanged\", cmd_whatchanged, RUN_SETUP | USE_PAGER },\n \t\t{ \"write-tree\", cmd_write_tree, RUN_SETUP },\n \t\t{ \"verify-pack\", cmd_verify_pack },\n-\t\t{ \"show-ref\", cmd_show_ref, RUN_SETUP },\n+\t\t{ \"show-ref\", cmd_show_ref, RUN_SETUP | H_IS_NOT_HELP },\n \t\t{ \"pack-refs\", cmd_pack_refs, RUN_SETUP },\n \t};\n \tint i;\ndiff --git a/http-fetch.c b/http-fetch.c\nindex e8f44ba..85f5338 100644\n--- a/http-fetch.c\n+++ b/http-fetch.c\n@@ -1,6 +1,10 @@\n #include \"cache.h\"\n+#include \"exec_cmd.h\"\n #include \"walker.h\"\n \n+static const char http_fetch_usage[] = \"git http-fetch \"\n+\t\"[-c] [-t] [-a] [-v] [--recover] [-w ref] [--stdin] commit-id url\";\n+\n int main(int argc, const char **argv)\n {\n \tconst char *prefix;\n@@ -19,6 +23,13 @@ int main(int argc, const char **argv)\n \tint get_verbosely = 0;\n \tint get_recover = 0;\n \n+\tgit_extract_argv0_path(argv[0]);\n+\n+\tif (argc == 2 && !strcmp(argv[1], \"-h\")) {\n+\t\tfprintf(stderr, \"%s\\n\", http_fetch_usage);\n+\t\treturn 0;\n+\t}\n+\n \tprefix = setup_git_directory();\n \n \tgit_config(git_default_config, NULL);\n@@ -45,7 +56,7 @@ int main(int argc, const char **argv)\n \t\targ++;\n \t}\n \tif (argc < arg + 2 - commits_on_stdin) {\n-\t\tusage(\"git http-fetch [-c] [-t] [-a] [-v] [--recover] [-w ref] [--stdin] commit-id url\");\n+\t\tusage(http_fetch_usage);\n \t\treturn 1;\n \t}\n \tif (commits_on_stdin) {\ndiff --git a/index-pack.c b/index-pack.c\nindex b4f8278..4a7d405 100644\n--- a/index-pack.c\n+++ b/index-pack.c\n@@ -882,6 +882,11 @@ int main(int argc, char **argv)\n \n \tgit_extract_argv0_path(argv[0]);\n \n+\tif (argc == 2 && !strcmp(argv[1], \"-h\")) {\n+\t\tfprintf(stderr, \"usage: %s\\n\", index_pack_usage);\n+\t\treturn 0;\n+\t}\n+\n \t/*\n \t * We wish to read the repository's config file if any, and\n \t * for that it is necessary to call setup_git_directory_gently().\ndiff --git a/pack-redundant.c b/pack-redundant.c\nindex 69a7ab2..24d59f9 100644\n--- a/pack-redundant.c\n+++ b/pack-redundant.c\n@@ -603,6 +603,11 @@ int main(int argc, char **argv)\n \n \tgit_extract_argv0_path(argv[0]);\n \n+\tif (argc == 2 && !strcmp(argv[1], \"-h\")) {\n+\t\tfprintf(stderr, \"usage: %s\\n\", pack_redundant_usage);\n+\t\treturn 0;\n+\t}\n+\n \tsetup_git_directory();\n \n \tfor (i = 1; i < argc; i++) {\n-- \n1.6.5.2\n"},{"id":"127065","messageId":"20091108072604.GA21367@progeny.tock","threadId":"21527","inReplyTo":"20091108071152.GA20741@progeny.tock","subject":"[PATCH] Show usage string for 'git http-push -h'","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-08T07:26:04Z","receivedAt":"2009-11-08T07:26:04Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"git http-push already knows how to dump usage if it is given no\noptions, but it interprets '-h' as the URL to a remote repository:\n\n$ git http-push -h\nerror: Cannot access URL -h/, return code 6\n\nDump usage on -h, instead.  Humans wanting to pass the URL -h/ to\ncurl for some reason can use 'git http-push -h/' explicitly.\nScripts expecting to access an HTTP repository at URL '-h' will\nbreak, though.\n\nCc: Tay Ray Chuan <rctay89@gmail.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nJonathan Nieder wrote:\n> Some commands\n> do not show usage with '-h' and have been left unchanged.\n\nLike this one.  Full list of non-builtin commands in C like this:\nhttp-push, fast-import, imap-send, remote-curl, show-index.\n\n http-push.c |    9 +++++++--\n 1 files changed, 7 insertions(+), 2 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex 00e83dc..2e0782a 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -13,8 +13,8 @@\n \n #include <expat.h>\n \n-static const char http_push_usage[] =\n-\"git http-push [--all] [--dry-run] [--force] [--verbose] <remote> [<head>...]\\n\";\n+static const char http_push_usage[] = \"git http-push \"\n+\"[-h] [--all] [--dry-run] [--force] [--verbose] <remote> [<head>...]\\n\";\n \n #ifndef XML_STATUS_OK\n enum XML_Status {\n@@ -1792,6 +1792,11 @@ int main(int argc, char **argv)\n \n \tgit_extract_argv0_path(argv[0]);\n \n+\tif (argc == 2 && !strcmp(argv[1], \"-h\")) {\n+\t\tfprintf(stderr, \"usage: %s\\n\", http_push_usage);\n+\t\treturn 0;\n+\t}\n+\n \tsetup_git_directory();\n \n \trepo = xcalloc(sizeof(*repo), 1);\n-- \n1.6.5.2\n"},{"id":"127067","messageId":"7vvdhlfk2y.fsf@alter.siamese.dyndns.org","threadId":"21527","inReplyTo":"20091108071152.GA20741@progeny.tock","subject":"Re: [PATCH] Let 'git <command> -h' show usage without a git dir","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-11-08T09:21:25Z","receivedAt":"2009-11-08T09:21:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> diff --git a/git.c b/git.c\n> index bd2c5fe..bfa9518 100644\n> --- a/git.c\n> +++ b/git.c\n> @@ -220,6 +220,11 @@ const char git_version_string[] = GIT_VERSION;\n>   * RUN_SETUP for reading from the configuration file.\n>   */\n>  #define NEED_WORK_TREE\t(1<<2)\n> +/*\n> + * Let RUN_SETUP, USE_PAGER, and NEED_WORK_TREE take effect even if\n> + * passed the -h option.\n> + */\n> +#define H_IS_NOT_HELP\t(1<<3)\n\nYuck.  Let's think of a way to avoid this ugliness.\n\n> @@ -278,7 +287,8 @@ static void handle_internal_command(int argc, const char **argv)\n>  \t\t{ \"annotate\", cmd_annotate, RUN_SETUP },\n>  \t\t{ \"apply\", cmd_apply },\n>  \t\t{ \"archive\", cmd_archive },\n> -\t\t{ \"bisect--helper\", cmd_bisect__helper, RUN_SETUP | NEED_WORK_TREE },\n> +\t\t{ \"bisect--helper\", cmd_bisect__helper,\n> +\t\t\tRUN_SETUP | NEED_WORK_TREE },\n\nBesides, this hunk is totally unwarranted.\n\nHere are the relevant parts (some of your H_IS_NOT_HELP are not visible\nbecause you needlessly wrapped the lines):\n\n> +\t\t{ \"cherry\", cmd_cherry, RUN_SETUP | H_IS_NOT_HELP },\n> +\t\t{ \"commit-tree\", cmd_commit_tree, RUN_SETUP | H_IS_NOT_HELP },\n> +\t\t{ \"fetch--tool\", cmd_fetch__tool, RUN_SETUP | H_IS_NOT_HELP },\n> +\t\t{ \"grep\", cmd_grep, RUN_SETUP | USE_PAGER | H_IS_NOT_HELP },\n> +\t\t{ \"merge-ours\", cmd_merge_ours, RUN_SETUP | H_IS_NOT_HELP },\n> +\t\t{ \"merge-recursive\", cmd_merge_recursive,\n> +\t\t{ \"merge-subtree\", cmd_merge_recursive,\n> +\t\t{ \"show-ref\", cmd_show_ref, RUN_SETUP | H_IS_NOT_HELP },\n\nExcept for \"grep\" and \"show-ref\", none of these have a valid -h option\nthat means something else.\n\nConsidering that this niggle is strictly about \"git cmd -h\", and not about\n\"git cmd --otheropt -h somearg\", we can even say that \"git grep -h\" is\nasking for help, and not \"do not show filenames from match\", as there is\nno pattern specified.\n\nSo I think the right approach is something like how you handled http-push;\nnamely, check if the sole argument is \"-h\", and if so show help and exit.\n\n\tClarification. the following description only talks about \"cmd -h\"\n\twithout any other options and arguments.\n\nSuch a change cannot be breaking backward compatibility for...\n\n * \"cherry -h\" could be asking to compare histories that leads to our HEAD\n   and a commit that can be named as \"-h\".  Strictly speaking, that may be\n   a valid refname, but the user would have to say something like\n   \"tags/-h\" to name such a pathological ref already, so I do not think it\n   is such a big deal.\n\n * \"commit-tree -h\" is to make a root commit that records a tree-ish\n   pointed by a tag whose name is \"-h\".  Same as above.\n\n * The first word to \"fetch--tool\" is a subcommand name, so \"fetch--tool -h\"\n   is an error and there cannot be any existing callers.  Besides, is it\n   still being used?\n\n * \"grep -h\" cannot be asking for suppressing filenames as there is no\n   match pattern specified.\n\n * \"merge-*\" strategy backends take the merge base (or \"--\") as the first\n   parameter; it cannot sanely be \"-h\". The callers are supposed to run\n   rev-parse to make it 40-hexdigit and the command won't see a refname\n   anyway.\n\nThat leaves \"show-ref -h\".  It shows all the refs/* and HEAD, as opposed\nto \"show-ref\" that shows all the refs/* and not HEAD.\n\nDoes anybody use \"show-ref -h\"?  It was in Linus's original, and I suspect\nit was done only because he thought \"it might be handy\", not because \"the\ncommand should not show the HEAD by default for such and such reasons\".\nSo I think it actually is Ok if \"show-ref -h\" (but not \"show-ref --head\")\ngave help and exit.\n"},{"id":"127069","messageId":"20091108110341.GA23737@progeny.tock","threadId":"21527","inReplyTo":"7vvdhlfk2y.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Let 'git <command> -h' show usage without a git dir","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-08T11:03:41Z","receivedAt":"2009-11-08T11:03:41Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Junio C Hamano wrote:\n> Jonathan Nieder <jrnieder@gmail.com> writes:\n> \n>> +/*\n>> + * Let RUN_SETUP, USE_PAGER, and NEED_WORK_TREE take effect even if\n>> + * passed the -h option.\n>> + */\n>> +#define H_IS_NOT_HELP\t(1<<3)\n> \n> Yuck.  Let's think of a way to avoid this ugliness.\n\nThank you. :)\n\n> So I think the right approach is something like how you handled http-push;\n> namely, check if the sole argument is \"-h\", and if so show help and exit.\n> \n> \tClarification. the following description only talks about \"cmd -h\"\n> \twithout any other options and arguments.\n> \n> Such a change cannot be breaking backward compatibility for...\n[...]\n>  * \"grep -h\" cannot be asking for suppressing filenames as there is no\n>    match pattern specified.\n\nOkay, here’s a start.\n\n-- %< --\nSubject: Show usage string for 'git grep -h'\n\nClarification: the following description only talks about \"git\ngrep -h\" without any other options and arguments.\n\nSuch a change cannot be breaking backward compatibility.  \"grep\n-h\" cannot be asking for suppressing filenames, as there is no\nmatch pattern specified.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nIs the long usage information really what is wanted here?  (I would\nthink yes, since there is no other way to get that, but sometimes all\nI want is a reminder of the non-optional arguments.)\n\nWithout something like the previous patch, the usage information is\ncaptured by a pager.  I know this is an accidental thing (not all\ncommands send their -h output through a pager), but it is very\nconvenient and mitigates the first effect somewhat.  Should\nwhatever -h always use with a pager?\n\nThe -h output is very long, and since it goes to standard error,\n\"git grep -h | head\" does not succeed in capturing the best of it.\n\nUsage errors caught in the same function die() currently.  I was going\nto switch them to usage_msg_opt(), but because of the long usage\nmessage, that would cause the error message to scroll off the\nscreen...\n\nSo I am not totally happy with this.  But it is certainly an\nimprovement over the output from before:\n\n$ git grep -h\nfatal: no pattern given.\n\nI’ll sleep on it.  Thank you for the advice.\n\nGood night,\nJonathan\n\n builtin-grep.c |    7 +++++++\n 1 files changed, 7 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-grep.c b/builtin-grep.c\nindex 1df25b0..01be9bf 100644\n--- a/builtin-grep.c\n+++ b/builtin-grep.c\n@@ -788,6 +788,13 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \t\tOPT_END()\n \t};\n \n+\t/*\n+\t * 'git grep -h', unlike 'git grep -h <pattern>', is a request\n+\t * to show usage information and exit.\n+\t */\n+\tif (argc == 2 && !strcmp(argv[1], \"-h\"))\n+\t\tusage_with_options(grep_usage, options);\n+\n \tmemset(&opt, 0, sizeof(opt));\n \topt.prefix = prefix;\n \topt.prefix_length = (prefix && *prefix) ? strlen(prefix) : 0;\n-- \n1.6.5.2\n"},{"id":"127131","messageId":"be6fef0d0911090052s158ac720ha1fac70da748106d@mail.gmail.com","threadId":"21527","inReplyTo":"20091108072604.GA21367@progeny.tock","subject":"Re: [PATCH] Show usage string for 'git http-push -h'","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2009-11-09T08:52:48Z","receivedAt":"2009-11-09T08:52:48Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi,\n\nOn Sun, Nov 8, 2009 at 3:26 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> @@ -1792,6 +1792,11 @@ int main(int argc, char **argv)\n>\n>        git_extract_argv0_path(argv[0]);\n>\n> +       if (argc == 2 && !strcmp(argv[1], \"-h\")) {\n> +               fprintf(stderr, \"usage: %s\\n\", http_push_usage);\n> +               return 0;\n> +       }\n> +\n>        setup_git_directory();\n>\n>        repo = xcalloc(sizeof(*repo), 1);\n\njust curious, I'm wondering why isn't the check for \"-h\" done in the\nargv loop later on? I see this being done already in the builtins\ndiff, log, ls-remote and update-index.\n\nAlso, unlike grep, -h <arg> is not an option we're looking out for, so\nI'm not sure if we should allow the user to mix -h with a valid set of\narguments (which is what Johnathan's patch would allow).\n\n-- \nCheers,\nRay Chuan\n"},{"id":"127133","messageId":"20091109104732.GA15519@progeny.tock","threadId":"21527","inReplyTo":"be6fef0d0911090052s158ac720ha1fac70da748106d@mail.gmail.com","subject":"[PATCH v2] Show usage string for 'git http-push -h'","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T10:47:34Z","receivedAt":"2009-11-09T10:47:34Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"http-push already knows how to dump usage if it is given no\noptions, but it interprets '-h' as the URL to a remote\nrepository:\n\n$ git http-push -h\nerror: Cannot access URL -h/, return code 6\n\nDump usage instead.  Humans wanting to pass the URL -h/ to curl\nfor some reason can use 'git http-push -h/' explicitly.  Scripts\nexpecting to access an HTTP repository at URL '-h' will break,\nthough.\n\nAlso delay finding a git directory until after option parsing, so\n\"http-push -h\" can be used outside any git repository.\n\nCc: Tay Ray Chuan <rctay89@gmail.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nTay Ray Chuan wrote:\n\n> just curious, I'm wondering why isn't the check for \"-h\" done in the\n> argv loop later on? I see this being done already in the builtins\n> diff, log, ls-remote and update-index.\n\nGood question. :)\n\n(I was making sure \"git http-push -h\" would work without a git\ndirectory by putting the check for -h before setup_git_directory().\nBut nothing in the argv loop requires a git repository, so it is\nbetter and simpler to move the setup_git_directory() call to after the\nloop.  Thanks for the catch.)\n\n> Also, unlike grep, -h <arg> is not an option we're looking out for, so\n> I'm not sure if we should allow the user to mix -h with a valid set of\n> arguments (which is what Johnathan's patch would allow).\n\nMakes sense.\n\n http-push.c |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex 00e83dc..ad1a6c9 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1792,8 +1792,6 @@ int main(int argc, char **argv)\n \n \tgit_extract_argv0_path(argv[0]);\n \n-\tsetup_git_directory();\n-\n \trepo = xcalloc(sizeof(*repo), 1);\n \n \targv++;\n@@ -1827,6 +1825,8 @@ int main(int argc, char **argv)\n \t\t\t\tforce_delete = 1;\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!strcmp(arg, \"-h\"))\n+\t\t\t\tusage(http_push_usage);\n \t\t}\n \t\tif (!repo->url) {\n \t\t\tchar *path = strstr(arg, \"//\");\n@@ -1854,6 +1854,8 @@ int main(int argc, char **argv)\n \tif (delete_branch && nr_refspec != 1)\n \t\tdie(\"You must specify only one branch name when deleting a remote branch\");\n \n+\tsetup_git_directory();\n+\n \tmemset(remote_dir_exists, -1, 256);\n \n \t/*\n-- \n1.6.5.2\n"},{"id":"127138","messageId":"be6fef0d0911090556u77dbc1fah458e6a8b37ffa2cb@mail.gmail.com","threadId":"21527","inReplyTo":"20091109104732.GA15519@progeny.tock","subject":"Re: [PATCH v2] Show usage string for 'git http-push -h'","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2009-11-09T13:56:51Z","receivedAt":"2009-11-09T13:56:51Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi,\n\nOn Mon, Nov 9, 2009 at 6:47 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> (I was making sure \"git http-push -h\" would work without a git\n> directory by putting the check for -h before setup_git_directory().\n> But nothing in the argv loop requires a git repository, so it is\n> better and simpler to move the setup_git_directory() call to after the\n> loop.  Thanks for the catch.)\n\nActually, I didn't notice the removal of the \"is in a git directory\nfor -h\" requirement; I was only looking at the argument mix.\n\nThanks.\n\nAcked-by: Tay Ray Chuan <rctay89@gmail.com>\n\n-- \nCheers,\nRay Chuan\n"},{"id":"127140","messageId":"20091109150235.GA23871@progeny.tock","threadId":"21527","inReplyTo":"20091108110341.GA23737@progeny.tock","subject":"[PATCH 00/24] Let 'git <command> -h' show usage without a git dir","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:02:35Z","receivedAt":"2009-11-09T15:02:35Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Junio C Hamano wrote:\n\n> So I think the right approach is something like how you handled http-push;\n> namely, check if the sole argument is \"-h\", and if so show help and exit.\n\nI took a more aggressive approach with some commands.  As long as it\nwas obviously safe and not too complicated to implement, I let -h work\nwherever other options work.\n\nTested with\n\ngit_home=$(pwd)\nwhile read a b\ndo\n\tcmd=${a#git-}\n\ttest \"$cmd\" = \"$a\" && continue\n\techo \"$cmd\"\n\t( cd /tmp && \"$git_home/git\" \"$cmd\" -h 2>&1 | head -1 )\ndone |\nless\n\nand the test suite.\n\nThoughts?\n\nJonathan Nieder (24):\n  Retire fetch--tool helper to contrib/examples\n  Show usage string for 'git grep -h'\n  Show usage string for 'git cherry -h'\n  Show usage string for 'git commit-tree -h'\n  Show usage string for 'git merge-ours -h'\n  Show usage string for 'git show-ref -h'\n  check-ref-format: update usage string\n  Show usage string for 'git check-ref-format -h'\n  Show usage string for 'git fast-import -h'\n  Show usage string for 'git get-tar-commit-id -h'\n  Show usage string for 'git imap-send -h'\n  Show usage string for 'git mailsplit -h'\n  Show usage string for 'git merge-one-file -h'\n  Show usage string for 'git rev-parse -h'\n  Show usage string for 'git show-index -h'\n  Show usage string for 'git unpack-file -h'\n  Show usage string for 'git stripspace -h'\n  merge: do not setup worktree twice\n  Let 'git http-fetch -h' show usage outside any git repository\n  http-fetch: add missing initialization of argv0_path\n  Let 'git <command> -h' show usage without a git dir\n  Let usage() take a printf-style format\n  merge-{recursive,subtree}: use usage() to print usage\n  diff --no-index: make the usage string less scary\n\n Documentation/git-show-ref.txt                     |    3 +-\n Makefile                                           |    1 -\n builtin-check-ref-format.c                         |    9 +++++++-\n builtin-commit-tree.c                              |    2 +-\n builtin-grep.c                                     |    7 ++++++\n builtin-log.c                                      |    9 ++++++++\n builtin-mailsplit.c                                |    2 +\n builtin-merge-ours.c                               |    6 +++++\n builtin-merge-recursive.c                          |    2 +-\n builtin-merge.c                                    |    1 -\n builtin-mv.c                                       |    8 +++---\n builtin-read-tree.c                                |    4 +-\n builtin-reflog.c                                   |    3 ++\n builtin-rerere.c                                   |    3 ++\n builtin-rev-parse.c                                |   10 +++++++++\n builtin-show-ref.c                                 |   10 +++++++-\n builtin-stripspace.c                               |    4 ++-\n builtin-tar-tree.c                                 |    6 +++++\n builtin.h                                          |    1 -\n .../examples/builtin-fetch--tool.c                 |    0\n diff-no-index.c                                    |    2 +-\n fast-import.c                                      |    3 ++\n git-compat-util.h                                  |    2 +-\n git-merge-one-file.sh                              |   12 ++++++++++\n git.c                                              |   22 ++++++++++---------\n http-fetch.c                                       |   21 ++++++++++++------\n imap-send.c                                        |    5 ++++\n index-pack.c                                       |    3 ++\n pack-redundant.c                                   |    3 ++\n show-index.c                                       |    5 ++++\n unpack-file.c                                      |    2 +-\n usage.c                                            |   14 ++++++++----\n 32 files changed, 143 insertions(+), 42 deletions(-)\n rename builtin-fetch--tool.c => contrib/examples/builtin-fetch--tool.c (100%)\n"},{"id":"127141","messageId":"1257779104-23884-1-git-send-email-jrnieder@gmail.com","threadId":"21527","inReplyTo":"20091109150235.GA23871@progeny.tock","subject":"[PATCH 01/24] Retire fetch--tool helper to contrib/examples","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:04:41Z","receivedAt":"2009-11-09T15:04:41Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"When git-fetch was builtin-ized, the previous script was moved to\ncontrib/examples.  Now, it is the sole remaining user for\n'git fetch--tool'.\n\nThe fetch--tool code is still worth keeping around so people can\ntry out the old git-fetch.sh, for example when investigating\nregressions from the builtinifaction.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nSee also <http://thread.gmane.org/gmane.comp.version-control.git/65122/focus=65191>.\n\n Makefile                                           |    1 -\n builtin.h                                          |    1 -\n .../examples/builtin-fetch--tool.c                 |    0\n git.c                                              |    1 -\n 4 files changed, 0 insertions(+), 3 deletions(-)\n rename builtin-fetch--tool.c => contrib/examples/builtin-fetch--tool.c (100%)\n\ndiff --git a/Makefile b/Makefile\nindex 5d5976f..c0ba479 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -601,7 +601,6 @@ BUILTIN_OBJS += builtin-diff-index.o\n BUILTIN_OBJS += builtin-diff-tree.o\n BUILTIN_OBJS += builtin-diff.o\n BUILTIN_OBJS += builtin-fast-export.o\n-BUILTIN_OBJS += builtin-fetch--tool.o\n BUILTIN_OBJS += builtin-fetch-pack.o\n BUILTIN_OBJS += builtin-fetch.o\n BUILTIN_OBJS += builtin-fmt-merge-msg.o\ndiff --git a/builtin.h b/builtin.h\nindex a2174dc..c3f83c0 100644\n--- a/builtin.h\n+++ b/builtin.h\n@@ -48,7 +48,6 @@ extern int cmd_diff_tree(int argc, const char **argv, const char *prefix);\n extern int cmd_fast_export(int argc, const char **argv, const char *prefix);\n extern int cmd_fetch(int argc, const char **argv, const char *prefix);\n extern int cmd_fetch_pack(int argc, const char **argv, const char *prefix);\n-extern int cmd_fetch__tool(int argc, const char **argv, const char *prefix);\n extern int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix);\n extern int cmd_for_each_ref(int argc, const char **argv, const char *prefix);\n extern int cmd_format_patch(int argc, const char **argv, const char *prefix);\ndiff --git a/builtin-fetch--tool.c b/contrib/examples/builtin-fetch--tool.c\nsimilarity index 100%\nrename from builtin-fetch--tool.c\nrename to contrib/examples/builtin-fetch--tool.c\ndiff --git a/git.c b/git.c\nindex bd2c5fe..f295561 100644\n--- a/git.c\n+++ b/git.c\n@@ -304,7 +304,6 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"fast-export\", cmd_fast_export, RUN_SETUP },\n \t\t{ \"fetch\", cmd_fetch, RUN_SETUP },\n \t\t{ \"fetch-pack\", cmd_fetch_pack, RUN_SETUP },\n-\t\t{ \"fetch--tool\", cmd_fetch__tool, RUN_SETUP },\n \t\t{ \"fmt-merge-msg\", cmd_fmt_merge_msg, RUN_SETUP },\n \t\t{ \"for-each-ref\", cmd_for_each_ref, RUN_SETUP },\n \t\t{ \"format-patch\", cmd_format_patch, RUN_SETUP },\n-- \n1.6.5.2\n"},{"id":"127142","messageId":"1257779104-23884-2-git-send-email-jrnieder@gmail.com","threadId":"21527","inReplyTo":"20091109150235.GA23871@progeny.tock","subject":"[PATCH 02/24] Show usage string for 'git grep -h'","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:04:42Z","receivedAt":"2009-11-09T15:04:42Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Clarification: the following description only talks about \"git\ngrep -h\" without any other options and arguments.\n\nSuch a change cannot be breaking backward compatibility.  \"grep\n-h\" cannot be asking for suppressing filenames, as there is no\nmatch pattern specified.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin-grep.c |    7 +++++++\n 1 files changed, 7 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-grep.c b/builtin-grep.c\nindex 1df25b0..01be9bf 100644\n--- a/builtin-grep.c\n+++ b/builtin-grep.c\n@@ -788,6 +788,13 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \t\tOPT_END()\n \t};\n \n+\t/*\n+\t * 'git grep -h', unlike 'git grep -h <pattern>', is a request\n+\t * to show usage information and exit.\n+\t */\n+\tif (argc == 2 && !strcmp(argv[1], \"-h\"))\n+\t\tusage_with_options(grep_usage, options);\n+\n \tmemset(&opt, 0, sizeof(opt));\n \topt.prefix = prefix;\n \topt.prefix_length = (prefix && *prefix) ? strlen(prefix) : 0;\n-- \n1.6.5.2\n"},{"id":"127161","messageId":"1257779104-23884-3-git-send-email-jrnieder@gmail.com","threadId":"21527","inReplyTo":"20091109150235.GA23871@progeny.tock","subject":"[PATCH 03/24] Show usage string for 'git cherry -h'","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:04:43Z","receivedAt":"2009-11-09T15:04:43Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Treat an \"-h\" option as a request for help, rather than an\n\"Unknown commit -h\" error.\n\n\"cherry -h\" could be asking to compare histories that leads to\nour HEAD and a commit that can be named as \"-h\".  Strictly\nspeaking, that may be a valid refname, but the user would have to\nsay something like \"tags/-h\" to name such a pathological ref\nalready, so it is not such a big deal.\n\nThe \"-h\" option keeps its meaning even if preceded by other\noptions or followed by other arguments.  This keeps the\ncommand-line syntax closer to what parse_options would give and\nsupports shell aliases like 'alias cherry=\"git cherry -v\"' a\nlittle better.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n builtin-log.c |    3 +++\n 1 files changed, 3 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-log.c b/builtin-log.c\nindex 207a361..5248507 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -1237,6 +1237,9 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)\n \t\targv++;\n \t}\n \n+\tif (argc > 1 && !strcmp(argv[1], \"-h\"))\n+\t\tusage(cherry_usage);\n+\n \tswitch (argc) {\n \tcase 4:\n \t\tlimit = argv[3];\n-- \n1.6.5.2\n"},{"id":"127145","messageId":"1257779104-23884-4-git-send-email-jrnieder@gmail.com","threadId":"21527","inReplyTo":"20091109150235.GA23871@progeny.tock","subject":"[PATCH 04/24] Show usage string for 'git commit-tree -h'","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:04:44Z","receivedAt":"2009-11-09T15:04:44Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Treat an \"-h\" option as a request for help, rather than a \"Not a\nvalid object name\" error.\n\n\"commit-tree -h\" could be asking to create a new commit from a\ntreeish named \"-h\".  Strictly speaking, such a pathological ref\nname is possible, but the user would have to had said something\nlike \"tags/-h\" to name such a pathological already.  commit-tree\nis usually used in scripts with raw object ids, anyway.\n\nFor consistency, the \"-h\" option uses its new meaning even if\nfollowed by other arguments.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n builtin-commit-tree.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-commit-tree.c b/builtin-commit-tree.c\nindex 6467077..ddcb7a4 100644\n--- a/builtin-commit-tree.c\n+++ b/builtin-commit-tree.c\n@@ -105,7 +105,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)\n \n \tgit_config(git_default_config, NULL);\n \n-\tif (argc < 2)\n+\tif (argc < 2 || !strcmp(argv[1], \"-h\"))\n \t\tusage(commit_tree_usage);\n \tif (get_sha1(argv[1], tree_sha1))\n \t\tdie(\"Not a valid object name %s\", argv[1]);\n-- \n1.6.5.2\n"},{"id":"127144","messageId":"1257779104-23884-5-git-send-email-jrnieder@gmail.com","threadId":"21527","inReplyTo":"20091109150235.GA23871@progeny.tock","subject":"[PATCH 05/24] Show usage string for 'git merge-ours -h'","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:04:45Z","receivedAt":"2009-11-09T15:04:45Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"This change is strictly about 'git merge-ours -h' without\nany other options and arguments.\n\nThis change cannot break compatibility since merge drivers are\nalways passed '--', among other arguments.\n\nAny usage string for this command is a lie, since it ignored its\narguments until now.  Still, it makes sense to let the user know\nthe expected usage when asked.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n builtin-merge-ours.c |    6 ++++++\n 1 files changed, 6 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-merge-ours.c b/builtin-merge-ours.c\nindex 8f5bbaf..6844116 100644\n--- a/builtin-merge-ours.c\n+++ b/builtin-merge-ours.c\n@@ -10,6 +10,9 @@\n #include \"git-compat-util.h\"\n #include \"builtin.h\"\n \n+static const char builtin_merge_ours_usage[] =\n+\t\"git merge-ours <base>... -- HEAD <remote>...\";\n+\n static const char *diff_index_args[] = {\n \t\"diff-index\", \"--quiet\", \"--cached\", \"HEAD\", \"--\", NULL\n };\n@@ -17,6 +20,9 @@ static const char *diff_index_args[] = {\n \n int cmd_merge_ours(int argc, const char **argv, const char *prefix)\n {\n+\tif (argc == 2 && !strcmp(argv[1], \"-h\"))\n+\t\tusage(builtin_merge_ours_usage);\n+\n \t/*\n \t * We need to exit with 2 if the index does not match our HEAD tree,\n \t * because the current index is what we will be committing as the\n-- \n1.6.5.2\n"},{"id":"127163","messageId":"1257779104-23884-6-git-send-email-jrnieder@gmail.com","threadId":"21527","inReplyTo":"20091109150235.GA23871@progeny.tock","subject":"[PATCH/RFC 06/24] Show usage string for 'git show-ref -h'","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:04:46Z","receivedAt":"2009-11-09T15:04:46Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"This only changes the behavior of \"git show-ref -h\" without any\nother options and arguments.\n\n\"show-ref -h\" currently is short for \"show-ref --head\", which\nshows all the refs/* and HEAD, as opposed to \"show-ref\" that\nshows all the refs/* and not HEAD.\n\nDoes anybody use \"show-ref -h\"?  It was in Linus's original, most\nlikely only because \"it might be handy\", not because \"the command\nshould not show the HEAD by default for such and such reasons\".\nSo I think it is okay if \"show-ref -h\" (but not \"show-ref\n--head\") gives help and exits.\n\nIf a current script uses \"git show-ref -h\" without any other\narguments, it would have to be adapted by changing \"-h\" to\n\"--head\".\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n Documentation/git-show-ref.txt |    3 +--\n builtin-show-ref.c             |   10 ++++++++--\n 2 files changed, 9 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-show-ref.txt b/Documentation/git-show-ref.txt\nindex f4429bd..70f400b 100644\n--- a/Documentation/git-show-ref.txt\n+++ b/Documentation/git-show-ref.txt\n@@ -8,7 +8,7 @@ git-show-ref - List references in a local repository\n SYNOPSIS\n --------\n [verse]\n-'git show-ref' [-q|--quiet] [--verify] [-h|--head] [-d|--dereference]\n+'git show-ref' [-q|--quiet] [--verify] [--head] [-d|--dereference]\n \t     [-s|--hash[=<n>]] [--abbrev[=<n>]] [--tags]\n \t     [--heads] [--] <pattern>...\n 'git show-ref' --exclude-existing[=<pattern>] < ref-list\n@@ -30,7 +30,6 @@ the `.git` directory.\n OPTIONS\n -------\n \n--h::\n --head::\n \n \tShow the HEAD reference.\ndiff --git a/builtin-show-ref.c b/builtin-show-ref.c\nindex c46550c..17ada88 100644\n--- a/builtin-show-ref.c\n+++ b/builtin-show-ref.c\n@@ -7,7 +7,7 @@\n #include \"parse-options.h\"\n \n static const char * const show_ref_usage[] = {\n-\t\"git show-ref [-q|--quiet] [--verify] [-h|--head] [-d|--dereference] [-s|--hash[=<n>]] [--abbrev[=<n>]] [--tags] [--heads] [--] [pattern*] \",\n+\t\"git show-ref [-q|--quiet] [--verify] [--head] [-d|--dereference] [-s|--hash[=<n>]] [--abbrev[=<n>]] [--tags] [--heads] [--] [pattern*] \",\n \t\"git show-ref --exclude-existing[=pattern] < ref-list\",\n \tNULL\n };\n@@ -183,7 +183,10 @@ static const struct option show_ref_options[] = {\n \tOPT_BOOLEAN(0, \"heads\", &heads_only, \"only show heads (can be combined with tags)\"),\n \tOPT_BOOLEAN(0, \"verify\", &verify, \"stricter reference checking, \"\n \t\t    \"requires exact ref path\"),\n-\tOPT_BOOLEAN('h', \"head\", &show_head, \"show the HEAD reference\"),\n+\t{ OPTION_BOOLEAN, 'h', NULL, &show_head, NULL,\n+\t  \"show the HEAD reference\",\n+\t  PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },\n+\tOPT_BOOLEAN(0, \"head\", &show_head, \"show the HEAD reference\"),\n \tOPT_BOOLEAN('d', \"dereference\", &deref_tags,\n \t\t    \"dereference tags into object IDs\"),\n \t{ OPTION_CALLBACK, 's', \"hash\", &abbrev, \"n\",\n@@ -201,6 +204,9 @@ static const struct option show_ref_options[] = {\n \n int cmd_show_ref(int argc, const char **argv, const char *prefix)\n {\n+\tif (argc == 2 && !strcmp(argv[1], \"-h\"))\n+\t\tusage_with_options(show_ref_usage, show_ref_options);\n+\n \targc = parse_options(argc, argv, prefix, show_ref_options,\n \t\t\t     show_ref_usage, PARSE_OPT_NO_INTERNAL_HELP);\n \n-- \n1.6.5.2\n"},{"id":"127160","messageId":"1257779104-23884-7-git-send-email-jrnieder@gmail.com","threadId":"21527","inReplyTo":"20091109150235.GA23871@progeny.tock","subject":"[PATCH 07/24] check-ref-format: update usage string","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:04:47Z","receivedAt":"2009-11-09T15:04:47Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"'git check-ref-format' has learned --branch and --print options\nsince the usage string was last updated.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n builtin-check-ref-format.c |    6 +++++-\n 1 files changed, 5 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-check-ref-format.c b/builtin-check-ref-format.c\nindex e3e7bdf..513f134 100644\n--- a/builtin-check-ref-format.c\n+++ b/builtin-check-ref-format.c\n@@ -7,6 +7,10 @@\n #include \"builtin.h\"\n #include \"strbuf.h\"\n \n+static const char builtin_check_ref_format_usage[] =\n+\"git check-ref-format [--print] <refname>\\n\"\n+\"   or: git check-ref-format --branch <branchname-shorthand>\";\n+\n /*\n  * Replace each run of adjacent slashes in src with a single slash,\n  * and write the result to dst.\n@@ -49,6 +53,6 @@ int cmd_check_ref_format(int argc, const char **argv, const char *prefix)\n \t\texit(0);\n \t}\n \tif (argc != 2)\n-\t\tusage(\"git check-ref-format refname\");\n+\t\tusage(builtin_check_ref_format_usage);\n \treturn !!check_ref_format(argv[1]);\n }\n-- \n1.6.5.2\n"},{"id":"127162","messageId":"1257779104-23884-8-git-send-email-jrnieder@gmail.com","threadId":"21527","inReplyTo":"20091109150235.GA23871@progeny.tock","subject":"[PATCH 08/24] Show usage string for 'git check-ref-format -h'","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:04:48Z","receivedAt":"2009-11-09T15:04:48Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"This only changes the behavior of \"git check-ref-format -h\"\nwithout any other options and arguments.\n\nThis change cannot be breaking backward compatibility, since any\nvalid refname must contain a /.   Most existing scripts use\narguments such as \"heads/$foo\".  If some script checks the\nrefname \"-h\" alone, git check-ref-format will still exit with\nnonzero status, and the only detrimental side-effect will be a\nusage string sent to stderr.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n builtin-check-ref-format.c |    3 +++\n 1 files changed, 3 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-check-ref-format.c b/builtin-check-ref-format.c\nindex 513f134..b106c65 100644\n--- a/builtin-check-ref-format.c\n+++ b/builtin-check-ref-format.c\n@@ -35,6 +35,9 @@ static void collapse_slashes(char *dst, const char *src)\n \n int cmd_check_ref_format(int argc, const char **argv, const char *prefix)\n {\n+\tif (argc == 2 && !strcmp(argv[1], \"-h\"))\n+\t\tusage(builtin_check_ref_format_usage);\n+\n \tif (argc == 3 && !strcmp(argv[1], \"--branch\")) {\n \t\tstruct strbuf sb = STRBUF_INIT;\n \n-- \n1.6.5.2\n"},{"id":"127143","messageId":"1257779104-23884-9-git-send-email-jrnieder@gmail.com","threadId":"21527","inReplyTo":"20091109150235.GA23871@progeny.tock","subject":"[PATCH 09/24] Show usage string for 'git fast-import -h'","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:04:49Z","receivedAt":"2009-11-09T15:04:49Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Let \"git fast-import -h\" (with no other arguments) print usage\nbefore exiting, even when run outside any repository.\n\nCc: Shawn O. Pearce <spearce@spearce.org>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n fast-import.c |    3 +++\n 1 files changed, 3 insertions(+), 0 deletions(-)\n\ndiff --git a/fast-import.c b/fast-import.c\nindex 6faaaac..f4f1de6 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -2405,6 +2405,9 @@ int main(int argc, const char **argv)\n \n \tgit_extract_argv0_path(argv[0]);\n \n+\tif (argc == 2 && !strcmp(argv[1], \"-h\"))\n+\t\tusage(fast_import_usage);\n+\n \tsetup_git_directory();\n \tgit_config(git_pack_config, NULL);\n \tif (!pack_compression_seen && core_compression_seen)\n-- \n1.6.5.2\n"},{"id":"127146","messageId":"1257779104-23884-10-git-send-email-jrnieder@gmail.com","threadId":"21527","inReplyTo":"20091109150235.GA23871@progeny.tock","subject":"[PATCH 10/24] Show usage string for 'git get-tar-commit-id -h'","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:04:50Z","receivedAt":"2009-11-09T15:04:50Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n builtin-tar-tree.c |    6 ++++++\n 1 files changed, 6 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-tar-tree.c b/builtin-tar-tree.c\nindex 8b3a35e..3f1e701 100644\n--- a/builtin-tar-tree.c\n+++ b/builtin-tar-tree.c\n@@ -11,6 +11,9 @@ static const char tar_tree_usage[] =\n \"git tar-tree [--remote=<repo>] <tree-ish> [basedir]\\n\"\n \"*** Note that this command is now deprecated; use \\\"git archive\\\" instead.\";\n \n+static const char builtin_get_tar_commit_id_usage[] =\n+\"git get-tar-commit-id < <tarfile>\";\n+\n int cmd_tar_tree(int argc, const char **argv, const char *prefix)\n {\n \t/*\n@@ -81,6 +84,9 @@ int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix)\n \tchar *content = buffer + RECORDSIZE;\n \tssize_t n;\n \n+\tif (argc != 1)\n+\t\tusage(builtin_get_tar_commit_id_usage);\n+\n \tn = read_in_full(0, buffer, HEADERSIZE);\n \tif (n < HEADERSIZE)\n \t\tdie(\"git get-tar-commit-id: read error\");\n-- \n1.6.5.2\n"},{"id":"127148","messageId":"1257779104-23884-11-git-send-email-jrnieder@gmail.com","threadId":"21527","inReplyTo":"20091109150235.GA23871@progeny.tock","subject":"[PATCH 11/24] Show usage string for 'git imap-send -h'","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:04:51Z","receivedAt":"2009-11-09T15:04:51Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n imap-send.c |    5 +++++\n 1 files changed, 5 insertions(+), 0 deletions(-)\n\ndiff --git a/imap-send.c b/imap-send.c\nindex 3847fd1..04e5374 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -93,6 +93,8 @@ struct msg_data {\n \tunsigned int crlf:1;\n };\n \n+static const char imap_send_usage[] = \"git imap-send < <mbox>\";\n+\n #define DRV_OK          0\n #define DRV_MSG_BAD     -1\n #define DRV_BOX_BAD     -2\n@@ -1491,6 +1493,9 @@ int main(int argc, char **argv)\n \n \tgit_extract_argv0_path(argv[0]);\n \n+\tif (argc != 1)\n+\t\tusage(imap_send_usage);\n+\n \t/* init the random number generator */\n \tarc4_init();\n \n-- \n1.6.5.2\n"},{"id":"127151","messageId":"1257779104-23884-12-git-send-email-jrnieder@gmail.com","threadId":"21527","inReplyTo":"20091109150235.GA23871@progeny.tock","subject":"[PATCH 12/24] Show usage string for 'git mailsplit -h'","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:04:52Z","receivedAt":"2009-11-09T15:04:52Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n builtin-mailsplit.c |    2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-mailsplit.c b/builtin-mailsplit.c\nindex dfe5b15..207e358 100644\n--- a/builtin-mailsplit.c\n+++ b/builtin-mailsplit.c\n@@ -231,6 +231,8 @@ int cmd_mailsplit(int argc, const char **argv, const char *prefix)\n \t\t\tcontinue;\n \t\t} else if ( arg[1] == 'f' ) {\n \t\t\tnr = strtol(arg+2, NULL, 10);\n+\t\t} else if ( arg[1] == 'h' ) {\n+\t\t\tusage(git_mailsplit_usage);\n \t\t} else if ( arg[1] == 'b' && !arg[2] ) {\n \t\t\tallow_bare = 1;\n \t\t} else if (!strcmp(arg, \"--keep-cr\")) {\n-- \n1.6.5.2\n"},{"id":"127147","messageId":"1257779104-23884-13-git-send-email-jrnieder@gmail.com","threadId":"21527","inReplyTo":"20091109150235.GA23871@progeny.tock","subject":"[PATCH 13/24] Show usage string for 'git merge-one-file -h'","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:04:53Z","receivedAt":"2009-11-09T15:04:53Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n git-merge-one-file.sh |   12 ++++++++++++\n 1 files changed, 12 insertions(+), 0 deletions(-)\n\ndiff --git a/git-merge-one-file.sh b/git-merge-one-file.sh\nindex 9c2c1b7..d067894 100755\n--- a/git-merge-one-file.sh\n+++ b/git-merge-one-file.sh\n@@ -16,6 +16,18 @@\n # been handled already by git read-tree, but that one doesn't\n # do any merges that might change the tree layout.\n \n+USAGE='<orig blob> <our blob> <their blob> <path>'\n+USAGE=\"$USAGE <orig mode> <our mode> <their mode>\"\n+LONG_USAGE=\"Usage: git merge-one-file $USAGE\n+\n+Blob ids and modes should be empty for missing files.\"\n+\n+if ! test \"$#\" -eq 7\n+then\n+\techo \"$LONG_USAGE\"\n+\texit 1\n+fi\n+\n case \"${1:-.}${2:-.}${3:-.}\" in\n #\n # Deleted in both or deleted in one and unchanged in the other\n-- \n1.6.5.2\n"},{"id":"127153","messageId":"1257779104-23884-14-git-send-email-jrnieder@gmail.com","threadId":"21527","inReplyTo":"20091109150235.GA23871@progeny.tock","subject":"[PATCH 14/24] Show usage string for 'git rev-parse -h'","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:04:54Z","receivedAt":"2009-11-09T15:04:54Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n builtin-rev-parse.c |   10 ++++++++++\n 1 files changed, 10 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-rev-parse.c b/builtin-rev-parse.c\nindex 45bead6..24ee8b3 100644\n--- a/builtin-rev-parse.c\n+++ b/builtin-rev-parse.c\n@@ -426,6 +426,13 @@ static void die_no_single_rev(int quiet)\n \t\tdie(\"Needed a single revision\");\n }\n \n+static const char builtin_rev_parse_usage[] =\n+\"git rev-parse --parseopt [options] -- [<args>...]\\n\"\n+\"   or: git rev-parse --sq-quote [<arg>...]\\n\"\n+\"   or: git rev-parse [options] [<arg>...]\\n\"\n+\"\\n\"\n+\"Run \\\"git rev-parse --parseopt -h\\\" for more information on the first usage.\";\n+\n int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n {\n \tint i, as_is = 0, verify = 0, quiet = 0, revs_count = 0, type = 0;\n@@ -438,6 +445,9 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \tif (argc > 1 && !strcmp(\"--sq-quote\", argv[1]))\n \t\treturn cmd_sq_quote(argc - 2, argv + 2);\n \n+\tif (argc > 1 && !strcmp(\"-h\", argv[1]))\n+\t\tusage(builtin_rev_parse_usage);\n+\n \tprefix = setup_git_directory();\n \tgit_config(git_default_config, NULL);\n \tfor (i = 1; i < argc; i++) {\n-- \n1.6.5.2\n"},{"id":"127152","messageId":"1257779104-23884-15-git-send-email-jrnieder@gmail.com","threadId":"21527","inReplyTo":"20091109150235.GA23871@progeny.tock","subject":"[PATCH 15/24] Show usage string for 'git show-index -h'","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:04:55Z","receivedAt":"2009-11-09T15:04:55Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n show-index.c |    5 +++++\n 1 files changed, 5 insertions(+), 0 deletions(-)\n\ndiff --git a/show-index.c b/show-index.c\nindex 45bb535..63f9da5 100644\n--- a/show-index.c\n+++ b/show-index.c\n@@ -1,6 +1,9 @@\n #include \"cache.h\"\n #include \"pack.h\"\n \n+static const char show_index_usage[] =\n+\"git show-index < <packed archive index>\";\n+\n int main(int argc, char **argv)\n {\n \tint i;\n@@ -8,6 +11,8 @@ int main(int argc, char **argv)\n \tunsigned int version;\n \tstatic unsigned int top_index[256];\n \n+\tif (argc != 1)\n+\t\tusage(show_index_usage);\n \tif (fread(top_index, 2 * 4, 1, stdin) != 1)\n \t\tdie(\"unable to read header\");\n \tif (top_index[0] == htonl(PACK_IDX_SIGNATURE)) {\n-- \n1.6.5.2\n"},{"id":"127150","messageId":"1257779104-23884-16-git-send-email-jrnieder@gmail.com","threadId":"21527","inReplyTo":"20091109150235.GA23871@progeny.tock","subject":"[PATCH 16/24] Show usage string for 'git unpack-file -h'","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:04:56Z","receivedAt":"2009-11-09T15:04:56Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"\"unpack-file -h\" could be asking to save the contents of a blob\nnamed \"-h\".  Strictly speaking, such a pathological ref name is\npossible, but the user would have to had said something like\n\"tags/-h\" to name such a pathological ref already.  When used in\nscripts, unpack-file is typically not passed a user-supplied tag\nname directly.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n unpack-file.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/unpack-file.c b/unpack-file.c\nindex ac9cbf7..e9d8934 100644\n--- a/unpack-file.c\n+++ b/unpack-file.c\n@@ -28,7 +28,7 @@ int main(int argc, char **argv)\n \n \tgit_extract_argv0_path(argv[0]);\n \n-\tif (argc != 2)\n+\tif (argc != 2 || !strcmp(argv[1], \"-h\"))\n \t\tusage(\"git unpack-file <sha1>\");\n \tif (get_sha1(argv[1], sha1))\n \t\tdie(\"Not a valid object name %s\", argv[1]);\n-- \n1.6.5.2\n"},{"id":"127164","messageId":"1257779104-23884-17-git-send-email-jrnieder@gmail.com","threadId":"21527","inReplyTo":"20091109150235.GA23871@progeny.tock","subject":"[PATCH 17/24] Show usage string for 'git stripspace -h'","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:04:57Z","receivedAt":"2009-11-09T15:04:57Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n builtin-stripspace.c |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-stripspace.c b/builtin-stripspace.c\nindex 1fd2205..4d3b93f 100644\n--- a/builtin-stripspace.c\n+++ b/builtin-stripspace.c\n@@ -73,9 +73,11 @@ int cmd_stripspace(int argc, const char **argv, const char *prefix)\n \tstruct strbuf buf = STRBUF_INIT;\n \tint strip_comments = 0;\n \n-\tif (argc > 1 && (!strcmp(argv[1], \"-s\") ||\n+\tif (argc == 2 && (!strcmp(argv[1], \"-s\") ||\n \t\t\t\t!strcmp(argv[1], \"--strip-comments\")))\n \t\tstrip_comments = 1;\n+\telse if (argc > 1)\n+\t\tusage(\"git stripspace [-s | --strip-comments] < <stream>\");\n \n \tif (strbuf_read(&buf, 0, 1024) < 0)\n \t\tdie_errno(\"could not read the input\");\n-- \n1.6.5.2\n"},{"id":"127154","messageId":"1257779104-23884-18-git-send-email-jrnieder@gmail.com","threadId":"21527","inReplyTo":"20091109150235.GA23871@progeny.tock","subject":"[PATCH 18/24] merge: do not setup worktree twice","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:04:58Z","receivedAt":"2009-11-09T15:04:58Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Builtins do not need to run setup_worktree() for themselves, since\nthe builtin machinery runs it for them.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nThis matter since '-h' cannot suppress _this_ setup_work_tree()\nthrough the builtin machinery.\n\n builtin-merge.c |    1 -\n 1 files changed, 0 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-merge.c b/builtin-merge.c\nindex c69a305..1857138 100644\n--- a/builtin-merge.c\n+++ b/builtin-merge.c\n@@ -843,7 +843,6 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \tconst char *best_strategy = NULL, *wt_strategy = NULL;\n \tstruct commit_list **remotes = &remoteheads;\n \n-\tsetup_work_tree();\n \tif (file_exists(git_path(\"MERGE_HEAD\")))\n \t\tdie(\"You have not concluded your merge. (MERGE_HEAD exists)\");\n \tif (read_cache_unmerged())\n-- \n1.6.5.2\n"},{"id":"127156","messageId":"1257779104-23884-19-git-send-email-jrnieder@gmail.com","threadId":"21527","inReplyTo":"20091109150235.GA23871@progeny.tock","subject":"[PATCH 19/24] Let 'git http-fetch -h' show usage outside any git repository","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:04:59Z","receivedAt":"2009-11-09T15:04:59Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Delay search for a git directory until option parsing has finished.\nNone of the functions used in option parsing look for or read any\nfiles other than stdin, so this is safe.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n http-fetch.c |   21 +++++++++++++--------\n 1 files changed, 13 insertions(+), 8 deletions(-)\n\ndiff --git a/http-fetch.c b/http-fetch.c\nindex e8f44ba..52a4f6d 100644\n--- a/http-fetch.c\n+++ b/http-fetch.c\n@@ -1,6 +1,10 @@\n #include \"cache.h\"\n+#include \"exec_cmd.h\"\n #include \"walker.h\"\n \n+static const char http_fetch_usage[] = \"git http-fetch \"\n+\"[-c] [-t] [-a] [-v] [--recover] [-w ref] [--stdin] commit-id url\";\n+\n int main(int argc, const char **argv)\n {\n \tconst char *prefix;\n@@ -19,10 +23,6 @@ int main(int argc, const char **argv)\n \tint get_verbosely = 0;\n \tint get_recover = 0;\n \n-\tprefix = setup_git_directory();\n-\n-\tgit_config(git_default_config, NULL);\n-\n \twhile (arg < argc && argv[arg][0] == '-') {\n \t\tif (argv[arg][1] == 't') {\n \t\t\tget_tree = 1;\n@@ -37,6 +37,8 @@ int main(int argc, const char **argv)\n \t\t} else if (argv[arg][1] == 'w') {\n \t\t\twrite_ref = &argv[arg + 1];\n \t\t\targ++;\n+\t\t} else if (argv[arg][1] == 'h') {\n+\t\t\tusage(http_fetch_usage);\n \t\t} else if (!strcmp(argv[arg], \"--recover\")) {\n \t\t\tget_recover = 1;\n \t\t} else if (!strcmp(argv[arg], \"--stdin\")) {\n@@ -44,10 +46,8 @@ int main(int argc, const char **argv)\n \t\t}\n \t\targ++;\n \t}\n-\tif (argc < arg + 2 - commits_on_stdin) {\n-\t\tusage(\"git http-fetch [-c] [-t] [-a] [-v] [--recover] [-w ref] [--stdin] commit-id url\");\n-\t\treturn 1;\n-\t}\n+\tif (argc != arg + 2 - commits_on_stdin)\n+\t\tusage(http_fetch_usage);\n \tif (commits_on_stdin) {\n \t\tcommits = walker_targets_stdin(&commit_id, &write_ref);\n \t} else {\n@@ -55,6 +55,11 @@ int main(int argc, const char **argv)\n \t\tcommits = 1;\n \t}\n \turl = argv[arg];\n+\n+\tprefix = setup_git_directory();\n+\n+\tgit_config(git_default_config, NULL);\n+\n \tif (url && url[strlen(url)-1] != '/') {\n \t\trewritten_url = xmalloc(strlen(url)+2);\n \t\tstrcpy(rewritten_url, url);\n-- \n1.6.5.2\n"},{"id":"127149","messageId":"1257779104-23884-20-git-send-email-jrnieder@gmail.com","threadId":"21527","inReplyTo":"20091109150235.GA23871@progeny.tock","subject":"[PATCH 20/24] http-fetch: add missing initialization of argv0_path","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:05:00Z","receivedAt":"2009-11-09T15:05:00Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n http-fetch.c |    2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/http-fetch.c b/http-fetch.c\nindex 52a4f6d..ffd0ad7 100644\n--- a/http-fetch.c\n+++ b/http-fetch.c\n@@ -23,6 +23,8 @@ int main(int argc, const char **argv)\n \tint get_verbosely = 0;\n \tint get_recover = 0;\n \n+\tgit_extract_argv0_path(argv[0]);\n+\n \twhile (arg < argc && argv[arg][0] == '-') {\n \t\tif (argv[arg][1] == 't') {\n \t\t\tget_tree = 1;\n-- \n1.6.5.2\n"},{"id":"127159","messageId":"1257779104-23884-21-git-send-email-jrnieder@gmail.com","threadId":"21527","inReplyTo":"20091109150235.GA23871@progeny.tock","subject":"[PATCH 21/24] Let 'git <command> -h' show usage without a git dir","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:05:01Z","receivedAt":"2009-11-09T15:05:01Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"There is no need for \"git <command> -h\" to depend on being inside\na repository.\n\nReported by Gerfried Fuchs through http://bugs.debian.org/462557\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n builtin-log.c       |    6 ++++++\n builtin-mv.c        |    8 ++++----\n builtin-read-tree.c |    4 ++--\n builtin-reflog.c    |    3 +++\n builtin-rerere.c    |    3 +++\n git.c               |   21 ++++++++++++---------\n index-pack.c        |    3 +++\n pack-redundant.c    |    3 +++\n 8 files changed, 36 insertions(+), 15 deletions(-)\n\ndiff --git a/builtin-log.c b/builtin-log.c\nindex 5248507..a0fa30c 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -50,6 +50,12 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,\n \tif (default_date_mode)\n \t\trev->date_mode = parse_date_format(default_date_mode);\n \n+\t/*\n+\t * Check for -h before setup_revisions(), or \"git log -h\" will\n+\t * fail when run without a git directory.\n+\t */\n+\tif (argc == 2 && !strcmp(argv[1], \"-h\"))\n+\t\tusage(builtin_log_usage);\n \targc = setup_revisions(argc, argv, rev, \"HEAD\");\n \n \tif (rev->diffopt.pickaxe || rev->diffopt.filter)\ndiff --git a/builtin-mv.c b/builtin-mv.c\nindex 1b20028..f633d81 100644\n--- a/builtin-mv.c\n+++ b/builtin-mv.c\n@@ -64,15 +64,15 @@ int cmd_mv(int argc, const char **argv, const char *prefix)\n \n \tgit_config(git_default_config, NULL);\n \n-\tnewfd = hold_locked_index(&lock_file, 1);\n-\tif (read_cache() < 0)\n-\t\tdie(\"index file corrupt\");\n-\n \targc = parse_options(argc, argv, prefix, builtin_mv_options,\n \t\t\t     builtin_mv_usage, 0);\n \tif (--argc < 1)\n \t\tusage_with_options(builtin_mv_usage, builtin_mv_options);\n \n+\tnewfd = hold_locked_index(&lock_file, 1);\n+\tif (read_cache() < 0)\n+\t\tdie(\"index file corrupt\");\n+\n \tsource = copy_pathspec(prefix, argv, argc, 0);\n \tmodes = xcalloc(argc, sizeof(enum update_mode));\n \tdest_path = copy_pathspec(prefix, argv + argc, 1, 0);\ndiff --git a/builtin-read-tree.c b/builtin-read-tree.c\nindex 14c836b..2a3a32c 100644\n--- a/builtin-read-tree.c\n+++ b/builtin-read-tree.c\n@@ -108,11 +108,11 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)\n \n \tgit_config(git_default_config, NULL);\n \n-\tnewfd = hold_locked_index(&lock_file, 1);\n-\n \targc = parse_options(argc, argv, unused_prefix, read_tree_options,\n \t\t\t     read_tree_usage, 0);\n \n+\tnewfd = hold_locked_index(&lock_file, 1);\n+\n \tprefix_set = opts.prefix ? 1 : 0;\n \tif (1 < opts.merge + opts.reset + prefix_set)\n \t\tdie(\"Which one? -m, --reset, or --prefix?\");\ndiff --git a/builtin-reflog.c b/builtin-reflog.c\nindex e23b5ef..7498210 100644\n--- a/builtin-reflog.c\n+++ b/builtin-reflog.c\n@@ -698,6 +698,9 @@ static const char reflog_usage[] =\n \n int cmd_reflog(int argc, const char **argv, const char *prefix)\n {\n+\tif (argc > 1 && !strcmp(argv[1], \"-h\"))\n+\t\tusage(reflog_usage);\n+\n \t/* With no command, we default to showing it. */\n \tif (argc < 2 || *argv[1] == '-')\n \t\treturn cmd_log_reflog(argc, argv, prefix);\ndiff --git a/builtin-rerere.c b/builtin-rerere.c\nindex adfb7b5..343d6cd 100644\n--- a/builtin-rerere.c\n+++ b/builtin-rerere.c\n@@ -106,6 +106,9 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)\n \tif (argc < 2)\n \t\treturn rerere();\n \n+\tif (!strcmp(argv[1], \"-h\"))\n+\t\tusage(git_rerere_usage);\n+\n \tfd = setup_rerere(&merge_rr);\n \tif (fd < 0)\n \t\treturn 0;\ndiff --git a/git.c b/git.c\nindex f295561..743ee57 100644\n--- a/git.c\n+++ b/git.c\n@@ -229,21 +229,24 @@ struct cmd_struct {\n \n static int run_builtin(struct cmd_struct *p, int argc, const char **argv)\n {\n-\tint status;\n+\tint status, help;\n \tstruct stat st;\n \tconst char *prefix;\n \n \tprefix = NULL;\n-\tif (p->option & RUN_SETUP)\n-\t\tprefix = setup_git_directory();\n-\n-\tif (use_pager == -1 && p->option & RUN_SETUP)\n-\t\tuse_pager = check_pager_config(p->cmd);\n-\tif (use_pager == -1 && p->option & USE_PAGER)\n-\t\tuse_pager = 1;\n+\thelp = argc == 2 && !strcmp(argv[1], \"-h\");\n+\tif (!help) {\n+\t\tif (p->option & RUN_SETUP)\n+\t\t\tprefix = setup_git_directory();\n+\n+\t\tif (use_pager == -1 && p->option & RUN_SETUP)\n+\t\t\tuse_pager = check_pager_config(p->cmd);\n+\t\tif (use_pager == -1 && p->option & USE_PAGER)\n+\t\t\tuse_pager = 1;\n+\t}\n \tcommit_pager_choice();\n \n-\tif (p->option & NEED_WORK_TREE)\n+\tif (!help && p->option & NEED_WORK_TREE)\n \t\tsetup_work_tree();\n \n \ttrace_argv_printf(argv, \"trace: built-in: git\");\ndiff --git a/index-pack.c b/index-pack.c\nindex b4f8278..190f372 100644\n--- a/index-pack.c\n+++ b/index-pack.c\n@@ -882,6 +882,9 @@ int main(int argc, char **argv)\n \n \tgit_extract_argv0_path(argv[0]);\n \n+\tif (argc == 2 && !strcmp(argv[1], \"-h\"))\n+\t\tusage(index_pack_usage);\n+\n \t/*\n \t * We wish to read the repository's config file if any, and\n \t * for that it is necessary to call setup_git_directory_gently().\ndiff --git a/pack-redundant.c b/pack-redundant.c\nindex 69a7ab2..21c61db 100644\n--- a/pack-redundant.c\n+++ b/pack-redundant.c\n@@ -603,6 +603,9 @@ int main(int argc, char **argv)\n \n \tgit_extract_argv0_path(argv[0]);\n \n+\tif (argc == 2 && !strcmp(argv[1], \"-h\"))\n+\t\tusage(pack_redundant_usage);\n+\n \tsetup_git_directory();\n \n \tfor (i = 1; i < argc; i++) {\n-- \n1.6.5.2\n"},{"id":"127158","messageId":"1257779104-23884-22-git-send-email-jrnieder@gmail.com","threadId":"21527","inReplyTo":"20091109150235.GA23871@progeny.tock","subject":"[PATCH 22/24] Let usage() take a printf-style format","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:05:02Z","receivedAt":"2009-11-09T15:05:02Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"merge-recursive and diff --no-index are not able to use usage()\nbecause their usage strings depend on the circumstances in which\nthey are called.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n git-compat-util.h |    2 +-\n usage.c           |   14 +++++++++-----\n 2 files changed, 10 insertions(+), 6 deletions(-)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex ef60803..42048e7 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -188,7 +188,7 @@ extern char *gitbasename(char *);\n #include \"compat/bswap.h\"\n \n /* General helper functions */\n-extern NORETURN void usage(const char *err);\n+extern NORETURN void usage(const char *err, ...) __attribute__((format (printf, 1, 2)));\n extern NORETURN void die(const char *err, ...) __attribute__((format (printf, 1, 2)));\n extern NORETURN void die_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));\n extern int error(const char *err, ...) __attribute__((format (printf, 1, 2)));\ndiff --git a/usage.c b/usage.c\nindex c488f3a..f6d9ff5 100644\n--- a/usage.c\n+++ b/usage.c\n@@ -12,9 +12,9 @@ static void report(const char *prefix, const char *err, va_list params)\n \tfprintf(stderr, \"%s%s\\n\", prefix, msg);\n }\n \n-static NORETURN void usage_builtin(const char *err)\n+static NORETURN void usage_builtin(const char *err, va_list params)\n {\n-\tfprintf(stderr, \"usage: %s\\n\", err);\n+\treport(\"usage: \", err, params);\n \texit(129);\n }\n \n@@ -36,7 +36,7 @@ static void warn_builtin(const char *warn, va_list params)\n \n /* If we are in a dlopen()ed .so write to a global variable would segfault\n  * (ugh), so keep things static. */\n-static NORETURN_PTR void (*usage_routine)(const char *err) = usage_builtin;\n+static NORETURN_PTR void (*usage_routine)(const char *err, va_list params) = usage_builtin;\n static NORETURN_PTR void (*die_routine)(const char *err, va_list params) = die_builtin;\n static void (*error_routine)(const char *err, va_list params) = error_builtin;\n static void (*warn_routine)(const char *err, va_list params) = warn_builtin;\n@@ -46,9 +46,13 @@ void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_list param\n \tdie_routine = routine;\n }\n \n-void usage(const char *err)\n+void usage(const char *err, ...)\n {\n-\tusage_routine(err);\n+\tva_list params;\n+\n+\tva_start(params, err);\n+\tusage_routine(err, params);\n+\tva_end(params);\n }\n \n void die(const char *err, ...)\n-- \n1.6.5.2\n"},{"id":"127157","messageId":"1257779104-23884-23-git-send-email-jrnieder@gmail.com","threadId":"21527","inReplyTo":"20091109150235.GA23871@progeny.tock","subject":"[PATCH 23/24] merge-{recursive,subtree}: use usage() to print usage","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:05:03Z","receivedAt":"2009-11-09T15:05:03Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Usage messages (for example, from \"git merge-recursive -h\") are\nfriendlier when not preceded by \"fatal\".\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n builtin-merge-recursive.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-merge-recursive.c b/builtin-merge-recursive.c\nindex d26a96e..add5900 100644\n--- a/builtin-merge-recursive.c\n+++ b/builtin-merge-recursive.c\n@@ -33,7 +33,7 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (argc < 4)\n-\t\tdie(\"Usage: %s <base>... -- <head> <remote> ...\", argv[0]);\n+\t\tusage(\"%s <base>... -- <head> <remote> ...\", argv[0]);\n \n \tfor (i = 1; i < argc; ++i) {\n \t\tif (!strcmp(argv[i], \"--\"))\n-- \n1.6.5.2\n"},{"id":"127155","messageId":"1257779104-23884-24-git-send-email-jrnieder@gmail.com","threadId":"21527","inReplyTo":"20091109150235.GA23871@progeny.tock","subject":"[PATCH 24/24] diff --no-index: make the usage string less scary","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-09T15:05:04Z","receivedAt":"2009-11-09T15:05:04Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Start the diff --no-index usage string with \"usage:\" instead of\n\"fatal:\".\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n diff-no-index.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/diff-no-index.c b/diff-no-index.c\nindex 4ebc1db..a1f6fdf 100644\n--- a/diff-no-index.c\n+++ b/diff-no-index.c\n@@ -201,7 +201,7 @@ void diff_no_index(struct rev_info *revs,\n \t\t\treturn;\n \t}\n \tif (argc != i + 2)\n-\t\tdie(\"git diff %s takes two paths\",\n+\t\tusage(\"git diff %s <path> <path>\",\n \t\t    no_index ? \"--no-index\" : \"[--no-index]\");\n \n \tdiff_setup(&revs->diffopt);\n-- \n1.6.5.2\n"},{"id":"127266","messageId":"7v4op287is.fsf@alter.siamese.dyndns.org","threadId":"21527","inReplyTo":"1257779104-23884-7-git-send-email-jrnieder@gmail.com","subject":"Re: [PATCH 07/24] check-ref-format: update usage string","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-11-10T20:11:23Z","receivedAt":"2009-11-10T20:11:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This deserves to go to maint, so I ejected it out of the series.\n\nThanks.\n"},{"id":"127267","messageId":"7vws1y6sxg.fsf@alter.siamese.dyndns.org","threadId":"21527","inReplyTo":"1257779104-23884-18-git-send-email-jrnieder@gmail.com","subject":"Re: [PATCH 18/24] merge: do not setup worktree twice","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-11-10T20:11:55Z","receivedAt":"2009-11-10T20:11:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> Builtins do not need to run setup_worktree() for themselves, since\n> the builtin machinery runs it for them.\n>\n> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n> ---\n> This matter since '-h' cannot suppress _this_ setup_work_tree()\n> through the builtin machinery.\n\nI think this should directly go to 'maint'.  I ejected it from the\nseries.\n\nThanks.\n"},{"id":"127268","messageId":"7vpr7q6sw8.fsf@alter.siamese.dyndns.org","threadId":"21527","inReplyTo":"1257779104-23884-20-git-send-email-jrnieder@gmail.com","subject":"Re: [PATCH 20/24] http-fetch: add missing initialization of argv0_path","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-11-10T20:12:39Z","receivedAt":"2009-11-10T20:12:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n> ---\n\nWhy do you have inclusion of \"exec_cmd.h\" in [19/24]?  As far as I can\ntell, nothing you do in that patch depends on it.\n\nAccording to c6dfb39 (remote-curl: add missing initialization of\nargv0_path, 2009-10-13), this patch is necessary (and you must include\n\"exec_cmd.h\") on MinGW, regardless of the \"give help upon -h\" topic.\n\nI think this should be ejected from your series go directly to 'maint', or\nam I mistaken?\n\n http-fetch.c |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/http-fetch.c b/http-fetch.c\nindex e8f44ba..88f7dc8 100644\n--- a/http-fetch.c\n+++ b/http-fetch.c\n@@ -1,4 +1,5 @@\n #include \"cache.h\"\n+#include \"exec_cmd.h\"\n #include \"walker.h\"\n \n int main(int argc, const char **argv)\n@@ -19,8 +20,8 @@ int main(int argc, const char **argv)\n \tint get_verbosely = 0;\n \tint get_recover = 0;\n \n+\tgit_extract_argv0_path(argv[0]);\n \tprefix = setup_git_directory();\n-\n \tgit_config(git_default_config, NULL);\n \n \twhile (arg < argc && argv[arg][0] == '-') {\n"},{"id":"127269","messageId":"7veio66spc.fsf@alter.siamese.dyndns.org","threadId":"21527","inReplyTo":"1257779104-23884-22-git-send-email-jrnieder@gmail.com","subject":"Re: [PATCH 22/24] Let usage() take a printf-style format","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-11-10T20:16:47Z","receivedAt":"2009-11-10T20:16:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> merge-recursive and diff --no-index are not able to use usage()\n> because their usage strings depend on the circumstances in which\n> they are called.\n\nSince die() and warn() are already printf-like, it may be tempting\nto do this, but this is wrong.\n\nI do not want to vet all the existing call sites to usage() of make sure\nthat all of them _happen_ to pass constant strings that do not have any\n'%' in them.\n\nMuch more importantly, without a patch to future-proof all existing\ncallsites to modify from\n\n\tusage(blame_usage);\n\nto\n\n\tusage(\"%s\", blame_usage);\n\neverybody needs to remember that some *_usage strings are special and have\nto double % in it forever, which is a maintenance nightmare.\n\nBesides, the majority of usage strings are _expected_ to be constant.\nThat is an important difference from die/warn whose purpose is to diagnose\nand give appropriate message to the situation (hence they benefit from\nformatting).\n\nI've renamed this to usagef() and updated your two callers to use it in\nthe version I queued to 'pu'.\n\nThanks.\n"},{"id":"127277","messageId":"200911102256.08627.j6t@kdbg.org","threadId":"21527","inReplyTo":"7vpr7q6sw8.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 20/24] http-fetch: add missing initialization of argv0_path","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2009-11-10T21:56:08Z","receivedAt":"2009-11-10T21:56:08Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Dienstag, 10. November 2009, Junio C Hamano wrote:\n> Jonathan Nieder <jrnieder@gmail.com> writes:\n> > Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n> > ---\n>\n> Why do you have inclusion of \"exec_cmd.h\" in [19/24]?  As far as I can\n> tell, nothing you do in that patch depends on it.\n>\n> According to c6dfb39 (remote-curl: add missing initialization of\n> argv0_path, 2009-10-13), this patch is necessary (and you must include\n> \"exec_cmd.h\") on MinGW, regardless of the \"give help upon -h\" topic.\n>\n> I think this should be ejected from your series go directly to 'maint', or\n> am I mistaken?\n\nYou are right.\n\nThis command (in bash):\n\ncomm <(git grepc -l main\\( *.c) <(git grepc -l extract_argv0 *.c)\n\nshows programs in the 1st column that have main(), but do not call \ngit_extract_argv0_path. One remaining candidate is show-index.c, but its only \ncall-out is sha1_to_hex(), which doesn't use any other services.\n\nhttp-fetch.c is the only file that needs this patch.\n\n-- Hannes\n"},{"id":"127284","messageId":"20091111015245.GA9027@progeny.tock","threadId":"21527","inReplyTo":"7vpr7q6sw8.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 20/24] http-fetch: add missing initialization of argv0_path","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-11T01:52:45Z","receivedAt":"2009-11-11T01:52:45Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Junio C Hamano wrote:\n\n> Why do you have inclusion of \"exec_cmd.h\" in [19/24]?  As far as I can\n> tell, nothing you do in that patch depends on it.\n\nNo good reason.  Thanks for cleaning up my mess.\n\nJonathan\n"},{"id":"127285","messageId":"20091111015832.GB9027@progeny.tock","threadId":"21527","inReplyTo":"7vws1y6sxg.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 18/24] merge: do not setup worktree twice","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2009-11-11T01:58:33Z","receivedAt":"2009-11-11T01:58:33Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Junio C Hamano wrote:\n> Jonathan Nieder <jrnieder@gmail.com> writes:\n>\n>> Builtins do not need to run setup_worktree() for themselves, since\n>> the builtin machinery runs it for them.\n>>\n>> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n>> ---\n>> This matter since '-h' cannot suppress _this_ setup_work_tree()\n>> through the builtin machinery.\n>\n> I think this should directly go to 'maint'.  I ejected it from the\n> series.\n\nThanks.  I think something like this should go on top on maint, then\nreverted in master.\n\nSorry for the trouble,\nJonathan\n\n-- %< --\nSubject: check-ref-format does not know --print yet\n\nDon’t advertise the --print option of the future in the current\nusage string.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n builtin-check-ref-format.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-check-ref-format.c b/builtin-check-ref-format.c\nindex 96382e3..a5ba4ea 100644\n--- a/builtin-check-ref-format.c\n+++ b/builtin-check-ref-format.c\n@@ -8,7 +8,7 @@\n #include \"strbuf.h\"\n \n static const char builtin_check_ref_format_usage[] =\n-\"git check-ref-format [--print] <refname>\\n\"\n+\"git check-ref-format <refname>\\n\"\n \"   or: git check-ref-format --branch <branchname-shorthand>\";\n \n int cmd_check_ref_format(int argc, const char **argv, const char *prefix)\n-- \n1.6.5.2\n"}]}