mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 12:23:09 +00:00
[git completions] Minor cleanup
This commit is contained in:
parent
bc976a913c
commit
4057cfdce5
1 changed files with 28 additions and 33 deletions
|
@ -171,7 +171,7 @@ function __fish_git_ranges
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
set -l to (set -q both[2]; and echo $both[2])
|
set -l to $both[2]
|
||||||
# Remove description from the from-ref, not the to-ref.
|
# Remove description from the from-ref, not the to-ref.
|
||||||
for from_ref in (__fish_git_refs | string match "$from" | string replace -r \t'.*$' '')
|
for from_ref in (__fish_git_refs | string match "$from" | string replace -r \t'.*$' '')
|
||||||
for to_ref in (__fish_git_refs | string match "*$to*") # if $to is empty, this correctly matches everything
|
for to_ref in (__fish_git_refs | string match "*$to*") # if $to is empty, this correctly matches everything
|
||||||
|
@ -182,38 +182,34 @@ end
|
||||||
|
|
||||||
function __fish_git_needs_command
|
function __fish_git_needs_command
|
||||||
set cmd (commandline -opc)
|
set cmd (commandline -opc)
|
||||||
if [ (count $cmd) -eq 1 ]
|
set -l skip_next 1
|
||||||
return 0
|
set -q cmd[2]; or return 0
|
||||||
else
|
# Skip first word because it's "git" or a wrapper
|
||||||
set -l skip_next 1
|
for c in $cmd[2..-1]
|
||||||
# Skip first word because it's "git" or a wrapper
|
test $skip_next -eq 0
|
||||||
for c in $cmd[2..-1]
|
and set skip_next 1
|
||||||
test $skip_next -eq 0
|
and continue
|
||||||
and set skip_next 1
|
# git can only take a few options before a command, these are the ones mentioned in the "git" man page
|
||||||
and continue
|
# e.g. `git --follow log` is wrong, `git --help log` is okay (and `git --help log $branch` is superfluous but works)
|
||||||
# git can only take a few options before a command, these are the ones mentioned in the "git" man page
|
# In case any other option is used before a command, we'll fail, but that's okay since it's invalid anyway
|
||||||
# e.g. `git --follow log` is wrong, `git --help log` is okay (and `git --help log $branch` is superfluous but works)
|
switch $c
|
||||||
# In case any other option is used before a command, we'll fail, but that's okay since it's invalid anyway
|
# General options that can still take a command
|
||||||
switch $c
|
case "--help" "-p" "--paginate" "--no-pager" "--bare" "--no-replace-objects" --{literal,glob,noglob,icase}-pathspecs --{exec-path,git-dir,work-tree,namespace}"=*"
|
||||||
# General options that can still take a command
|
continue
|
||||||
case "--help" "-p" "--paginate" "--no-pager" "--bare" "--no-replace-objects" --{literal,glob,noglob,icase}-pathspecs --{exec-path,git-dir,work-tree,namespace}"=*"
|
# General options with an argument we need to skip. The option=value versions have already been handled above
|
||||||
continue
|
case --{exec-path,git-dir,work-tree,namespace}
|
||||||
# General options with an argument we need to skip. The option=value versions have already been handled above
|
set skip_next 0
|
||||||
case --{exec-path,git-dir,work-tree,namespace}
|
continue
|
||||||
set skip_next 0
|
# General options that cause git to do something and exit - these behave like commands and everything after them is ignored
|
||||||
continue
|
case "--version" --{html,man,info}-path
|
||||||
# General options that cause git to do something and exit - these behave like commands and everything after them is ignored
|
return 1
|
||||||
case "--version" --{html,man,info}-path
|
# We assume that any other token that's not an argument to a general option is a command
|
||||||
return 1
|
case "*"
|
||||||
# We assume that any other token that's not an argument to a general option is a command
|
echo $c
|
||||||
case "*"
|
return 1
|
||||||
echo $c
|
|
||||||
return 1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return 0
|
|
||||||
end
|
end
|
||||||
return 1
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -906,8 +902,7 @@ complete -f -c git -n '__fish_git_using_command tag' -s v -l verify -d 'Verify s
|
||||||
complete -f -c git -n '__fish_git_using_command tag' -s f -l force -d 'Force overwriting exising tag'
|
complete -f -c git -n '__fish_git_using_command tag' -s f -l force -d 'Force overwriting exising tag'
|
||||||
complete -f -c git -n '__fish_git_using_command tag' -s l -l list -d 'List tags'
|
complete -f -c git -n '__fish_git_using_command tag' -s l -l list -d 'List tags'
|
||||||
complete -f -c git -n '__fish_git_using_command tag' -l contains -xa '(__fish_git_commits)' -d 'List tags that contain a commit'
|
complete -f -c git -n '__fish_git_using_command tag' -l contains -xa '(__fish_git_commits)' -d 'List tags that contain a commit'
|
||||||
complete -f -c git -n '__fish_git_using_command tag; and __fish_contains_opt -s d' -a '(__fish_git_tags)' -d 'Tag'
|
complete -f -c git -n '__fish_git_using_command tag; and __fish_contains_opt -s d delete -s v verify' -a '(__fish_git_tags)' -d 'Tag'
|
||||||
complete -f -c git -n '__fish_git_using_command tag; and __fish_contains_opt -s v' -a '(__fish_git_tags)' -d 'Tag'
|
|
||||||
# TODO options
|
# TODO options
|
||||||
|
|
||||||
### stash
|
### stash
|
||||||
|
|
Loading…
Reference in a new issue