René Scharfe <l.s.r@xxxxxx> writes: > Builtin commands show usage information on stdout if called with -h as > their only option, usage.c::show_usage_if_asked() makes sure of that. > > Aliases show alias information on stderr if called with -h as the first > option since a9a60b94cc (git.c: handle_alias: prepend alias info when > first argument is -h, 2018-10-09). This is surprising when using > aliases for commands that take -h as a normal argument among others, > like git grep. > > Tighten the condition and show the alias information only if -h is the > only option given, to be consistent with builtins. Hmph. This certainly is an obvious improvement, especially when the alias does not redirect to our commands, e.g. "git g" is an alias to the system supplied (likely to be GNU) grep: $ git -c alias.g='!grep' g -h frotz *.c which gives us hits in our sources as expected. But without arguments, we get the obvious plus something we may not want to see: $ git -c alias.g='!grep' g -h 'g' is aliased to '!grep' Usage: grep [OPTION]... PATTERNS [FILE]... Try 'grep --help' for more information. I wonder if we should not run the underlying/aliased command after showing the alias expansion? With "grep" we got lucky that a sole "-h" means the same thing as it means to us (i.e. short help), but if it is not one of our commands that would not generally hold. It is risky to blindly run the external command with a single "-h" as an argument. When it redirects to our commands, it is less risky as we aim to make all our commands honor a single "-h" via t0450. $ git -c alias.c=checkout c -h 'c' is aliased to 'checkout' usage: git checkout [<options>] <branch> or: git checkout [<options>] [<branch>] -- <file>... -b <branch> create and checkout a new branch -B <branch> create/reset and checkout a branch ... --pathspec-from-file <file> read pathspec from file --pathspec-file-nul with --pathspec-from-file, pathspec elements are separated with NUL character But then, it may not be such a good idea to pay attention to "do we have extra '-h'?" when alias expands to our commands, e.g. $ git -c alias.c=checkout c -h main usage: git checkout [<options>] <branch> or: git checkout [<options>] [<branch>] -- <file>... -b <branch> create and checkout a new branch -B <branch> create/reset and checkout a branch ... --pathspec-from-file <file> read pathspec from file --pathspec-file-nul with --pathspec-from-file, pathspec elements are separated with NUL character We get the same short-help, without what alias expansion caused this mess, and without any indication that we lost 'main' on the command line. So, I dunno.