Teach git completion about difftool. Change __fish_git_ranges to output branches as designed.

This commit is contained in:
ridiculousfish 2013-04-04 21:36:13 -07:00
parent 5ed5d637b8
commit 5cebd3abf7

View File

@ -18,13 +18,13 @@ function __fish_git_remotes
end end
function __fish_git_ranges function __fish_git_ranges
set from (commandline -ot | perl -ne 'my @parts = split(/\.\./); print $parts[0]') set -l from (commandline -ot | perl -ne 'if (index($_, "..") > 0) { my @parts = split(/\.\./); print $parts[0]; }')
set to (commandline -ot | perl -ne 'my @parts = split(/\.\./); print $parts[1]') if test -z "$from"
if [ "$from" = "" ]
__fish_git_branches __fish_git_branches
return 0 return 0
end end
set -l to (commandline -ot | perl -ne 'if (index($_, "..") > 0) { my @parts = split(/\.\./); print $parts[1]; }')
for from_ref in (__fish_git_heads | grep -e "$from") for from_ref in (__fish_git_heads | grep -e "$from")
for to_ref in (__fish_git_heads | grep -e "$to") for to_ref in (__fish_git_heads | grep -e "$to")
printf "%s..%s\n" $from_ref $to_ref printf "%s..%s\n" $from_ref $to_ref
@ -146,6 +146,13 @@ complete -c git -n '__fish_git_using_command diff' -a '(__fish_git_ranges)' -d '
complete -c git -n '__fish_git_using_command diff' -l cached -d 'Show diff of changes in the index' complete -c git -n '__fish_git_using_command diff' -l cached -d 'Show diff of changes in the index'
# TODO options # TODO options
### difftool
complete -c git -n '__fish_git_needs_command' -a difftool -d 'Open diffs in a visual tool'
complete -c git -n '__fish_git_using_command difftool' -a '(__fish_git_ranges)' -d 'Branch'
complete -c git -n '__fish_git_using_command difftool' -l cached -d 'Visually show diff of changes in the index'
# TODO options
### grep ### grep
complete -c git -n '__fish_git_needs_command' -a grep -d 'Print lines matching a pattern' complete -c git -n '__fish_git_needs_command' -a grep -d 'Print lines matching a pattern'
# TODO options # TODO options