diff mbox series

[1/3] show-ref: remove unused custom handling of -h

Message ID patch-1.3-c79a3907a27-20210924T164820Z-avarab@gmail.com (mailing list archive)
State New, archived
Headers show
Series show-ref, ls-remote, grep: fix -h handling | expand

Commit Message

Ævar Arnfjörð Bjarmason Sept. 24, 2021, 4:51 p.m. UTC
Since b92891f9783 (parseopt: add PARSE_OPT_NO_INTERNAL_HELP,
2009-03-08) parse_options() has handled "-h" unless told not to, so
when show-ref was migrated to parse_options() in
69932bc6117 (show-ref: migrate to parse-options, 2009-06-20) the
custom "-h" handling that was retained did nothing.

The option was then hidden in e62b3935056 (Show usage string for 'git
show-ref -h', 2009-11-09), but that OPT_BOOLEAN didn't do
anything. Let's just remove this dead code.

Reported-by: Ignacy Gawedzki <ignacy.gawedzki@green-communications.fr>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/show-ref.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Junio C Hamano Sept. 24, 2021, 7:24 p.m. UTC | #1
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> Since b92891f9783 (parseopt: add PARSE_OPT_NO_INTERNAL_HELP,
> 2009-03-08) parse_options() has handled "-h" unless told not to, so
> when show-ref was migrated to parse_options() in
> 69932bc6117 (show-ref: migrate to parse-options, 2009-06-20) the
> custom "-h" handling that was retained did nothing.
>
> The option was then hidden in e62b3935056 (Show usage string for 'git
> show-ref -h', 2009-11-09), but that OPT_BOOLEAN didn't do
> anything. Let's just remove this dead code.
>
> Reported-by: Ignacy Gawedzki <ignacy.gawedzki@green-communications.fr>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  builtin/show-ref.c | 2 --
>  1 file changed, 2 deletions(-)

While this is a fine no-op, I am not sure this "fixes" complaint
in Ignacy's report.  "git show-ref -h" would (and should) show the
short-help, no?
René Scharfe Sept. 24, 2021, 8:53 p.m. UTC | #2
Am 24.09.21 um 21:24 schrieb Junio C Hamano:
> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
>
>> Since b92891f9783 (parseopt: add PARSE_OPT_NO_INTERNAL_HELP,
>> 2009-03-08) parse_options() has handled "-h" unless told not to, so
>> when show-ref was migrated to parse_options() in
>> 69932bc6117 (show-ref: migrate to parse-options, 2009-06-20) the
>> custom "-h" handling that was retained did nothing.
>>
>> The option was then hidden in e62b3935056 (Show usage string for 'git
>> show-ref -h', 2009-11-09), but that OPT_BOOLEAN didn't do
>> anything. Let's just remove this dead code.
>>
>> Reported-by: Ignacy Gawedzki <ignacy.gawedzki@green-communications.fr>
>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
>> ---
>>  builtin/show-ref.c | 2 --
>>  1 file changed, 2 deletions(-)
>
> While this is a fine no-op, I am not sure this "fixes" complaint
> in Ignacy's report.  "git show-ref -h" would (and should) show the
> short-help, no?
>

It would, but -h is not a no-op without this patch.  The option is
equivalent to --heads as long as it's not the only argument.  E.g. it
has an effect in "git show-ref -h HEA." or "git show-ref -hh".

René
Junio C Hamano Sept. 24, 2021, 9:21 p.m. UTC | #3
René Scharfe <l.s.r@web.de> writes:

> Am 24.09.21 um 21:24 schrieb Junio C Hamano:
>> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
>>
>>> Since b92891f9783 (parseopt: add PARSE_OPT_NO_INTERNAL_HELP,
>>> 2009-03-08) parse_options() has handled "-h" unless told not to, so
>>> when show-ref was migrated to parse_options() in
>>> 69932bc6117 (show-ref: migrate to parse-options, 2009-06-20) the
>>> custom "-h" handling that was retained did nothing.
>>>
>>> The option was then hidden in e62b3935056 (Show usage string for 'git
>>> show-ref -h', 2009-11-09), but that OPT_BOOLEAN didn't do
>>> anything. Let's just remove this dead code.
>>>
>>> Reported-by: Ignacy Gawedzki <ignacy.gawedzki@green-communications.fr>
>>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
>>> ---
>>>  builtin/show-ref.c | 2 --
>>>  1 file changed, 2 deletions(-)
>>
>> While this is a fine no-op, I am not sure this "fixes" complaint
>> in Ignacy's report.  "git show-ref -h" would (and should) show the
>> short-help, no?
>>
>
> It would, but -h is not a no-op without this patch.  The option is
> equivalent to --heads as long as it's not the only argument.  E.g. it
> has an effect in "git show-ref -h HEA." or "git show-ref -hh".

Ah, so this actively breaks the command?  Yeah, thanks---I smelled
something fishy in the change.
diff mbox series

Patch

diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 7f8a5332f83..8cefb663282 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -163,8 +163,6 @@  static const struct option show_ref_options[] = {
 	OPT_BOOL(0, "heads", &heads_only, N_("only show heads (can be combined with tags)")),
 	OPT_BOOL(0, "verify", &verify, N_("stricter reference checking, "
 		    "requires exact ref path")),
-	OPT_HIDDEN_BOOL('h', NULL, &show_head,
-			N_("show the HEAD reference, even if it would be filtered out")),
 	OPT_BOOL(0, "head", &show_head,
 	  N_("show the HEAD reference, even if it would be filtered out")),
 	OPT_BOOL('d', "dereference", &deref_tags,