{"thread":{"id":"52160","subject":"[PATCH] ls-remote: Remove conflicting option \"-h\"","startedAt":"2019-10-30T17:42:44Z","lastAt":"2019-10-30T18:29:00Z","messageCount":2,"participants":["Mattias Hansson","SZEDER Gábor"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"385165","messageId":"20191030173337.6574-1-mattias.hansson@axis.com","threadId":"52160","inReplyTo":null,"subject":"[PATCH] ls-remote: Remove conflicting option \"-h\"","fromName":"Mattias Hansson","fromEmail":"mattias.hansson@axis.com","sentAt":"2019-10-30T17:33:37Z","receivedAt":"2019-10-30T17:42:44Z","isPatch":true,"sender":{"key":"mattias.hansson@axis.com","avatar":null},"body":"From: Mattias Hansson <hansson.mattias@gmail.com>\n\nThe \"-h\" option is documented to limit the result to heads, which is a\nbit nonintuitive since \"-h\" is commonly used as the short option for\n\"--help\". However, \"-h\" currently displays the usage information\nwhich proves that there's a double reference to the option.\n\nThis patch will remove \"-h\" as a short option for \"--heads\". This\nwill maintain the current behaviour and correct the misleading\ndocumentation.\n\nSigned-off-by: Mattias Hansson <hansson.mattias@gmail.com>\n---\n builtin/ls-remote.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex 6ef519514b..85ce336fc3 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -63,7 +63,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \t\t\t   N_(\"path of git-upload-pack on the remote host\"),\n \t\t\t   PARSE_OPT_HIDDEN },\n \t\tOPT_BIT('t', \"tags\", &flags, N_(\"limit to tags\"), REF_TAGS),\n-\t\tOPT_BIT('h', \"heads\", &flags, N_(\"limit to heads\"), REF_HEADS),\n+\t\tOPT_BIT(0, \"heads\", &flags, N_(\"limit to heads\"), REF_HEADS),\n \t\tOPT_BIT(0, \"refs\", &flags, N_(\"do not show peeled tags\"), REF_NORMAL),\n \t\tOPT_BOOL(0, \"get-url\", &get_url,\n \t\t\t N_(\"take url.<base>.insteadOf into account\")),\n-- \n2.22.0\n\n"},{"id":"385169","messageId":"20191030182854.GX4348@szeder.dev","threadId":"52160","inReplyTo":"20191030173337.6574-1-mattias.hansson@axis.com","subject":"Re: [PATCH] ls-remote: Remove conflicting option \"-h\"","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2019-10-30T18:28:54Z","receivedAt":"2019-10-30T18:29:00Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Wed, Oct 30, 2019 at 06:33:37PM +0100, Mattias Hansson wrote:\n> From: Mattias Hansson <hansson.mattias@gmail.com>\n> \n> The \"-h\" option is documented to limit the result to heads, which is a\n> bit nonintuitive since \"-h\" is commonly used as the short option for\n> \"--help\". However, \"-h\" currently displays the usage information\n> which proves that there's a double reference to the option.\n\nInteresting.\n\nWhile 'git ls-remote -h' shows the usage information, 'git ls-remote\n-h origin' does list branches from the given remote.  This is\nintentional: 'git ls-remote -h' without a remote listed branches from\nthe default remote for years, but, as you pointed out, it's\nnonintuitive, so it's behavior was changed to what we have today in\ncommit 91a640ffb6 (ls-remote: a lone \"-h\" is asking for help,\n2011-09-16).\n\nI think the short option should stay, because removing it will break\nthe case when the remote is specified on the command line.\n\nHowever, its description in the usage string and in the man page could\nbe improved to point out this caveat.  Doing so in the man page is\nsurely not too difficult, because we can dedicate a whole sentence or\neven two to this corner case, but I'm not sure how it could be\nsensibly squeezed into the usage string.\n\n> This patch will remove \"-h\" as a short option for \"--heads\". This\n> will maintain the current behaviour and correct the misleading\n> documentation.\n\nNote that '-h' is documentet in the man page as well, so if we decide\nto go for removal, then it should be removed from the man page as\nwell.\n\n> Signed-off-by: Mattias Hansson <hansson.mattias@gmail.com>\n> ---\n>  builtin/ls-remote.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\n> index 6ef519514b..85ce336fc3 100644\n> --- a/builtin/ls-remote.c\n> +++ b/builtin/ls-remote.c\n> @@ -63,7 +63,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n>  \t\t\t   N_(\"path of git-upload-pack on the remote host\"),\n>  \t\t\t   PARSE_OPT_HIDDEN },\n>  \t\tOPT_BIT('t', \"tags\", &flags, N_(\"limit to tags\"), REF_TAGS),\n> -\t\tOPT_BIT('h', \"heads\", &flags, N_(\"limit to heads\"), REF_HEADS),\n> +\t\tOPT_BIT(0, \"heads\", &flags, N_(\"limit to heads\"), REF_HEADS),\n>  \t\tOPT_BIT(0, \"refs\", &flags, N_(\"do not show peeled tags\"), REF_NORMAL),\n>  \t\tOPT_BOOL(0, \"get-url\", &get_url,\n>  \t\t\t N_(\"take url.<base>.insteadOf into account\")),\n> -- \n> 2.22.0\n> \n"}]}