KEMBAR78
Comparing d1f96fd84d...912104770d · git/git · GitHub
Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: git/git
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d1f96fd84d
Choose a base ref
...
head repository: git/git
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 912104770d
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Oct 11, 2018

  1. help: redirect to aliased commands for "git cmd --help"

    As discussed in the thread for v1 of this patch [1] [2], this changes the
    rules for "git foo --help" when foo is an alias.
    
    (1) When invoked as "git help foo", we continue to print the "foo is
    aliased to bar" message and nothing else.
    
    (2) If foo is an alias for a shell command, print "foo is aliased to
    !bar" as usual.
    
    (3) Otherwise, print "foo is aliased to bar" to the standard error
    stream, and then break the alias string into words and pretend as if
    "git word[0] --help" were called.
    
    Getting the man page for git-cherry-pick directly with "git cp --help"
    is consistent with "--help" generally providing more comprehensive help
    than "-h". Printing the alias definition to stderr means that in certain
    cases (e.g. if help.format=web or if the pager uses an alternate screen
    and does not clear the terminal), one has
    
    'cp' is aliased to 'cherry-pick -n'
    
    above the prompt when one returns to the terminal/quits the pager, which
    is a useful reminder that using 'cp' has some flag implicitly set. There
    are cases where this information vanishes or gets scrolled
    away, but being printed to stderr, it should never hurt.
    
    [1] https://public-inbox.org/git/20180926102636.30691-1-rv@rasmusvillemoes.dk/
    [2] https://public-inbox.org/git/20180926184914.GC30680@sigill.intra.peff.net/
    
    Signed-off-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    Villemoes authored and gitster committed Oct 11, 2018
    Configuration menu
    Copy the full SHA
    e6e76ba View commit details
    Browse the repository at this point in the history
  2. git.c: handle_alias: prepend alias info when first argument is -h

    Most git commands respond to -h anywhere in the command line, or at
    least as a first and lone argument, by printing the usage
    information. For aliases, we can provide a little more information that
    might be useful in interpreting/understanding the following output by
    prepending a line telling that the command is an alias, and for what.
    
    When one invokes a simple alias, such as "cp = cherry-pick"
    with -h, this results in
    
    $ git cp -h
    'cp' is aliased to 'cherry-pick'
    usage: git cherry-pick [<options>] <commit-ish>...
    ...
    
    When the alias consists of more than one word, this provides the
    additional benefit of informing the user which options are implicit in
    using the alias, e.g. with "cp = cherry-pick -n":
    
    $ git cp -h
    'cp' is aliased to 'cherry-pick -n'
    usage: git cherry-pick [<options>] <commit-ish>...
    ...
    
    For shell commands, we cannot know how it responds to -h, but printing
    this line to stderr should not hurt, and can help in figuring out what
    is happening in a case like
    
    $ git sc -h
    'sc' is aliased to '!somecommand'
    somecommand: invalid option '-h'
    
    Suggested-by: Jeff King <peff@peff.net>
    Signed-off-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    Villemoes authored and gitster committed Oct 11, 2018
    1 Configuration menu
    Copy the full SHA
    a9a60b9 View commit details
    Browse the repository at this point in the history
  3. git-help.txt: document "git help cmd" vs "git cmd --help" for aliases

    This documents the existing behaviour of "git help cmd" when cmd is an
    alias, as well as providing a hint to use the "git cmd --help" form to
    be taken directly to the man page for the aliased command.
    
    Signed-off-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    Villemoes authored and gitster committed Oct 11, 2018
    Configuration menu
    Copy the full SHA
    9121047 View commit details
    Browse the repository at this point in the history
Loading