From: Junio C Hamano <gitster@pobox.com>
To: "D. Ben Knoble" <ben.knoble+github@gmail.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>,
Elijah Newren <newren@gmail.com>,
Lessley Dennington <lessleydennington@gmail.com>
Subject: Re: [PATCH 4/4] builtins: show help on "-h"/"--help-all" with more than 2 arguments left
Date: Sat, 26 Jul 2025 17:28:11 -0700 [thread overview]
Message-ID: <xmqqms8qzdd0.fsf@gitster.g> (raw)
In-Reply-To: <20250726165320.4039-5-ben.knoble+github@gmail.com> (D. Ben Knoble's message of "Sat, 26 Jul 2025 12:53:14 -0400")
"D. Ben Knoble" <ben.knoble+github@gmail.com> writes:
> When asking for short help on a previous command, the user may use their
> shell history to recall a command like
>
> git rebase new-base
>
> Then inserting "-h" after "rebase" doesn't yield the help; make it so.
I doubt this is a good idea for at least two reasons.
* As "git help cli" says, we should be discouraging, not
encouraging peope to say "git rebase new-base -h".
* "git rebase -h new-base" that shows help is probably a bug (think
what should happen with s/rebase/grep/) in the first place.
If anything, we probably should fix the "-h" codepath to
- react and do the short-help only when "-h" is the only command
line option; with argument, it should probably barf, saying "-h
does not take an argument".
- if "-h" resulted in reported an alias, it should stop there.
E.g. "git -c alias.x=ls-files x -h" would currently invoke "git
ls-files -h" after reporting that 'x' is aliased to 'ls-files'.
If the alias is to one of our commands, it is not too risky, but
otherwise we should not assume it is safe to append "-h" to the
underlying command and run it. Imagine
$ git -c alias.x='!echo rm -rf .' x -h
and worse yet, if your alias did not have "echo" in it ;-)???
The only end-user expectation we can safely assume is when they
say,
$ git frotz -h
is that they would get a help on 'frotz' without doing any harm.
If frotz is an alias to some external command, for which we have no
idea what it would do when we run it with "-h" appended to the
command line, the user would be in a lot of pain if the aliased
operation is destructive.
next prev parent reply other threads:[~2025-07-27 0:28 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-26 16:53 [PATCH 0/4] permit -h/--help-all in more scenarios D. Ben Knoble
2025-07-26 16:53 ` [PATCH 1/4] t1517: fixup for ua/t1517-short-help-tests D. Ben Knoble
2025-07-26 21:57 ` Usman Akinyemi
2025-07-28 15:35 ` Junio C Hamano
2025-07-26 16:53 ` [PATCH 2/4] parse-options: name flags passed to usage_with_options_internal D. Ben Knoble
2025-07-28 15:26 ` Junio C Hamano
2025-07-28 18:19 ` Junio C Hamano
2025-07-30 22:05 ` D. Ben Knoble
2025-07-26 16:53 ` [PATCH 3/4] builtin: also setup gently for --help-all D. Ben Knoble
2025-07-28 15:33 ` Junio C Hamano
2025-07-30 22:00 ` D. Ben Knoble
2025-07-26 16:53 ` [PATCH 4/4] builtins: show help on "-h"/"--help-all" with more than 2 arguments left D. Ben Knoble
2025-07-27 0:28 ` Junio C Hamano [this message]
2025-07-30 21:55 ` D. Ben Knoble
2025-08-02 9:23 ` Jeff King
2025-08-02 16:10 ` D. Ben Knoble
2025-08-02 16:28 ` Jeff King
2025-08-02 17:05 ` D. Ben Knoble
2025-08-03 1:26 ` [PATCH v2 0/3] permit -h/--help-all in more scenarios D. Ben Knoble
2025-08-03 16:10 ` [PATCH v3 " D. Ben Knoble
2025-08-04 4:53 ` Junio C Hamano
2025-08-05 1:28 ` D. Ben Knoble
2025-08-03 16:10 ` [PATCH v3 1/3] t1517: fixup for ua/t1517-short-help-tests D. Ben Knoble
2025-08-03 16:41 ` Junio C Hamano
2025-08-03 16:43 ` D. Ben Knoble
2025-08-03 16:10 ` [PATCH v3 2/3] parse-options: refactor flags for usage_with_options_internal D. Ben Knoble
2025-08-03 16:10 ` [PATCH v3 3/3] builtin: also setup gently for --help-all D. Ben Knoble
2025-08-03 1:26 ` [PATCH v2 1/3] t1517: fixup for ua/t1517-short-help-tests D. Ben Knoble
2025-08-03 1:26 ` [PATCH v2 2/3] parse-options: refactor flags for usage_with_options_internal D. Ben Knoble
2025-08-03 1:26 ` [PATCH v2 3/3] builtin: also setup gently for --help-all D. Ben Knoble
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=xmqqms8qzdd0.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=ben.knoble+github@gmail.com \
--cc=git@vger.kernel.org \
--cc=lessleydennington@gmail.com \
--cc=newren@gmail.com \
--cc=peff@peff.net \
/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).