mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-21 13:48:03 +08:00
git completion: Rewrite __fish_git_ranges with the string stuff
Cuts down on perl. Also complete heads (i.e. tags and branches) always.
This commit is contained in:
parent
4fcda28d9b
commit
4f12821ca8
@ -37,18 +37,21 @@ function __fish_git_add_files
|
||||
end
|
||||
|
||||
function __fish_git_ranges
|
||||
set -l from (commandline -ot | perl -ne 'if (index($_, "..") > 0) { my @parts = split(/\.\./); print $parts[0]; }')
|
||||
if test -z "$from"
|
||||
__fish_git_branches
|
||||
return 0
|
||||
end
|
||||
set -l both (commandline -ot | string split "..")
|
||||
set -l from $both[1]
|
||||
# If we didn't need to split (or there's nothing _to_ split), complete only the first part
|
||||
# Note that status here is from `string split` because `set` doesn't alter it
|
||||
if test -z "$from" -o $status -gt 0
|
||||
__fish_git_heads
|
||||
return 0
|
||||
end
|
||||
|
||||
set -l to (commandline -ot | perl -ne 'if (index($_, "..") > 0) { my @parts = split(/\.\./); print $parts[1]; }')
|
||||
for from_ref in (__fish_git_heads | __fish_sgrep -e "$from")
|
||||
for to_ref in (__fish_git_heads | __fish_sgrep -e "$to")
|
||||
printf "%s..%s\n" $from_ref $to_ref
|
||||
end
|
||||
end
|
||||
set -l to (set -q both[2]; and echo $both[2])
|
||||
for from_ref in (__fish_git_heads | string match "$from")
|
||||
for to_ref in (__fish_git_heads | string match "*$to*") # if $to is empty, this correctly matches everything
|
||||
printf "%s..%s\n" $from_ref $to_ref
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function __fish_git_needs_command
|
||||
|
Loading…
x
Reference in New Issue
Block a user