{"thread":{"id":"21664","subject":"[PATCH v4] git remote: Separate usage strings for subcommands","startedAt":"2009-11-19T02:59:46Z","lastAt":"2009-11-20T09:36:46Z","messageCount":6,"participants":["Tim Henigan","Nanako Shiraishi","Junio C Hamano"],"isPatch":true,"patchVersion":4,"patchTotal":null},"messages":[{"id":"127882","messageId":"4B04B4A2.8090001@gmail.com","threadId":"21664","inReplyTo":null,"subject":"[PATCH v4] git remote: Separate usage strings for subcommands","fromName":"Tim Henigan","fromEmail":"tim.henigan@gmail.com","sentAt":"2009-11-19T02:59:46Z","receivedAt":"2009-11-19T02:59:46Z","isPatch":true,"sender":{"key":"tim.henigan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42022?v=4"},"body":"When the usage string for a subcommand must be printed,\nonly print the information relevant to that command.\n\nThis commit also removes the options from the first line\nof the usage string (replacing them with '<options>'\nand lets them be documented in the paragraph below.\n\nSigned-off-by: Tim Henigan <tim.henigan@gmail.com>\n---\n\nThis patch is based on:\nhttp://article.gmane.org/gmane.comp.version-control.git/132953\n\nAll usage strings are still only located at the top of file.  However,\nseparate usage string arrays have been created for each subcommand.\n\nv2 fixed line wrap issues present in v1.\n\nv3 changes include:\n - Changed usage strings to use '<options>...' rather than document\n   the options both in the actual string and in the OPT_x array\n   (as recommended by Junio).\n - Removed the change made to the usage string array constructed\n   in 'cmd_remote'. v2 was broken because that change had made\n   the command stop recognizing the '-v' option. Added an extra\n   note here which explains that '-v' is only valid when placed\n   after 'git remote' and before any 'subcommand'.\n - Updated the man page.\n\nv4 changes include:\n - Changed usage strings to use '<options>' rather than\n   '<options>...' based on feedback from Jonathan Nieder.\n   See [1] for details.\n - Corrected \"git remote set-head\" usage string to show the\n   required [-a | -d | <branch>] portion of the command.\n - Corrected \"git remote update\" usage string to show the\n   optional, but not otherwise documented [<group> | <remote>]\n   portion of the command.\n - Removed 2 more instances of \"<subcommand> specific options\".\n\n[1] http://thread.gmane.org/gmane.comp.version-control.git/133151/focus=133160\n\n\n Documentation/git-remote.txt |   13 +++++----\n builtin-remote.c             |   60 +++++++++++++++++++++++++----------------\n 2 files changed, 43 insertions(+), 30 deletions(-)\n\ndiff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt\nindex 82a3d29..ee3dc80 100644\n--- a/Documentation/git-remote.txt\n+++ b/Documentation/git-remote.txt\n@@ -9,14 +9,14 @@ git-remote - manage set of tracked repositories\n SYNOPSIS\n --------\n [verse]\n-'git remote' [-v | --verbose]\n-'git remote add' [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url>\n+'git remote' [<options>]\n+'git remote add' [<options>] <name> <url>\n 'git remote rename' <old> <new>\n 'git remote rm' <name>\n-'git remote set-head' <name> [-a | -d | <branch>]\n-'git remote show' [-n] <name>\n-'git remote prune' [-n | --dry-run] <name>\n-'git remote update' [-p | --prune] [group | remote]...\n+'git remote set-head' <name> [<options>] [-a | -d | <branch>]\n+'git remote show' [<options>] <name>\n+'git remote prune' [<options>] <name>\n+'git remote update' [<options>] [<group> | <remote>]...\n \n DESCRIPTION\n -----------\n@@ -30,6 +30,7 @@ OPTIONS\n -v::\n --verbose::\n \tBe a little more verbose and show remote url after name.\n+\tNOTE: This must be placed between `remote` and `subcommand`.\n \n \n COMMANDS\ndiff --git a/builtin-remote.c b/builtin-remote.c\nindex 0777dd7..24a3ec0 100644\n--- a/builtin-remote.c\n+++ b/builtin-remote.c\n@@ -7,18 +7,35 @@\n #include \"run-command.h\"\n #include \"refs.h\"\n \n+#define REMOTE_BARE_USAGE \"git remote [<options>]\"\n+#define REMOTE_ADD_USAGE \"git remote add [<options>] <name> <url>\"\n+#define REMOTE_RENAME_USAGE \"git remote rename <old> <new>\"\n+#define REMOTE_RM_USAGE \"git remote rm <name>\"\n+#define REMOTE_SETHEAD_USAGE \"git remote set-head <name> [-a | -d | <branch>]\"\n+#define REMOTE_SHOW_USAGE \"git remote show [<options>] <name>\"\n+#define REMOTE_PRUNE_USAGE \"git remote prune [<options>] <name>\"\n+#define REMOTE_UPDATE_USAGE \"git remote update [<options>] [<group> | <remote>]...\"\n+\n static const char * const builtin_remote_usage[] = {\n-\t\"git remote [-v | --verbose]\",\n-\t\"git remote add [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url>\",\n-\t\"git remote rename <old> <new>\",\n-\t\"git remote rm <name>\",\n-\t\"git remote set-head <name> [-a | -d | <branch>]\",\n-\t\"git remote show [-n] <name>\",\n-\t\"git remote prune [-n | --dry-run] <name>\",\n-\t\"git remote [-v | --verbose] update [-p | --prune] [group]\",\n+\tREMOTE_BARE_USAGE,\n+\tREMOTE_ADD_USAGE,\n+\tREMOTE_RENAME_USAGE,\n+\tREMOTE_RM_USAGE,\n+\tREMOTE_SETHEAD_USAGE,\n+\tREMOTE_SHOW_USAGE,\n+\tREMOTE_PRUNE_USAGE,\n+\tREMOTE_UPDATE_USAGE,\n \tNULL\n };\n \n+static const char * const builtin_remote_add_usage[] = { REMOTE_ADD_USAGE, NULL };\n+static const char * const builtin_remote_rename_usage[] = { REMOTE_RENAME_USAGE, NULL };\n+static const char * const builtin_remote_rm_usage[] = { REMOTE_RM_USAGE, NULL };\n+static const char * const builtin_remote_sethead_usage[] = { REMOTE_SETHEAD_USAGE, NULL };\n+static const char * const builtin_remote_show_usage[] = { REMOTE_SHOW_USAGE, NULL };\n+static const char * const builtin_remote_prune_usage[] = { REMOTE_PRUNE_USAGE, NULL };\n+static const char * const builtin_remote_update_usage[] = { REMOTE_UPDATE_USAGE, NULL };\n+\n #define GET_REF_STATES (1<<0)\n #define GET_HEAD_NAMES (1<<1)\n #define GET_PUSH_REF_STATES (1<<2)\n@@ -70,7 +87,6 @@ static int add(int argc, const char **argv)\n \tint i;\n \n \tstruct option options[] = {\n-\t\tOPT_GROUP(\"add specific options\"),\n \t\tOPT_BOOLEAN('f', \"fetch\", &fetch, \"fetch the remote branches\"),\n \t\tOPT_CALLBACK('t', \"track\", &track, \"branch\",\n \t\t\t\"branch(es) to track\", opt_parse_track),\n@@ -79,11 +95,11 @@ static int add(int argc, const char **argv)\n \t\tOPT_END()\n \t};\n \n-\targc = parse_options(argc, argv, NULL, options, builtin_remote_usage,\n+\targc = parse_options(argc, argv, NULL, options, builtin_remote_add_usage,\n \t\t\t     0);\n \n \tif (argc < 2)\n-\t\tusage_with_options(builtin_remote_usage, options);\n+\t\tusage_with_options(builtin_remote_add_usage, options);\n \n \tname = argv[0];\n \turl = argv[1];\n@@ -540,7 +556,7 @@ static int mv(int argc, const char **argv)\n \tint i;\n \n \tif (argc != 3)\n-\t\tusage_with_options(builtin_remote_usage, options);\n+\t\tusage_with_options(builtin_remote_rename_usage, options);\n \n \trename.old = argv[1];\n \trename.new = argv[2];\n@@ -681,7 +697,7 @@ static int rm(int argc, const char **argv)\n \tint i, result;\n \n \tif (argc != 2)\n-\t\tusage_with_options(builtin_remote_usage, options);\n+\t\tusage_with_options(builtin_remote_rm_usage, options);\n \n \tremote = remote_get(argv[1]);\n \tif (!remote)\n@@ -976,7 +992,6 @@ static int show(int argc, const char **argv)\n {\n \tint no_query = 0, result = 0, query_flag = 0;\n \tstruct option options[] = {\n-\t\tOPT_GROUP(\"show specific options\"),\n \t\tOPT_BOOLEAN('n', NULL, &no_query, \"do not query remotes\"),\n \t\tOPT_END()\n \t};\n@@ -984,7 +999,7 @@ static int show(int argc, const char **argv)\n \tstruct string_list info_list = { NULL, 0, 0, 0 };\n \tstruct show_info info;\n \n-\targc = parse_options(argc, argv, NULL, options, builtin_remote_usage,\n+\targc = parse_options(argc, argv, NULL, options, builtin_remote_show_usage,\n \t\t\t     0);\n \n \tif (argc < 1)\n@@ -1081,14 +1096,13 @@ static int set_head(int argc, const char **argv)\n \tchar *head_name = NULL;\n \n \tstruct option options[] = {\n-\t\tOPT_GROUP(\"set-head specific options\"),\n \t\tOPT_BOOLEAN('a', \"auto\", &opt_a,\n \t\t\t    \"set refs/remotes/<name>/HEAD according to remote\"),\n \t\tOPT_BOOLEAN('d', \"delete\", &opt_d,\n \t\t\t    \"delete refs/remotes/<name>/HEAD\"),\n \t\tOPT_END()\n \t};\n-\targc = parse_options(argc, argv, NULL, options, builtin_remote_usage,\n+\targc = parse_options(argc, argv, NULL, options, builtin_remote_sethead_usage,\n \t\t\t     0);\n \tif (argc)\n \t\tstrbuf_addf(&buf, \"refs/remotes/%s/HEAD\", argv[0]);\n@@ -1114,7 +1128,7 @@ static int set_head(int argc, const char **argv)\n \t\tif (delete_ref(buf.buf, NULL, REF_NODEREF))\n \t\t\tresult |= error(\"Could not delete %s\", buf.buf);\n \t} else\n-\t\tusage_with_options(builtin_remote_usage, options);\n+\t\tusage_with_options(builtin_remote_sethead_usage, options);\n \n \tif (head_name) {\n \t\tunsigned char sha1[20];\n@@ -1138,16 +1152,15 @@ static int prune(int argc, const char **argv)\n {\n \tint dry_run = 0, result = 0;\n \tstruct option options[] = {\n-\t\tOPT_GROUP(\"prune specific options\"),\n \t\tOPT__DRY_RUN(&dry_run),\n \t\tOPT_END()\n \t};\n \n-\targc = parse_options(argc, argv, NULL, options, builtin_remote_usage,\n+\targc = parse_options(argc, argv, NULL, options, builtin_remote_prune_usage,\n \t\t\t     0);\n \n \tif (argc < 1)\n-\t\tusage_with_options(builtin_remote_usage, options);\n+\t\tusage_with_options(builtin_remote_prune_usage, options);\n \n \tfor (; argc; argc--, argv++)\n \t\tresult |= prune_remote(*argv, dry_run);\n@@ -1228,13 +1241,12 @@ static int update(int argc, const char **argv)\n \tstruct string_list list = { NULL, 0, 0, 0 };\n \tstatic const char *default_argv[] = { NULL, \"default\", NULL };\n \tstruct option options[] = {\n-\t\tOPT_GROUP(\"update specific options\"),\n \t\tOPT_BOOLEAN('p', \"prune\", &prune,\n \t\t\t    \"prune remotes after fetching\"),\n \t\tOPT_END()\n \t};\n \n-\targc = parse_options(argc, argv, NULL, options, builtin_remote_usage,\n+\targc = parse_options(argc, argv, NULL, options, builtin_remote_update_usage,\n \t\t\t     PARSE_OPT_KEEP_ARGV0);\n \tif (argc < 2) {\n \t\targc = 2;\n@@ -1334,7 +1346,7 @@ static int show_all(void)\n int cmd_remote(int argc, const char **argv, const char *prefix)\n {\n \tstruct option options[] = {\n-\t\tOPT__VERBOSE(&verbose),\n+\t\tOPT_BOOLEAN('v', \"verbose\", &verbose, \"be verbose; must be placed before a subcommand\"),\n \t\tOPT_END()\n \t};\n \tint result;\n-- \n1.6.5.2.186.ga4d60\n"},{"id":"127883","messageId":"20091119124040.6117@nanako3.lavabit.com","threadId":"21664","inReplyTo":"4B04B4A2.8090001@gmail.com","subject":"Re: [PATCH v4] git remote: Separate usage strings for subcommands","fromName":"Nanako Shiraishi","fromEmail":"nanako3@lavabit.com","sentAt":"2009-11-19T03:40:40Z","receivedAt":"2009-11-19T03:40:40Z","isPatch":true,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"Quoting Tim Henigan <tim.henigan@gmail.com>\n\n> When the usage string for a subcommand must be printed,\n> only print the information relevant to that command.\n\nI think this is a huge improvement.\n\n> diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt\n> index 82a3d29..ee3dc80 100644\n> --- a/Documentation/git-remote.txt\n> +++ b/Documentation/git-remote.txt\n> @@ -9,14 +9,14 @@ git-remote - manage set of tracked repositories\n>  SYNOPSIS\n>  --------\n>  [verse]\n> -'git remote' [-v | --verbose]\n> -'git remote add' [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url>\n> +'git remote' [<options>]\n> +'git remote add' [<options>] <name> <url>\n>  'git remote rename' <old> <new>\n>  'git remote rm' <name>\n> -'git remote set-head' <name> [-a | -d | <branch>]\n> -'git remote show' [-n] <name>\n> -'git remote prune' [-n | --dry-run] <name>\n> -'git remote update' [-p | --prune] [group | remote]...\n> +'git remote set-head' <name> [<options>] [-a | -d | <branch>]\n> +'git remote show' [<options>] <name>\n> +'git remote prune' [<options>] <name>\n> +'git remote update' [<options>] [<group> | <remote>]...\n\nOften people look at this part of the manual page to quickly remind \nthemselves what options are available, and it is better to keep the \ncurrent text. Some manual pages have to use [options...] when there \nare too many to list, but each subcommand of git-remote doesn't have \nthat many options.\n\n> diff --git a/builtin-remote.c b/builtin-remote.c\n> index 0777dd7..24a3ec0 100644\n> --- a/builtin-remote.c\n> +++ b/builtin-remote.c\n> @@ -7,18 +7,35 @@\n>  #include \"run-command.h\"\n>  #include \"refs.h\"\n>  \n> +#define REMOTE_BARE_USAGE \"git remote [<options>]\"\n> +#define REMOTE_ADD_USAGE \"git remote add [<options>] <name> <url>\"\n> +#define REMOTE_RENAME_USAGE \"git remote rename <old> <new>\"\n> +#define REMOTE_RM_USAGE \"git remote rm <name>\"\n> +#define REMOTE_SETHEAD_USAGE \"git remote set-head <name> [-a | -d | <branch>]\"\n> +#define REMOTE_SHOW_USAGE \"git remote show [<options>] <name>\"\n> +#define REMOTE_PRUNE_USAGE \"git remote prune [<options>] <name>\"\n> +#define REMOTE_UPDATE_USAGE \"git remote update [<options>] [<group> | <remote>]...\"\n> +\n>  static const char * const builtin_remote_usage[] = {\n> -\t\"git remote [-v | --verbose]\",\n> -\t\"git remote add [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url>\",\n> -\t\"git remote rename <old> <new>\",\n> -\t\"git remote rm <name>\",\n> -\t\"git remote set-head <name> [-a | -d | <branch>]\",\n> -\t\"git remote show [-n] <name>\",\n> -\t\"git remote prune [-n | --dry-run] <name>\",\n> -\t\"git remote [-v | --verbose] update [-p | --prune] [group]\",\n> +\tREMOTE_BARE_USAGE,\n> +\tREMOTE_ADD_USAGE,\n> +\tREMOTE_RENAME_USAGE,\n> +\tREMOTE_RM_USAGE,\n> +\tREMOTE_SETHEAD_USAGE,\n> +\tREMOTE_SHOW_USAGE,\n> +\tREMOTE_PRUNE_USAGE,\n> +\tREMOTE_UPDATE_USAGE,\n>  \tNULL\n>  };\n\nFor the same reason, I don't think this is a good change, if these\nlines are used to show the first lines of 'git-remote -h' output.\n"},{"id":"127903","messageId":"32c343770911190651w3f1ac9b6i2d3b1a62a032489f@mail.gmail.com","threadId":"21664","inReplyTo":"20091119124040.6117@nanako3.lavabit.com","subject":"Re: [PATCH v4] git remote: Separate usage strings for subcommands","fromName":"Tim Henigan","fromEmail":"tim.henigan@gmail.com","sentAt":"2009-11-19T14:51:18Z","receivedAt":"2009-11-19T14:51:18Z","isPatch":true,"sender":{"key":"tim.henigan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42022?v=4"},"body":"On Wed, Nov 18, 2009 at 10:40 PM, Nanako Shiraishi <nanako3@lavabit.com> wrote:\n> Quoting Tim Henigan <tim.henigan@gmail.com>\n>\n>> When the usage string for a subcommand must be printed,\n>> only print the information relevant to that command.\n>\n> I think this is a huge improvement.\n>\n> Often people look at this part of the manual page to quickly remind\n> themselves what options are available, and it is better to keep the\n> current text. Some manual pages have to use [options...] when there\n> are too many to list, but each subcommand of git-remote doesn't have\n> that many options.\n\n... snip ...\n\n> For the same reason, I don't think this is a good change, if these\n> lines are used to show the first lines of 'git-remote -h' output.\n\nThe original version of this patch [1] left the contents of the usage\nstrings intact.  However, Junio expressed a preference to change\nthem to use the generic <options>.  See this thread for the\ndiscussion [2].\n\n[1] http://article.gmane.org/gmane.comp.version-control.git/133048/\n[2] http://thread.gmane.org/gmane.comp.version-control.git/132968/focus=133050\n"},{"id":"127912","messageId":"7vlji2bd23.fsf@alter.siamese.dyndns.org","threadId":"21664","inReplyTo":"32c343770911190651w3f1ac9b6i2d3b1a62a032489f@mail.gmail.com","subject":"Re: [PATCH v4] git remote: Separate usage strings for subcommands","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-11-19T18:10:44Z","receivedAt":"2009-11-19T18:10:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tim Henigan <tim.henigan@gmail.com> writes:\n\n> The original version of this patch [1] left the contents of the usage\n> strings intact.  However, Junio expressed a preference to change\n> them to use the generic <options>.  See this thread for the\n> discussion [2].\n>\n> [1] http://article.gmane.org/gmane.comp.version-control.git/133048/\n> [2] http://thread.gmane.org/gmane.comp.version-control.git/132968/focus=133050\n\nSorry, but I think you misunderstood what I meant, then.  in [2], I said...\n\n    > ... hunk to remove literal strings from builtin_remote_usage[] \n    > ... and replace them with REMOTE_BARE_USAGE, REMOTE_ADD_USAGE\n\n    I am not sure about the value of reusing option string like this, and for\n\nHere, please note that I was objecting to the use of _the same string_ in\nboth contexts (\"reusing\").\n\n    all other subcommands the same comment applies.  For example, in the case\n    of \"remote add -h\", you would use\n\n    \"git remote add [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url>\"\n\n    from REMOTE_ADD_USAGE, but ...\n\n    > ... hunk to give the builtin_remote_add_usage[] that  uses the same\n    > ... REMOTE_ADD_USAGE to parse_options() \n\n    ... the options list is used to reproduce the information in a major part\n    of that string already.  So I would prefer builtin_remote_add_usage[] to\n    be something like:\n\n        \"git remote add [<options>...] <name> <url>\"\n\nI meant that we want to change \"remote add -h\" to show this here; and the\nreason why I doubted \"the value of reusing option string\" was because I\nwanted to do so without touching the concise list of the subcommands and\ntheir options given by \"remote -h\".  Otherwise, it would have made perfect\nsense to use preprocessor macros to share the two identical strings.\n\nIn your response to my above comment, you indicated that you wanted to do\nthe [<options>] thing as a separate patch (your original patch spelled\noptions in full).  I took it to mean that you would do that only for the\nsubcommand help, and did not respond, because\n\n (1) doing that to the subcommand help would be a good idea anyway; and\n\n (2) you will realize what I said in the message about \"the value of\n     reusing option string\" was correct when you see the end result, which\n     will regress \"remote -h\" output.\n\nIn this case, unfortunately (2) didn't happen before Nana pointed it out.\n"},{"id":"127916","messageId":"32c343770911191058x7be7d34ascc3564064b880213@mail.gmail.com","threadId":"21664","inReplyTo":"7vlji2bd23.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v4] git remote: Separate usage strings for subcommands","fromName":"Tim Henigan","fromEmail":"tim.henigan@gmail.com","sentAt":"2009-11-19T18:58:57Z","receivedAt":"2009-11-19T18:58:57Z","isPatch":true,"sender":{"key":"tim.henigan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42022?v=4"},"body":"On Thu, Nov 19, 2009 at 1:10 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Tim Henigan <tim.henigan@gmail.com> writes:\n>\n>> The original version of this patch [1] left the contents of the usage\n>> strings intact.  However, Junio expressed a preference to change\n>> them to use the generic <options>.  See this thread for the\n>> discussion [2].\n>>\n>> [1] http://article.gmane.org/gmane.comp.version-control.git/133048/\n>> [2] http://thread.gmane.org/gmane.comp.version-control.git/132968/focus=133050\n>\n> Sorry, but I think you misunderstood what I meant, then.  in [2], I said...\n\n... snip ...\n\n>    ... the options list is used to reproduce the information in a major part\n>    of that string already.  So I would prefer builtin_remote_add_usage[] to\n>    be something like:\n>\n>        \"git remote add [<options>...] <name> <url>\"\n>\n> I meant that we want to change \"remote add -h\" to show this here; and the\n> reason why I doubted \"the value of reusing option string\" was because I\n> wanted to do so without touching the concise list of the subcommands and\n> their options given by \"remote -h\".  Otherwise, it would have made perfect\n> sense to use preprocessor macros to share the two identical strings.\n\nOkay, I believe I understand now, but let's test that theory ;)\n\nUsing the 'add' subcommand as an example, the desired output is:\n\nOutput of 'git remote -h':\n    \"git remote [-v | --verbose]\"\n    \"git remote add [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url>\"\n    etc.\n\nOutput of 'git remote add -h':\n    \"git remote add [<options>...] <name> <url>\"\n    followed by the detailed description given by 'parse_options()'.\n\nText in 'man git-remote':\n    \"git remote add [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url>\"\n    with the options explained in detail later in the file.\n\nThanks for your patience,\nTim\n"},{"id":"127989","messageId":"7vskc95yhd.fsf@alter.siamese.dyndns.org","threadId":"21664","inReplyTo":"32c343770911191058x7be7d34ascc3564064b880213@mail.gmail.com","subject":"Re: [PATCH v4] git remote: Separate usage strings for subcommands","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-11-20T09:36:46Z","receivedAt":"2009-11-20T09:36:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tim Henigan <tim.henigan@gmail.com> writes:\n\n> Using the 'add' subcommand as an example, the desired output is:\n>\n> Output of 'git remote -h':\n>     \"git remote [-v | --verbose]\"\n>     \"git remote add [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url>\"\n>     etc.\n>\n> Output of 'git remote add -h':\n>     \"git remote add [<options>...] <name> <url>\"\n>     followed by the detailed description given by 'parse_options()'.\n>\n> Text in 'man git-remote':\n>     \"git remote add [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url>\"\n>     with the options explained in detail later in the file.\n>\n> Thanks for your patience,\n\nI think the above looks good; thank _you_ for your patience.\n\nI often wonder if we want to add to the parse-options library a function\nthat takes a \"const struct option *\" and some other unspecified hints, and\nfills a strbuf with a one-line description, e.g.\n\n    \"[-t <branch>] [-m <master>] [-f] [--mirror]\"\n\nI expect we would eventually want to handle something like (this example\nis from \"git push\"):\n\n    \"[--all | --mirror | --tags] [-n | --dry-run]\"\n\nand walking elements in a \"struct option\" one by one wouldn't give us\nenough information to group all/mirror/tags in \"one of these\" brackets,\nand that is what I mean by \"some other unspecified hints\".  Obviously we\ncould do the \"[-n|--dry-run]\" with existing information.\n\nA helper function like that may make things a bit easier.  parse_options()\nmay need to take a custom callback function of some sort so that you can\noverride what parse_options_usage() does when responding to \"remote -h\"\nand generate the list of subcommands and their options on the fly, though.\n\nBut that is all outside the scope of this particular patch.\n"}]}