From: Junio C Hamano <gitster@pobox.com>
To: Ignacy Gawedzki <ignacy.gawedzki@green-communications.fr>
Cc: git@vger.kernel.org
Subject: Re: Wrong option -h in grep, ls-remote, and show-ref.
Date: Fri, 24 Sep 2021 11:12:56 -0700 [thread overview]
Message-ID: <xmqqilypvo47.fsf@gitster.g> (raw)
In-Reply-To: <20210924141920.ezfpyf4uutob2h5z@zenon.in.qult.net> (Ignacy Gawedzki's message of "Fri, 24 Sep 2021 16:19:20 +0200")
Ignacy Gawedzki <ignacy.gawedzki@green-communications.fr> writes:
> What did you do before the bug happened? (Steps to reproduce your issue)
>
> git ls-remote -h
>
> What did you expect to happen? (Expected behavior)
>
> The same as git ls-remote --heads.
>
> What happened instead? (Actual behavior)
>
> Displayed the git ls-remote usage.
Thanks for a report, but this is very much working as intended.
There may be some subcommands that assign their own meaning to "-h"
for historical reasons (like "ls-remote -h origin"), or for external
reasons (like "grep -h -e pattern"), but most newbies expect a short
help out of "-h" uniformly across subcommands.
Fortunately, "-h" alone would not make any sense for "grep" (you
need a pattern) and you do not need to use "-h" for "ls-remote" [*].
We prioritized to help newbies by consistently giving a short help
across subcommands, over letting "git grep -h" to complain "you need
to give me a pattern", like so:
$ git ls-remote --heads
fatal: No remote configured to list refs from.
$ git grep
fatal: no pattern given
$ git grep -h
usage: git grep [<options>] [-e] <pattern> [<rev>...] [[--] <path>...]
--cached search in index instead of in the work tree
...
$ git ls-remote -h
usage: git ls-remote [--heads] [--tags] [--refs] [--upload-pack=<exec>]
[-q | --quiet] [--exit-code] [--get-url]
...
HTH.
[Footnote]
* It is not end-user facing Porcelain, but is meant for scripting,
and you can afford to write "--heads". Besides, "-h" acts as
"--heads" in "git ls-remote -h origin" or "git ls-remote -h -q"
just fine. Only the "-h and nothing else is given" case is
sacrificed to help newbies in the case of this subcommand.
prev parent reply other threads:[~2021-09-24 18:13 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-24 14:19 Wrong option -h in grep, ls-remote, and show-ref Ignacy Gawedzki
2021-09-24 16:51 ` [PATCH 0/3] show-ref, ls-remote, grep: fix -h handling Ævar Arnfjörð Bjarmason
2021-09-24 16:51 ` [PATCH 1/3] show-ref: remove unused custom handling of -h Ævar Arnfjörð Bjarmason
2021-09-24 19:24 ` Junio C Hamano
2021-09-24 20:53 ` René Scharfe
2021-09-24 21:21 ` Junio C Hamano
2021-09-24 16:51 ` [PATCH 2/3] ls-remote: remove documentation for custom -h option Ævar Arnfjörð Bjarmason
2021-09-24 17:11 ` SZEDER Gábor
2021-09-24 17:54 ` Jeff King
2021-09-24 18:17 ` Junio C Hamano
2021-09-24 16:51 ` [PATCH 3/3] grep: pass PARSE_OPT_NO_INTERNAL_HELP, fix odd -h handling Ævar Arnfjörð Bjarmason
2021-09-24 18:12 ` Junio C Hamano [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqilypvo47.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=ignacy.gawedzki@green-communications.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).