bash: complete 'git diff ...branc<TAB>'
commit1d66ec587e7d903afdf12a81718772a9eadc15a1
authorSZEDER Gábor <szeder@ira.uka.de>
Thu, 10 Mar 2011 18:12:29 +0000 (10 19:12 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 11 Mar 2011 06:38:50 +0000 (10 22:38 -0800)
treed2e5c48fd540c89915f4a3a764af4896cce58281
parent80152b09438f757a2beefd632f13dc0628c11418
bash: complete 'git diff ...branc<TAB>'

While doing a final sanity check before merging a topic Bsomething, it
is a good idea to review what damage Bsomething branch would make, by
running:

    $ git diff ...Bsomething

Unfortunately, our completion script for 'git diff' doesn't offer
anything after '...'.  This is because 'git diff's completion function
invokes __git_complete_file() for non-option arguments to complete the
'<tree>:<path>' extended SHA-1 notation, but this helper function
doesn't support refs after '...' or '..'.  Completion of refs after
'...' or '..' is supported by the __git_complete_revlist() helper
function, but that doesn't support '<tree>:<path>'.

To support both '...<ref>' and '<tree>:<path>' notations for 'git
diff', this patch, instead of adding yet another helper function,
joins __git_complete_file() and __git_complete_revlist() into the new
common function __git_complete_revlist_file().  The old helper
functions __git_complete_file() and __git_complete_revlist() are
changed to be a direct wrapper around the new
__git_complete_revlist_file(), because they might be used in
user-supplied completion scripts and we don't want to break them.

This change will cause some wrong suggestions for other commands which
use __git_complete_file() ('git diff' and friends) or
__git_complete_revlist() ('git log' and friends), e.g. 'git diff
...master:Doc<TAB>' and 'git log master:Doc<TAB>' will complete the
path to 'Documentation/', although neither commands make any sense.
However, both of these were actively wrong to begin with as soon as
the user entered the ':', so there is no real harm done.

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-completion.bash