Merge branch 'rs/tighten-alias-help'

"git -c alias.foo=bar foo -h baz" reported "'foo' is aliased to
'bar'" and then went on to run "git foo -h baz", which was
unexpected.  Tighten the rule so that alias expansion is reported
only when "-h" is the sole option.

* rs/tighten-alias-help:
  git: show alias info only with lone -h
maint
Junio C Hamano 2025-08-05 11:53:55 -07:00
commit 2823d928b4
1 changed files with 1 additions and 1 deletions

2
git.c
View File

@ -371,7 +371,7 @@ static int handle_alias(struct strvec *args)
alias_command = args->v[0];
alias_string = alias_lookup(alias_command);
if (alias_string) {
if (args->nr > 1 && !strcmp(args->v[1], "-h"))
if (args->nr == 2 && !strcmp(args->v[1], "-h"))
fprintf_ln(stderr, _("'%s' is aliased to '%s'"),
alias_command, alias_string);
if (alias_string[0] == '!') {