git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git alias and --help

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 28, 2011, 18:07 UTC
Message-ID
<7v62j9t2gj.fsf@alter.siamese.dyndns.org>
In-Reply-To
<m362j95jv3.fsf@localhost.localdomain>
Jakub Narebski <jnareb@gmail.com> writes:
Show 18 quoted lines
>> What I've often wished is that git's help system would output
>> something like:
>> 
>>    $ git help co
>>    `git co' is aliased to `checkout'
>> 
>>    Here's the help entry for `checkout':
>> 
>>    GIT-CHECKOUT(1)                   Git Manual                   GIT-CHECKOUT(1)
>
> Wouldn't it be more useful to say something like this:
>
>   $ git co --help
>   `git co' is aliased to `checkout'
>  
>   You can see help entry for `checkout' with "git checkout --help"
>
> Then help is only copy'n'paste away.  

Describe your algorithm to come up with the equivalent to the above 'checkout' in this example:

    $ git one --help
    `git one' is aliased to `!sh -c 'git show -s --pretty="format:%h (%s, %ai" "$@" | sed -e "s/ [012][0-9]:[0-5][0-9]:[0-5][0-9] [-+][0-9][0-9][0-9][0-9]$/)/"' -'

If we decide to punt on the '! <cmd>' form, i.e. "take the first token and if it is a git command then do this special thing but otherwise don't make things worse", then you could improve this example:

    $ git lgf --help
    'git lgf' is aliased to 'log --oneline --boundary --first-parent'
with "git log --help", but that is aiming too low for my taste.

If you are redesigning the help system, isn't it a shame that you are discarding other tokens in the alias when giving help? Wouldn't it be wonderful if you extracted the option descriptions for these three options specified and showing only that, for example?

You would need to ensure that the manual pages for all commands share the same structure to make that happen, which goes without saying.

Previous: Jakub NarebskiNext: Miles Bader
Message 12 of 14 in “git alias and --help”
  1. Gelonida NOct 27, 2011
  2. Junio C HamanoOct 27, 2011
  3. Junio C HamanoOct 27, 2011
  4. Gelonida NOct 28, 2011
  5. Miles BaderOct 28, 2011
  6. Junio C HamanoOct 28, 2011
  7. Michael J GruberOct 28, 2011
  8. Gelonida NOct 28, 2011
  9. Jakub NarebskiOct 28, 2011
  10. Gelonida NOct 28, 2011
  11. Jakub NarebskiOct 28, 2011
  12. Junio C HamanoOct 28, 2011
  13. Miles BaderOct 28, 2011
  14. Gelonida NOct 28, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.