2009-02-04 18:58:26 +00:00
# fish completion for git
2013-04-14 07:46:40 +00:00
# Use 'command git' to avoid interactions for aliases from git to (e.g.) hub
2009-02-04 18:58:26 +00:00
2015-12-18 16:07:43 +00:00
function __fish_git_commits
2016-05-11 13:06:10 +00:00
# Complete commits with their subject line as the description
# This allows filtering by subject with the new pager!
# Because even subject lines can be quite long,
2016-07-09 17:07:59 +00:00
# trim them (abbrev'd hash+tab+subject) to 73 characters
2016-06-04 10:26:06 +00:00
command git log --pretty = tformat:"%h" \t "%s" --all ^ /dev/null \
2016-07-09 17:07:59 +00:00
| string replace -r '(.{73}).+' '$1…'
2015-12-18 16:07:43 +00:00
end
2009-02-04 18:58:26 +00:00
function __fish_git_branches
2016-05-11 13:06:10 +00:00
command git branch --no-color -a $argv ^ /dev/null | string match -r -v ' -> ' | string trim -c "* " | string replace -r "^remotes/" ""
2015-09-22 14:46:43 +00:00
end
function __fish_git_unique_remote_branches
2016-05-11 13:06:10 +00:00
# Allow all remote branches with one remote without the remote part
# This is useful for `git checkout` to automatically create a remote-tracking branch
command git branch --no-color -a $argv ^ /dev/null | string match -r -v ' -> ' | string trim -c "* " | string replace -r "^remotes/[^/]*/" "" | sort | uniq -u
2009-02-04 18:58:26 +00:00
end
function __fish_git_tags
2016-05-11 13:06:10 +00:00
command git tag ^ /dev/null
2009-02-04 18:58:26 +00:00
end
2016-07-13 09:31:59 +00:00
function __fish_git_dir
command git rev-parse --git-dir ^ /dev/null
end
function __fish_git_heads
set -l gitdir ( __fish_git_dir )
for head in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD
if test -f $gitdir /$head
echo $head
end
end
end
2016-07-13 09:30:10 +00:00
function __fish_git_refs
2016-05-11 13:06:10 +00:00
__fish_git_branches
__fish_git_tags
2016-07-13 09:31:59 +00:00
__fish_git_heads
2009-02-04 18:58:26 +00:00
end
function __fish_git_remotes
2016-05-11 13:06:10 +00:00
command git remote ^ /dev/null
2009-02-04 18:58:26 +00:00
end
2013-05-24 12:01:47 +00:00
function __fish_git_modified_files
2016-05-11 13:06:10 +00:00
# git diff --name-only hands us filenames relative to the git toplevel
2016-06-04 10:26:06 +00:00
set -l root ( command git rev-parse --show-toplevel ^ /dev/null)
2016-05-11 13:06:10 +00:00
# Print files from the current $PWD as-is, prepend all others with ":/" (relative to toplevel in git-speak)
# This is a bit simplistic but finding the lowest common directory and then replacing everything else in $PWD with ".." is a bit annoying
string replace -- " $PWD / " "" " $root / " ( command git diff --name-only ^ /dev/null) | string replace " $root / " ":/"
2013-10-31 20:23:53 +00:00
end
2015-09-04 17:54:45 +00:00
function __fish_git_staged_files
2016-06-04 10:26:06 +00:00
set -l root ( command git rev-parse --show-toplevel ^ /dev/null)
2016-05-11 13:06:10 +00:00
string replace -- " $PWD / " "" " $root / " ( command git diff --staged --name-only ^ /dev/null) | string replace " $root / " ":/"
2015-09-04 17:54:45 +00:00
end
2013-10-31 20:23:53 +00:00
function __fish_git_add_files
2016-06-04 10:26:06 +00:00
set -l root ( command git rev-parse --show-toplevel ^ /dev/null)
2016-05-11 13:06:10 +00:00
string replace -- " $PWD / " "" " $root / " ( command git -C $root ls-files -mo --exclude-standard ^ /dev/null) | string replace " $root / " ":/"
2013-05-24 12:01:47 +00:00
end
2009-02-04 18:58:26 +00:00
function __fish_git_ranges
2016-05-11 13:06:10 +00:00
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
2016-07-13 09:30:10 +00:00
__fish_git_refs
2016-05-11 13:06:10 +00:00
return 0
end
set -l to ( set -q both [ 2 ] ; and echo $both [ 2 ] )
2016-07-13 09:30:10 +00:00
for from_ref in ( __fish_git_refs | string match " $from " )
for to_ref in ( __fish_git_refs | string match " * $to * " ) # if $to is empty, this correctly matches everything
2016-05-11 13:06:10 +00:00
printf "%s..%s\n" $from_ref $to_ref
end
end
2009-02-04 18:58:26 +00:00
end
function __fish_git_needs_command
2016-05-11 13:06:10 +00:00
set cmd ( commandline -opc )
if [ ( count $cmd ) - eq 1 ]
return 0
else
set -l skip_next 1
# Skip first word because it's "git" or a wrapper
for c in $cmd [ 2 .. - 1 ]
test $skip_next -eq 0
and set skip_next 1
and continue
# git can only take a few options before a command, these are the ones mentioned in the "git" man page
# e.g. `git --follow log` is wrong, `git --help log` is okay (and `git --help log $branch` is superfluous but works)
# In case any other option is used before a command, we'll fail, but that's okay since it's invalid anyway
switch $c
# General options that can still take a command
case "--help" "-p" "--paginate" "--no-pager" "--bare" "--no-replace-objects" --{literal ,glob,noglob,icase} -pathspecs --{exec-path ,git-dir,work-tree,namespace} "=*"
continue
# General options with an argument we need to skip. The option=value versions have already been handled above
case --{exec-path ,git-dir,work-tree,namespace}
set skip_next 0
continue
# General options that cause git to do something and exit - these behave like commands and everything after them is ignored
case "--version" --{html ,man,info} -path
return 1
# We assume that any other token that's not an argument to a general option is a command
case "*"
echo $c
return 1
end
end
return 0
end
return 1
2009-02-04 18:58:26 +00:00
end
function __fish_git_using_command
2016-05-11 12:56:36 +00:00
set -l cmd ( __fish_git_needs_command )
2016-05-11 13:06:10 +00:00
test -z " $cmd "
and return 1
contains -- $cmd $argv
and return 0
2013-01-31 07:59:52 +00:00
# aliased command
2016-05-11 12:56:36 +00:00
set -l aliased ( command git config --get " alias. $cmd " ^ /dev/null | string split " " )
2016-05-11 13:06:10 +00:00
contains -- " $aliased [1] " $argv
and return 0
2016-05-11 12:56:36 +00:00
return 1
2009-02-04 18:58:26 +00:00
end
2014-02-16 13:54:28 +00:00
function __fish_git_stash_using_command
2016-05-11 12:57:56 +00:00
set cmd ( commandline -opc )
2016-05-11 13:06:10 +00:00
__fish_git_using_command stash
or return 2
2016-05-11 12:57:56 +00:00
# The word after the stash command _must_ be the subcommand
set cmd $cmd [ ( contains - i - - "stash" $cmd ) .. - 1 ]
set -e cmd [ 1 ]
2016-05-11 13:06:10 +00:00
set -q cmd [ 1 ]
or return 1
contains -- $cmd [ 1 ] $argv
and return 0
2016-05-11 12:57:56 +00:00
return 1
2014-02-16 13:54:28 +00:00
end
function __fish_git_stash_not_using_subcommand
2016-05-11 12:57:56 +00:00
set cmd ( commandline -opc )
2016-05-11 13:06:10 +00:00
__fish_git_using_command stash
or return 2
2016-05-11 12:57:56 +00:00
set cmd $cmd [ ( contains - i - - "stash" $cmd ) .. - 1 ]
2016-05-11 13:06:10 +00:00
set -q cmd [ 2 ]
and return 1
2016-05-11 12:57:56 +00:00
return 0
2014-02-16 13:54:28 +00:00
end
function __fish_git_complete_stashes
2016-05-11 12:54:17 +00:00
command git stash list --format = %gd:%gs ^ /dev/null | string replace ":" \t
2014-02-16 13:54:28 +00:00
end
2014-09-20 01:35:32 +00:00
function __fish_git_aliases
2015-06-21 16:33:08 +00:00
command git config -z --get-regexp '^alias\.' ^ /dev/null | while read -lz key value
2014-09-22 02:54:42 +00:00
begin
2016-05-11 12:54:17 +00:00
set -l name ( string replace -r '^.*\.' '' -- $key )
2015-09-22 18:25:14 +00:00
printf "%s\t%s\n" $name " Alias for $value "
2014-09-22 02:54:42 +00:00
end
end
2014-09-20 01:35:32 +00:00
end
2014-09-20 02:00:29 +00:00
function __fish_git_custom_commands
# complete all commands starting with git-
# however, a few builtin commands are placed into $PATH by git because
# they're used by the ssh transport. We could filter them out by checking
# if any of these completion results match the name of the builtin git commands,
# but it's simpler just to blacklist these names. They're unlikely to change,
# and the failure mode is we accidentally complete a plumbing command.
2016-05-11 13:06:10 +00:00
for name in ( string replace -r "^.*/git-([^/]*)" '$1' $PATH /git-*)
2014-09-20 02:00:29 +00:00
switch $name
case cvsserver receive-pack shell upload-archive upload-pack
# skip these
case \*
echo $name
end
end
end
2016-04-30 14:21:41 +00:00
# Suggest branches for the specified remote - returns 1 if no known remote is specified
function __fish_git_branch_for_remote
2016-05-11 13:06:10 +00:00
set -l remotes ( __fish_git_remotes )
set -l remote
set -l cmd ( commandline -opc )
for r in $remotes
if contains -- $r $cmd
set remote $r
break
end
end
set -q remote [ 1 ]
or return 1
__fish_git_branches | string match -- " $remote /* " | string replace -- " $remote / " ''
2016-04-30 14:21:41 +00:00
end
2016-05-11 13:01:24 +00:00
# Return 0 if the current token is a possible commit-hash with at least 3 characters
function __fish_git_possible_commithash
2016-05-11 13:06:10 +00:00
set -q argv [ 1 ]
and set -l token $argv [ 1 ]
2016-05-11 13:01:24 +00:00
or set -l token ( commandline -ct )
if string match -qr '^[0-9a-fA-F]{3,}$' -- $token
return 0
end
return 1
end
2016-05-13 14:18:29 +00:00
function __fish_git_reflog
2016-06-04 10:26:06 +00:00
command git reflog ^ /dev/null | string replace -r '[0-9a-f]* (.+@\{[0-9]+\}): (.*)$' '$1\t$2'
2016-05-13 14:18:29 +00:00
end
2009-02-04 18:58:26 +00:00
# general options
2016-04-29 10:42:15 +00:00
complete -f -c git -l help -d 'Display the manual of a git command'
2016-06-04 10:27:06 +00:00
complete -f -c git -n '__fish_git_needs_command' -l version -d 'Display version'
complete -x -c git -n '__fish_git_needs_command' -s C -a '(__fish_complete_directories)' -d 'Run as if git was started in this directory'
complete -x -c git -n '__fish_git_needs_command' -s c -a '(command git config -l ^/dev/null | string replace = \t)' -d 'Set a configuration option'
complete -x -c git -n '__fish_git_needs_command' -l exec -path -a '(__fish_git_complete_directories)' -d 'Get or set the path to the git programs'
complete -f -c git -n '__fish_git_needs_command' -l html-path -d 'Print the path to the html documentation'
complete -f -c git -n '__fish_git_needs_command' -l man-path -d 'Print the path to the man documentation'
complete -f -c git -n '__fish_git_needs_command' -l info-path -d 'Print the path to the info documentation'
complete -f -c git -n '__fish_git_needs_command' -s p -l paginate -d 'Pipe output into a pager'
complete -f -c git -n '__fish_git_needs_command' -l no-pager -d 'Do not pipe output into a pager'
complete -f -c git -n '__fish_git_needs_command' -l git-dir -d 'Set the path to the repository'
complete -f -c git -n '__fish_git_needs_command' -l work-tree -d 'Set the path to the working tree'
complete -f -c git -n '__fish_git_needs_command' -l namespace -d 'Set the namespace'
complete -f -c git -n '__fish_git_needs_command' -l bare -d 'Treat the repository as bare'
complete -f -c git -n '__fish_git_needs_command' -l no-replace-objects -d 'Do not use replacement refs to replace git objects'
complete -f -c git -n '__fish_git_needs_command' -l literal-pathspecs -d 'Treat pathspecs literally'
complete -f -c git -n '__fish_git_needs_command' -l glob-pathspecs -d 'Treat pathspecs as globs'
complete -f -c git -n '__fish_git_needs_command' -l noglob-pathspecs -d "Don't treat pathspecs as globs"
complete -f -c git -n '__fish_git_needs_command' -l icase-pathspecs -d 'Match pathspecs case-insensitively'
2016-05-29 11:58:26 +00:00
# Options shared between multiple commands
2016-05-11 12:53:16 +00:00
complete -f -c git -n '__fish_git_using_command log show diff-tree rev-list' -l pretty -a 'oneline short medium full fuller email raw format:'
2009-02-04 18:58:26 +00:00
#### fetch
complete -f -c git -n '__fish_git_needs_command' -a fetch -d 'Download objects and refs from another repository'
2016-04-30 14:21:41 +00:00
# Suggest "repository", then "refspec" - this also applies to e.g. push/pull
complete -f -c git -n '__fish_git_using_command fetch; and not __fish_git_branch_for_remote' -a '(__fish_git_remotes)' -d 'Remote'
complete -f -c git -n '__fish_git_using_command fetch; and __fish_git_branch_for_remote' -a '(__fish_git_branch_for_remote)' -d 'Branch'
2009-02-04 18:58:26 +00:00
complete -f -c git -n '__fish_git_using_command fetch' -s q -l quiet -d 'Be quiet'
complete -f -c git -n '__fish_git_using_command fetch' -s v -l verbose -d 'Be verbose'
complete -f -c git -n '__fish_git_using_command fetch' -s a -l append -d 'Append ref names and object names'
# TODO --upload-pack
complete -f -c git -n '__fish_git_using_command fetch' -s f -l force -d 'Force update of local branches'
# TODO other options
2015-05-20 07:13:42 +00:00
#### filter-branch
complete -f -c git -n '__fish_git_needs_command' -a filter-branch -d 'Rewrite branches'
complete -f -c git -n '__fish_git_using_command filter-branch' -l env-filter -d 'This filter may be used if you only need to modify the environment'
complete -f -c git -n '__fish_git_using_command filter-branch' -l tree-filter -d 'This is the filter for rewriting the tree and its contents.'
complete -f -c git -n '__fish_git_using_command filter-branch' -l index-filter -d 'This is the filter for rewriting the index.'
complete -f -c git -n '__fish_git_using_command filter-branch' -l parent-filter -d 'This is the filter for rewriting the commit\\(cqs parent list.'
complete -f -c git -n '__fish_git_using_command filter-branch' -l msg-filter -d 'This is the filter for rewriting the commit messages.'
complete -f -c git -n '__fish_git_using_command filter-branch' -l commit-filter -d 'This is the filter for performing the commit.'
complete -f -c git -n '__fish_git_using_command filter-branch' -l tag-name-filter -d 'This is the filter for rewriting tag names.'
complete -f -c git -n '__fish_git_using_command filter-branch' -l subdirectory-filter -d 'Only look at the history which touches the given subdirectory.'
complete -f -c git -n '__fish_git_using_command filter-branch' -l prune-empty -d 'Ignore empty commits generated by filters'
complete -f -c git -n '__fish_git_using_command filter-branch' -l original -d 'Use this option to set the namespace where the original commits will be stored'
complete -r -c git -n '__fish_git_using_command filter-branch' -s d -d 'Use this option to set the path to the temporary directory used for rewriting'
complete -c git -n '__fish_git_using_command filter-branch' -s f -l force -d 'Force filter branch to start even w/ refs in refs/original or existing temp directory'
2009-02-04 18:58:26 +00:00
### remote
2015-11-29 21:14:11 +00:00
set -l remotecommands add rm show prune update rename set-head set-url set-branches
2009-02-04 18:58:26 +00:00
complete -f -c git -n '__fish_git_needs_command' -a remote -d 'Manage set of tracked repositories'
complete -f -c git -n '__fish_git_using_command remote' -a '(__fish_git_remotes)'
2015-11-29 21:14:11 +00:00
complete -f -c git -n " __fish_git_using_command remote; and not __fish_seen_subcommand_from $remotecommands " -s v -l verbose -d 'Be verbose'
complete -f -c git -n " __fish_git_using_command remote; and not __fish_seen_subcommand_from $remotecommands " -a add -d 'Adds a new remote'
complete -f -c git -n " __fish_git_using_command remote; and not __fish_seen_subcommand_from $remotecommands " -a rm -d 'Removes a remote'
complete -f -c git -n " __fish_git_using_command remote; and not __fish_seen_subcommand_from $remotecommands " -a show -d 'Shows a remote'
complete -f -c git -n " __fish_git_using_command remote; and not __fish_seen_subcommand_from $remotecommands " -a prune -d 'Deletes all stale tracking branches'
complete -f -c git -n " __fish_git_using_command remote; and not __fish_seen_subcommand_from $remotecommands " -a update -d 'Fetches updates'
complete -f -c git -n " __fish_git_using_command remote; and not __fish_seen_subcommand_from $remotecommands " -a rename -d 'Renames a remote'
complete -f -c git -n " __fish_git_using_command remote; and not __fish_seen_subcommand_from $remotecommands " -a set-head -d 'Sets the default branch for a remote'
complete -f -c git -n " __fish_git_using_command remote; and not __fish_seen_subcommand_from $remotecommands " -a set-url -d 'Changes URLs for a remote'
complete -f -c git -n " __fish_git_using_command remote; and not __fish_seen_subcommand_from $remotecommands " -a set-branches -d 'Changes the list of branches tracked by a remote'
complete -f -c git -n "__fish_git_using_command remote; and __fish_seen_subcommand_from add " -s f -d 'Once the remote information is set up git fetch <name> is run'
complete -f -c git -n "__fish_git_using_command remote; and __fish_seen_subcommand_from add " -l tags -d 'Import every tag from a remote with git fetch <name>'
complete -f -c git -n "__fish_git_using_command remote; and __fish_seen_subcommand_from add " -l no-tags -d "Don't import tags from a remote with git fetch <name>"
complete -f -c git -n "__fish_git_using_command remote; and __fish_seen_subcommand_from set-branches" -l add -d 'Add to the list of currently tracked branches instead of replacing it'
complete -f -c git -n "__fish_git_using_command remote; and __fish_seen_subcommand_from set-url" -l push -d 'Manipulate push URLs instead of fetch URLs'
complete -f -c git -n "__fish_git_using_command remote; and __fish_seen_subcommand_from set-url" -l add -d 'Add new URL instead of changing the existing URLs'
complete -f -c git -n "__fish_git_using_command remote; and __fish_seen_subcommand_from set-url" -l delete -d 'Remove URLs that match specified URL'
complete -f -c git -n "__fish_git_using_command remote; and __fish_seen_subcommand_from show" -s n -d 'Remote heads are not queried, cached information is used instead'
complete -f -c git -n "__fish_git_using_command remote; and __fish_seen_subcommand_from prune" -l dry-run -d 'Report what will be pruned but do not actually prune it'
complete -f -c git -n "__fish_git_using_command remote; and __fish_seen_subcommand_from update" -l prune -d 'Prune all remotes that are updated'
2009-02-04 18:58:26 +00:00
### show
complete -f -c git -n '__fish_git_needs_command' -a show -d 'Shows the last commit of a branch'
complete -f -c git -n '__fish_git_using_command show' -a '(__fish_git_branches)' -d 'Branch'
2015-09-22 14:46:43 +00:00
complete -f -c git -n '__fish_git_using_command show' -a '(__fish_git_unique_remote_branches)' -d 'Remote branch'
2016-05-07 10:05:44 +00:00
complete -f -c git -n '__fish_git_using_command show' -a '(__fish_git_tags)' --description 'Tag'
2015-12-18 16:07:43 +00:00
complete -f -c git -n '__fish_git_using_command show' -a '(__fish_git_commits)'
2016-07-15 20:04:12 +00:00
complete -f -c git -n '__fish_git_using_command show' -l stat -d 'Generate a diffstat, showing the number of changed lines of each file'
2009-02-04 18:58:26 +00:00
# TODO options
### show-branch
complete -f -c git -n '__fish_git_needs_command' -a show-branch -d 'Shows the commits on branches'
2016-07-13 09:31:59 +00:00
complete -f -c git -n '__fish_git_using_command show-branch' -a '(__fish_git_refs)' --description 'Rev'
2009-02-04 18:58:26 +00:00
# TODO options
### add
2016-05-11 13:06:10 +00:00
complete -c git -n '__fish_git_needs_command' -a add -d 'Add file contents to the index'
2013-05-25 06:08:51 +00:00
complete -c git -n '__fish_git_using_command add' -s n -l dry-run -d "Don't actually add the file(s)"
complete -c git -n '__fish_git_using_command add' -s v -l verbose -d 'Be verbose'
complete -c git -n '__fish_git_using_command add' -s f -l force -d 'Allow adding otherwise ignored files'
complete -c git -n '__fish_git_using_command add' -s i -l interactive -d 'Interactive mode'
complete -c git -n '__fish_git_using_command add' -s p -l patch -d 'Interactively choose hunks to stage'
complete -c git -n '__fish_git_using_command add' -s e -l edit -d 'Manually create a patch'
complete -c git -n '__fish_git_using_command add' -s u -l update -d 'Only match tracked files'
complete -c git -n '__fish_git_using_command add' -s A -l all -d 'Match files both in working tree and index'
complete -c git -n '__fish_git_using_command add' -s N -l intent-to-add -d 'Record only the fact that the path will be added later'
complete -c git -n '__fish_git_using_command add' -l refresh -d "Don't add the file(s), but only refresh their stat"
complete -c git -n '__fish_git_using_command add' -l ignore-errors -d 'Ignore errors'
complete -c git -n '__fish_git_using_command add' -l ignore-missing -d 'Check if any of the given files would be ignored'
2013-05-24 13:09:57 +00:00
complete -f -c git -n '__fish_git_using_command add; and __fish_contains_opt -s p patch' -a '(__fish_git_modified_files)'
2013-10-31 20:23:53 +00:00
complete -f -c git -n '__fish_git_using_command add' -a '(__fish_git_add_files)'
2009-02-04 18:58:26 +00:00
# TODO options
### checkout
2016-05-11 13:06:10 +00:00
complete -f -c git -n '__fish_git_needs_command' -a checkout -d 'Checkout and switch to a branch'
complete -f -c git -n '__fish_git_using_command checkout' -a '(__fish_git_branches)' --description 'Branch'
2016-07-13 09:31:59 +00:00
complete -f -c git -n '__fish_git_using_command checkout' -a '(__fish_git_heads)' --description 'Head'
2016-05-11 13:06:10 +00:00
complete -f -c git -n '__fish_git_using_command checkout' -a '(__fish_git_unique_remote_branches)' --description 'Remote branch'
complete -f -c git -n '__fish_git_using_command checkout' -a '(__fish_git_tags)' --description 'Tag'
2013-10-31 20:23:53 +00:00
complete -f -c git -n '__fish_git_using_command checkout' -a '(__fish_git_modified_files)' --description 'File'
2010-09-18 16:19:44 +00:00
complete -f -c git -n '__fish_git_using_command checkout' -s b -d 'Create a new branch'
2012-10-22 18:50:38 +00:00
complete -f -c git -n '__fish_git_using_command checkout' -s t -l track -d 'Track a new branch'
2009-02-04 18:58:26 +00:00
# TODO options
### apply
complete -f -c git -n '__fish_git_needs_command' -a apply -d 'Apply a patch on a git index file and a working tree'
# TODO options
### archive
complete -f -c git -n '__fish_git_needs_command' -a archive -d 'Create an archive of files from a named tree'
# TODO options
### bisect
complete -f -c git -n '__fish_git_needs_command' -a bisect -d 'Find the change that introduced a bug by binary search'
# TODO options
### branch
complete -f -c git -n '__fish_git_needs_command' -a branch -d 'List, create, or delete branches'
complete -f -c git -n '__fish_git_using_command branch' -a '(__fish_git_branches)' -d 'Branch'
2012-10-22 18:50:38 +00:00
complete -f -c git -n '__fish_git_using_command branch' -s d -d 'Delete branch'
2009-02-04 18:58:26 +00:00
complete -f -c git -n '__fish_git_using_command branch' -s D -d 'Force deletion of branch'
complete -f -c git -n '__fish_git_using_command branch' -s m -d 'Rename branch'
complete -f -c git -n '__fish_git_using_command branch' -s M -d 'Force renaming branch'
complete -f -c git -n '__fish_git_using_command branch' -s a -d 'Lists both local and remote branches'
2012-10-22 18:50:38 +00:00
complete -f -c git -n '__fish_git_using_command branch' -s t -l track -d 'Track remote branch'
complete -f -c git -n '__fish_git_using_command branch' -l no-track -d 'Do not track remote branch'
2016-04-28 19:26:45 +00:00
complete -f -c git -n '__fish_git_using_command branch' -l set-upstream-to -d 'Set remote branch to track'
2015-02-19 16:10:04 +00:00
complete -f -c git -n '__fish_git_using_command branch' -l merged -d 'List branches that have been merged'
complete -f -c git -n '__fish_git_using_command branch' -l no-merged -d 'List branches that have not been merged'
2009-02-04 18:58:26 +00:00
### cherry-pick
2010-09-18 02:18:26 +00:00
complete -f -c git -n '__fish_git_needs_command' -a cherry-pick -d 'Apply the change introduced by an existing commit'
2016-04-28 19:30:26 +00:00
complete -f -c git -n '__fish_git_using_command cherry-pick' -a '(__fish_git_branches --no-merged)' -d 'Branch'
complete -f -c git -n '__fish_git_using_command cherry-pick' -a '(__fish_git_unique_remote_branches --no-merged)' -d 'Remote branch'
2016-05-11 13:01:24 +00:00
# TODO: Filter further
complete -f -c git -n '__fish_git_using_command cherry-pick; and __fish_git_possible_commithash' -a '(__fish_git_commits)'
2015-12-08 22:51:29 +00:00
complete -f -c git -n '__fish_git_using_command cherry-pick' -s e -l edit -d 'Edit the commit message prior to committing'
complete -f -c git -n '__fish_git_using_command cherry-pick' -s x -d 'Append info in generated commit on the origin of the cherry-picked change'
complete -f -c git -n '__fish_git_using_command cherry-pick' -s n -l no-commit -d 'Apply changes without making any commit'
complete -f -c git -n '__fish_git_using_command cherry-pick' -s s -l signoff -d 'Add Signed-off-by line to the commit message'
complete -f -c git -n '__fish_git_using_command cherry-pick' -l ff -d 'Fast-forward if possible'
2009-02-04 18:58:26 +00:00
### clone
complete -f -c git -n '__fish_git_needs_command' -a clone -d 'Clone a repository into a new directory'
2015-12-09 22:58:08 +00:00
complete -f -c git -n '__fish_git_using_command clone' -l no-hardlinks -d 'Copy files instead of using hardlinks'
2016-05-11 13:06:10 +00:00
complete -f -c git -n '__fish_git_using_command clone' -s q -l quiet -d 'Operate quietly and do not report progress'
2015-12-09 22:58:08 +00:00
complete -f -c git -n '__fish_git_using_command clone' -s v -l verbose -d 'Provide more information on what is going on'
complete -f -c git -n '__fish_git_using_command clone' -s n -l no-checkout -d 'No checkout of HEAD is performed after the clone is complete'
2015-12-11 02:42:19 +00:00
complete -f -c git -n '__fish_git_using_command clone' -l bare -d 'Make a bare Git repository'
complete -f -c git -n '__fish_git_using_command clone' -l mirror -d 'Set up a mirror of the source repository'
complete -f -c git -n '__fish_git_using_command clone' -s o -l origin -d 'Use a specific name of the remote instead of the default'
complete -f -c git -n '__fish_git_using_command clone' -s b -l branch -d 'Use a specific branch instead of the one used by the cloned repository'
complete -f -c git -n '__fish_git_using_command clone' -l depth -d 'Truncate the history to a specified number of revisions'
complete -f -c git -n '__fish_git_using_command clone' -l recursive -d 'Initialize all submodules within the cloned repository'
2009-02-04 18:58:26 +00:00
### commit
2016-05-11 13:06:10 +00:00
complete -c git -n '__fish_git_needs_command' -a commit -d 'Record changes to the repository'
2009-02-04 18:58:26 +00:00
complete -c git -n '__fish_git_using_command commit' -l amend -d 'Amend the log message of the last commit'
2015-09-07 11:35:34 +00:00
complete -f -c git -n '__fish_git_using_command commit' -a '(__fish_git_modified_files)'
2016-05-11 11:33:22 +00:00
complete -f -c git -n '__fish_git_using_command commit' -l fixup -d 'Fixup commit to be used with rebase --autosquash'
complete -f -c git -n '__fish_git_using_command commit; and __fish_contains_opt fixup' -a '(__fish_git_commits)'
2009-02-04 18:58:26 +00:00
# TODO options
### diff
2016-05-11 13:06:10 +00:00
complete -c git -n '__fish_git_needs_command' -a diff -d 'Show changes between commits, commit and working tree, etc'
2009-02-04 18:58:26 +00:00
complete -c git -n '__fish_git_using_command diff' -a '(__fish_git_ranges)' -d 'Branch'
complete -c git -n '__fish_git_using_command diff' -l cached -d 'Show diff of changes in the index'
2016-03-20 15:10:51 +00:00
complete -c git -n '__fish_git_using_command diff' -l no-index -d 'Compare two paths on the filesystem'
2009-02-04 18:58:26 +00:00
# TODO options
2013-04-05 04:36:13 +00:00
### difftool
2016-05-11 13:06:10 +00:00
complete -c git -n '__fish_git_needs_command' -a difftool -d 'Open diffs in a visual tool'
2013-04-05 04:36:13 +00:00
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
2009-02-04 18:58:26 +00:00
### grep
2016-05-11 13:06:10 +00:00
complete -c git -n '__fish_git_needs_command' -a grep -d 'Print lines matching a pattern'
2009-02-04 18:58:26 +00:00
# TODO options
### init
complete -f -c git -n '__fish_git_needs_command' -a init -d 'Create an empty git repository or reinitialize an existing one'
# TODO options
### log
2016-05-11 13:06:10 +00:00
complete -c git -n '__fish_git_needs_command' -a log -d 'Show commit logs'
2016-07-13 09:30:10 +00:00
complete -c git -n '__fish_git_using_command log' -a '(__fish_git_refs) (__fish_git_ranges)' -d 'Branch'
2009-02-04 18:58:26 +00:00
# TODO options
### merge
complete -f -c git -n '__fish_git_needs_command' -a merge -d 'Join two or more development histories together'
complete -f -c git -n '__fish_git_using_command merge' -a '(__fish_git_branches)' -d 'Branch'
2015-09-22 14:46:43 +00:00
complete -f -c git -n '__fish_git_using_command merge' -a '(__fish_git_unique_remote_branches)' -d 'Remote branch'
2009-02-04 18:58:26 +00:00
complete -f -c git -n '__fish_git_using_command merge' -l commit -d "Autocommit the merge"
complete -f -c git -n '__fish_git_using_command merge' -l no-commit -d "Don't autocommit the merge"
2013-05-25 06:08:51 +00:00
complete -f -c git -n '__fish_git_using_command merge' -l edit -d 'Edit auto-generated merge message'
complete -f -c git -n '__fish_git_using_command merge' -l no-edit -d "Don't edit auto-generated merge message"
complete -f -c git -n '__fish_git_using_command merge' -l ff -d "Don't generate a merge commit if merge is fast-forward"
complete -f -c git -n '__fish_git_using_command merge' -l no-ff -d "Generate a merge commit even if merge is fast-forward"
complete -f -c git -n '__fish_git_using_command merge' -l ff-only -d 'Refuse to merge unless fast-forward possible'
complete -f -c git -n '__fish_git_using_command merge' -l log -d 'Populate the log message with one-line descriptions'
complete -f -c git -n '__fish_git_using_command merge' -l no-log -d "Don't populate the log message with one-line descriptions"
2009-02-04 18:58:26 +00:00
complete -f -c git -n '__fish_git_using_command merge' -l stat -d "Show diffstat of the merge"
complete -f -c git -n '__fish_git_using_command merge' -s n -l no-stat -d "Don't show diffstat of the merge"
complete -f -c git -n '__fish_git_using_command merge' -l squash -d "Squash changes from other branch as a single commit"
complete -f -c git -n '__fish_git_using_command merge' -l no-squash -d "Don't squash changes"
2013-05-25 06:08:51 +00:00
complete -f -c git -n '__fish_git_using_command merge' -s q -l quiet -d 'Be quiet'
complete -f -c git -n '__fish_git_using_command merge' -s v -l verbose -d 'Be verbose'
complete -f -c git -n '__fish_git_using_command merge' -l progress -d 'Force progress status'
complete -f -c git -n '__fish_git_using_command merge' -l no-progress -d 'Force no progress status'
complete -f -c git -n '__fish_git_using_command merge' -s m -d 'Set the commit message'
complete -f -c git -n '__fish_git_using_command merge' -l abort -d 'Abort the current conflict resolution process'
2009-02-04 18:58:26 +00:00
# TODO options
2016-07-15 22:34:05 +00:00
### mergetool
function __fish_git_mergetools
set -l tools diffuse diffmerge ecmerge emerge kdiff3 meld opendiff tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc codecompare
for tool in $tools
if command --search $tool > /dev/null
echo " $tool "
end
end
end
# returns list of files with status:
# "UU"=unmerged "\?\?"=untracked "M "=staged " M"=changed, not staged "MM"=staged and changed locally
function __fish_git_status --argument-names "statusmarker"
for line in ( git status -s )
set -l filename ( string replace -r " ^ $statusmarker \s+ " "" $line )
and echo $filename
end
end
complete -f -c git -n '__fish_git_needs_command' -a mergetool -d 'Run merge conflict resolution tools to resolve merge conflicts'
complete -f -c git -n '__fish_git_using_command mergetool' -s t -l tool -d "Use specific merge resolution program" -a "(__fish_git_mergetools)"
complete -f -c git -n '__fish_git_using_command mergetool' -a "(__fish_git_status 'UU')" -d "File"
2009-02-04 18:58:26 +00:00
### mv
2016-05-11 13:06:10 +00:00
complete -c git -n '__fish_git_needs_command' -a mv -d 'Move or rename a file, a directory, or a symlink'
2009-02-04 18:58:26 +00:00
# TODO options
### prune
complete -f -c git -n '__fish_git_needs_command' -a prune -d 'Prune all unreachable objects from the object database'
# TODO options
### pull
complete -f -c git -n '__fish_git_needs_command' -a pull -d 'Fetch from and merge with another repository or a local branch'
2013-05-25 06:08:51 +00:00
complete -f -c git -n '__fish_git_using_command pull' -s q -l quiet -d 'Be quiet'
complete -f -c git -n '__fish_git_using_command pull' -s v -l verbose -d 'Be verbose'
# Options related to fetching
complete -f -c git -n '__fish_git_using_command pull' -l all -d 'Fetch all remotes'
complete -f -c git -n '__fish_git_using_command pull' -s a -l append -d 'Append ref names and object names'
complete -f -c git -n '__fish_git_using_command pull' -s f -l force -d 'Force update of local branches'
complete -f -c git -n '__fish_git_using_command pull' -s k -l keep -d 'Keep downloaded pack'
complete -f -c git -n '__fish_git_using_command pull' -l no-tags -d 'Disable automatic tag following'
# TODO --upload-pack
complete -f -c git -n '__fish_git_using_command pull' -l progress -d 'Force progress status'
2016-04-30 14:21:41 +00:00
complete -f -c git -n '__fish_git_using_command pull; and not __fish_git_branch_for_remote' -a '(__fish_git_remotes)' -d 'Remote alias'
complete -f -c git -n '__fish_git_using_command pull; and __fish_git_branch_for_remote' -a '(__fish_git_branch_for_remote)' -d 'Branch'
2013-05-25 06:08:51 +00:00
# TODO other options
2009-02-04 18:58:26 +00:00
### push
complete -f -c git -n '__fish_git_needs_command' -a push -d 'Update remote refs along with associated objects'
2016-04-30 14:21:41 +00:00
complete -f -c git -n '__fish_git_using_command push; and not __fish_git_branch_for_remote' -a '(__fish_git_remotes)' -d 'Remote alias'
complete -f -c git -n '__fish_git_using_command push; and __fish_git_branch_for_remote' -a '(__fish_git_branches)' -d 'Branch'
2016-05-19 12:11:27 +00:00
# The "refspec" here is an optional "+" to signify a force-push
2016-04-30 14:30:02 +00:00
complete -f -c git -n '__fish_git_using_command push; and __fish_git_branch_for_remote; and string match -q "+*" -- (commandline -ct)' -a '+(__fish_git_branches)' -d 'Force-push branch'
2016-05-19 12:11:27 +00:00
# then src:dest (where both src and dest are git objects, so we want to complete branches)
complete -f -c git -n '__fish_git_using_command push; and __fish_git_branch_for_remote; and string match -q "+*:*" -- (commandline -ct)' -a '+(__fish_git_branches):(__fish_git_branch_for_remote)' -d 'Force-push local branch to remote branch'
complete -f -c git -n '__fish_git_using_command push; and __fish_git_branch_for_remote; and string match -q "*:*" -- (commandline -ct)' -a '(__fish_git_branches):(__fish_git_branch_for_remote)' -d 'Push local branch to remote branch'
2013-05-25 06:08:51 +00:00
complete -f -c git -n '__fish_git_using_command push' -l all -d 'Push all refs under refs/heads/'
complete -f -c git -n '__fish_git_using_command push' -l prune -d "Remove remote branches that don't have a local counterpart"
complete -f -c git -n '__fish_git_using_command push' -l mirror -d 'Push all refs under refs/'
complete -f -c git -n '__fish_git_using_command push' -l delete -d 'Delete all listed refs from the remote repository'
complete -f -c git -n '__fish_git_using_command push' -l tags -d 'Push all refs under refs/tags'
complete -f -c git -n '__fish_git_using_command push' -s n -l dry-run -d 'Do everything except actually send the updates'
complete -f -c git -n '__fish_git_using_command push' -l porcelain -d 'Produce machine-readable output'
complete -f -c git -n '__fish_git_using_command push' -s f -l force -d 'Force update of remote refs'
2016-04-28 19:26:45 +00:00
complete -f -c git -n '__fish_git_using_command push' -s u -l set-upstream-to -d 'Add upstream (tracking) reference'
2013-05-25 06:08:51 +00:00
complete -f -c git -n '__fish_git_using_command push' -s q -l quiet -d 'Be quiet'
complete -f -c git -n '__fish_git_using_command push' -s v -l verbose -d 'Be verbose'
complete -f -c git -n '__fish_git_using_command push' -l progress -d 'Force progress status'
# TODO --recurse-submodules=check|on-demand
2009-02-04 18:58:26 +00:00
### rebase
complete -f -c git -n '__fish_git_needs_command' -a rebase -d 'Forward-port local commits to the updated upstream head'
2016-04-30 14:21:41 +00:00
complete -f -c git -n '__fish_git_using_command rebase' -a '(__fish_git_remotes)' -d 'Remote alias'
2009-02-04 18:58:26 +00:00
complete -f -c git -n '__fish_git_using_command rebase' -a '(__fish_git_branches)' -d 'Branch'
2016-07-13 09:31:59 +00:00
complete -f -c git -n '__fish_git_using_command rebase' -a '(__fish_git_heads)' -d 'Head'
complete -f -c git -n '__fish_git_using_command rebase' -a '(__fish_git_tags)' -d 'Tag'
2013-05-25 06:08:51 +00:00
complete -f -c git -n '__fish_git_using_command rebase' -l continue -d 'Restart the rebasing process'
complete -f -c git -n '__fish_git_using_command rebase' -l abort -d 'Abort the rebase operation'
complete -f -c git -n '__fish_git_using_command rebase' -l keep-empty -d "Keep the commits that don't cahnge anything"
complete -f -c git -n '__fish_git_using_command rebase' -l skip -d 'Restart the rebasing process by skipping the current patch'
complete -f -c git -n '__fish_git_using_command rebase' -s m -l merge -d 'Use merging strategies to rebase'
complete -f -c git -n '__fish_git_using_command rebase' -s q -l quiet -d 'Be quiet'
complete -f -c git -n '__fish_git_using_command rebase' -s v -l verbose -d 'Be verbose'
complete -f -c git -n '__fish_git_using_command rebase' -l stat -d "Show diffstat of the rebase"
complete -f -c git -n '__fish_git_using_command rebase' -s n -l no-stat -d "Don't show diffstat of the rebase"
complete -f -c git -n '__fish_git_using_command rebase' -l verify -d "Allow the pre-rebase hook to run"
complete -f -c git -n '__fish_git_using_command rebase' -l no-verify -d "Don't allow the pre-rebase hook to run"
complete -f -c git -n '__fish_git_using_command rebase' -s f -l force-rebase -d 'Force the rebase'
complete -f -c git -n '__fish_git_using_command rebase' -s i -l interactive -d 'Interactive mode'
complete -f -c git -n '__fish_git_using_command rebase' -s p -l preserve-merges -d 'Try to recreate merges'
complete -f -c git -n '__fish_git_using_command rebase' -l root -d 'Rebase all reachable commits'
complete -f -c git -n '__fish_git_using_command rebase' -l autosquash -d 'Automatic squashing'
complete -f -c git -n '__fish_git_using_command rebase' -l no-autosquash -d 'No automatic squashing'
complete -f -c git -n '__fish_git_using_command rebase' -l no-ff -d 'No fast-forward'
2009-02-04 18:58:26 +00:00
### reset
2016-05-11 13:06:10 +00:00
complete -c git -n '__fish_git_needs_command' -a reset -d 'Reset current HEAD to the specified state'
2009-02-04 18:58:26 +00:00
complete -f -c git -n '__fish_git_using_command reset' -l hard -d 'Reset files in working directory'
2015-09-04 17:59:55 +00:00
complete -c git -n '__fish_git_using_command reset' -a '(__fish_git_branches)' -d 'Branch'
2015-09-04 17:54:45 +00:00
complete -f -c git -n '__fish_git_using_command reset' -a '(__fish_git_staged_files)' -d 'File'
2016-05-13 14:18:29 +00:00
complete -f -c git -n '__fish_git_using_command reset' -a '(__fish_git_reflog)' -d 'Reflog'
2009-02-04 18:58:26 +00:00
# TODO options
### revert
complete -f -c git -n '__fish_git_needs_command' -a revert -d 'Revert an existing commit'
2016-05-11 12:51:54 +00:00
complete -f -c git -n '__fish_git_using_command revert' -a '(__fish_git_commits)'
2009-02-04 18:58:26 +00:00
# TODO options
### rm
2016-05-11 13:06:10 +00:00
complete -c git -n '__fish_git_needs_command' -a rm -d 'Remove files from the working tree and from the index'
2011-09-23 10:51:14 +00:00
complete -c git -n '__fish_git_using_command rm' -f
complete -c git -n '__fish_git_using_command rm' -l cached -d 'Keep local copies'
complete -c git -n '__fish_git_using_command rm' -l ignore-unmatch -d 'Exit with a zero status even if no files matched'
complete -c git -n '__fish_git_using_command rm' -s r -d 'Allow recursive removal'
2013-05-25 06:08:51 +00:00
complete -c git -n '__fish_git_using_command rm' -s q -l quiet -d 'Be quiet'
2011-09-23 10:51:14 +00:00
complete -c git -n '__fish_git_using_command rm' -s f -l force -d 'Override the up-to-date check'
complete -c git -n '__fish_git_using_command rm' -s n -l dry-run -d 'Dry run'
2009-02-04 18:58:26 +00:00
# TODO options
### status
complete -f -c git -n '__fish_git_needs_command' -a status -d 'Show the working tree status'
2011-09-23 10:51:14 +00:00
complete -f -c git -n '__fish_git_using_command status' -s s -l short -d 'Give the output in the short-format'
complete -f -c git -n '__fish_git_using_command status' -s b -l branch -d 'Show the branch and tracking info even in short-format'
2016-05-11 13:06:10 +00:00
complete -f -c git -n '__fish_git_using_command status' -l porcelain -d 'Give the output in a stable, easy-to-parse format'
2013-04-01 17:52:27 +00:00
complete -f -c git -n '__fish_git_using_command status' -s z -d 'Terminate entries with null character'
2011-09-23 10:51:14 +00:00
complete -f -c git -n '__fish_git_using_command status' -s u -l untracked-files -x -a 'no normal all' -d 'The untracked files handling mode'
complete -f -c git -n '__fish_git_using_command status' -l ignore-submodules -x -a 'none untracked dirty all' -d 'Ignore changes to submodules'
2009-02-04 18:58:26 +00:00
# TODO options
### tag
complete -f -c git -n '__fish_git_needs_command' -a tag -d 'Create, list, delete or verify a tag object signed with GPG'
2016-04-08 02:46:51 +00:00
complete -f -c git -n '__fish_git_using_command tag; and __fish_not_contain_opt -s d; and __fish_not_contain_opt -s v; and test (count (commandline -opc | string match -r -v \' ^ -\' ) ) -eq 3 ' -a ' ( __fish_git_branches ) ' -d ' Branch'
2013-05-25 06:08:51 +00:00
complete -f -c git -n '__fish_git_using_command tag' -s a -l annotate -d 'Make an unsigned, annotated tag object'
complete -f -c git -n '__fish_git_using_command tag' -s s -l sign -d 'Make a GPG-signed tag'
complete -f -c git -n '__fish_git_using_command tag' -s d -l delete -d 'Remove a tag'
complete -f -c git -n '__fish_git_using_command tag' -s v -l verify -d 'Verify signature of a 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'
2016-05-11 12:51:54 +00:00
complete -f -c git -n '__fish_git_using_command tag' -l contains -xa '(__fish_git_commits)' -d 'List tags that contain a commit'
2015-09-07 11:35:50 +00:00
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 v' -a '(__fish_git_tags)' -d 'Tag'
2009-02-04 18:58:26 +00:00
# TODO options
2013-05-25 06:08:51 +00:00
### stash
complete -c git -n '__fish_git_needs_command' -a stash -d 'Stash away changes'
2014-02-16 13:54:28 +00:00
complete -f -c git -n '__fish_git_using_command stash; and __fish_git_stash_not_using_subcommand' -a list -d 'List stashes'
complete -f -c git -n '__fish_git_using_command stash; and __fish_git_stash_not_using_subcommand' -a show -d 'Show the changes recorded in the stash'
complete -f -c git -n '__fish_git_using_command stash; and __fish_git_stash_not_using_subcommand' -a pop -d 'Apply and remove a single stashed state'
complete -f -c git -n '__fish_git_using_command stash; and __fish_git_stash_not_using_subcommand' -a apply -d 'Apply a single stashed state'
complete -f -c git -n '__fish_git_using_command stash; and __fish_git_stash_not_using_subcommand' -a clear -d 'Remove all stashed states'
complete -f -c git -n '__fish_git_using_command stash; and __fish_git_stash_not_using_subcommand' -a drop -d 'Remove a single stashed state from the stash list'
complete -f -c git -n '__fish_git_using_command stash; and __fish_git_stash_not_using_subcommand' -a create -d 'Create a stash'
complete -f -c git -n '__fish_git_using_command stash; and __fish_git_stash_not_using_subcommand' -a save -d 'Save a new stash'
complete -f -c git -n '__fish_git_using_command stash; and __fish_git_stash_not_using_subcommand' -a branch -d 'Create a new branch from a stash'
complete -f -c git -n '__fish_git_stash_using_command apply' -a '(__fish_git_complete_stashes)'
complete -f -c git -n '__fish_git_stash_using_command branch' -a '(__fish_git_complete_stashes)'
complete -f -c git -n '__fish_git_stash_using_command drop' -a '(__fish_git_complete_stashes)'
complete -f -c git -n '__fish_git_stash_using_command pop' -a '(__fish_git_complete_stashes)'
complete -f -c git -n '__fish_git_stash_using_command show' -a '(__fish_git_complete_stashes)'
2013-05-25 06:08:51 +00:00
2009-02-04 18:58:26 +00:00
### config
complete -f -c git -n '__fish_git_needs_command' -a config -d 'Set and read git configuration variables'
# TODO options
### format-patch
complete -f -c git -n '__fish_git_needs_command' -a format-patch -d 'Generate patch series to send upstream'
complete -f -c git -n '__fish_git_using_command format-patch' -a '(__fish_git_branches)' -d 'Branch'
2015-08-25 13:17:07 +00:00
complete -f -c git -n '__fish_git_using_command format-patch' -s p -l no-stat -d "Generate plain patches without diffstat"
complete -f -c git -n '__fish_git_using_command format-patch' -s s -l no-patch -d "Suppress diff output"
complete -f -c git -n '__fish_git_using_command format-patch' -l minimal -d "Spend more time to create smaller diffs"
complete -f -c git -n '__fish_git_using_command format-patch' -l patience -d "Generate diff with the 'patience' algorithm"
complete -f -c git -n '__fish_git_using_command format-patch' -l histogram -d "Generate diff with the 'histogram' algorithm"
complete -f -c git -n '__fish_git_using_command format-patch' -l stdout -d "Print all commits to stdout in mbox format"
complete -f -c git -n '__fish_git_using_command format-patch' -l numstat -d "Show number of added/deleted lines in decimal notation"
complete -f -c git -n '__fish_git_using_command format-patch' -l shortstat -d "Output only last line of the stat"
complete -f -c git -n '__fish_git_using_command format-patch' -l summary -d "Output a condensed summary of extended header information"
complete -f -c git -n '__fish_git_using_command format-patch' -l no-renames -d "Disable rename detection"
complete -f -c git -n '__fish_git_using_command format-patch' -l full-index -d "Show full blob object names"
complete -f -c git -n '__fish_git_using_command format-patch' -l binary -d "Output a binary diff for use with git apply"
complete -f -c git -n '__fish_git_using_command format-patch' -l find-copies-harder -d "Also inspect unmodified files as source for a copy"
complete -f -c git -n '__fish_git_using_command format-patch' -l text -s a -d "Treat all files as text"
complete -f -c git -n '__fish_git_using_command format-patch' -l ignore-space-at-eol -d "Ignore changes in whitespace at EOL"
complete -f -c git -n '__fish_git_using_command format-patch' -l ignore-space-change -s b -d "Ignore changes in amount of whitespace"
complete -f -c git -n '__fish_git_using_command format-patch' -l ignore-all-space -s w -d "Ignore whitespace when comparing lines"
complete -f -c git -n '__fish_git_using_command format-patch' -l ignore-blank-lines -d "Ignore changes whose lines are all blank"
complete -f -c git -n '__fish_git_using_command format-patch' -l function-context -s W -d "Show whole surrounding functions of changes"
complete -f -c git -n '__fish_git_using_command format-patch' -l ext-diff -d "Allow an external diff helper to be executed"
complete -f -c git -n '__fish_git_using_command format-patch' -l no-ext-diff -d "Disallow external diff helpers"
complete -f -c git -n '__fish_git_using_command format-patch' -l no-textconv -d "Disallow external text conversion filters for binary files (Default)"
complete -f -c git -n '__fish_git_using_command format-patch' -l textconv -d "Allow external text conversion filters for binary files (Resulting diff is unappliable)"
complete -f -c git -n '__fish_git_using_command format-patch' -l no-prefix -d "Do not show source or destination prefix"
complete -f -c git -n '__fish_git_using_command format-patch' -l numbered -s n -d "Name output in [Patch n/m] format, even with a single patch"
complete -f -c git -n '__fish_git_using_command format-patch' -l no-numbered -s N -d "Name output in [Patch] format, even with multiple patches"
2009-02-04 18:58:26 +00:00
2010-09-17 08:38:26 +00:00
## git submodule
2015-10-20 13:49:22 +00:00
set -l submodulecommands add status init update summary foreach sync
2010-09-17 08:38:26 +00:00
complete -f -c git -n '__fish_git_needs_command' -a submodule -d 'Initialize, update or inspect submodules'
2015-10-20 13:49:22 +00:00
complete -f -c git -n " __fish_git_using_command submodule; and not __fish_seen_subcommand_from $submodulecommands " -a 'add' -d 'Add a submodule'
complete -f -c git -n " __fish_git_using_command submodule; and not __fish_seen_subcommand_from $submodulecommands " -a 'status' -d 'Show submodule status'
complete -f -c git -n " __fish_git_using_command submodule; and not __fish_seen_subcommand_from $submodulecommands " -a 'init' -d 'Initialize all submodules'
complete -f -c git -n " __fish_git_using_command submodule; and not __fish_seen_subcommand_from $submodulecommands " -a 'update' -d 'Update all submodules'
complete -f -c git -n " __fish_git_using_command submodule; and not __fish_seen_subcommand_from $submodulecommands " -a 'summary' -d 'Show commit summary'
complete -f -c git -n " __fish_git_using_command submodule; and not __fish_seen_subcommand_from $submodulecommands " -a 'foreach' -d 'Run command on each submodule'
complete -f -c git -n " __fish_git_using_command submodule; and not __fish_seen_subcommand_from $submodulecommands " -a 'sync' -d 'Sync submodules\' URL with .gitmodules'
complete -f -c git -n " __fish_git_using_command submodule; and not __fish_seen_subcommand_from $submodulecommands " -s q -l quiet -d "Only print error messages"
2015-10-20 13:42:48 +00:00
complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from update' -l init -d "Initialize all submodules"
complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from update' -l checkout -d "Checkout the superproject's commit on a detached HEAD in the submodule"
complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from update' -l merge -d "Merge the superproject's commit into the current branch of the submodule"
complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from update' -l rebase -d "Rebase current branch onto the superproject's commit"
complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from update' -s N -l no-fetch -d "Don't fetch new objects from the remote"
complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from update' -l remote -d "Instead of using superproject's SHA-1, use the state of the submodule's remote-tracking branch"
complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from update' -l force -d "Throw away local changes when switching to a different commit and always run checkout"
complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from add' -l force -d "Also add ignored submodule path"
complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from deinit' -l force -d "Remove even with local changes"
complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from status summary' -l cached -d "Use the commit stored in the index"
complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from summary' -l files -d "Compare the commit in the index with submodule HEAD"
complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from foreach update status' -l recursive -d "Traverse submodules recursively"
2015-10-20 13:49:45 +00:00
complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from foreach' -a "(__fish_complete_subcommand --fcs-skip=3)"
2010-09-17 08:38:26 +00:00
## git whatchanged
complete -f -c git -n '__fish_git_needs_command' -a whatchanged -d 'Show logs with difference each commit introduces'
## Aliases (custom user-defined commands)
2015-09-22 18:25:14 +00:00
complete -c git -n '__fish_git_needs_command' -a '(__fish_git_aliases)'
2014-09-20 02:00:29 +00:00
2014-11-28 21:15:49 +00:00
### git clean
complete -f -c git -n '__fish_git_needs_command' -a clean -d 'Remove untracked files from the working tree'
complete -f -c git -n '__fish_git_using_command clean' -s f -l force -d 'Force run'
complete -f -c git -n '__fish_git_using_command clean' -s i -l interactive -d 'Show what would be done and clean files interactively'
complete -f -c git -n '__fish_git_using_command clean' -s n -l dry-run -d 'Don\' t actually remove anything, just show what would be done'
complete -f -c git -n '__fish_git_using_command clean' -s q -l quite -d 'Be quiet, only report errors'
complete -f -c git -n '__fish_git_using_command clean' -s d -d 'Remove untracked directories in addition to untracked files'
complete -f -c git -n '__fish_git_using_command clean' -s x -d 'Remove ignored files, as well'
complete -f -c git -n '__fish_git_using_command clean' -s X -d 'Remove only ignored files'
# TODO -e option
2016-06-02 10:49:01 +00:00
### git blame
complete -f -c git -n '__fish_git_needs_command' -a blame -d 'Show what revision and author last modified each line of a file'
complete -f -c git -n '__fish_git_using_command blame' -s b -d 'Show blank SHA-1 for boundary commits'
complete -f -c git -n '__fish_git_using_command blame' -l root -d 'Do not treat root commits as boundaries'
complete -f -c git -n '__fish_git_using_command blame' -l show-stats -d 'Include additional statistics'
complete -f -c git -n '__fish_git_using_command blame' -s L -d 'Annotate only the given line range'
complete -f -c git -n '__fish_git_using_command blame' -s l -d 'Show long rev'
complete -f -c git -n '__fish_git_using_command blame' -s t -d 'Show raw timestamp'
complete -r -c git -n '__fish_git_using_command blame' -s S -d 'Use revisions from named file instead of calling rev-list'
complete -f -c git -n '__fish_git_using_command blame' -l reverse -d 'Walk history forward instead of backward'
complete -f -c git -n '__fish_git_using_command blame' -s p -l porcelain -d 'Show in a format designed for machine consumption'
complete -f -c git -n '__fish_git_using_command blame' -l line-porcelain -d 'Show the porcelain format'
complete -f -c git -n '__fish_git_using_command blame' -l incremental -d 'Show the result incrementally'
complete -r -c git -n '__fish_git_using_command blame' -l contents -d 'Instead of working tree, use the contents of the named file'
complete -x -c git -n '__fish_git_using_command blame' -l date -d 'Specifies the format used to output dates'
complete -f -c git -n '__fish_git_using_command blame' -s M -d 'Detect moved or copied lines within a file'
complete -f -c git -n '__fish_git_using_command blame' -s C -d 'Detect lines moved or copied from other files that were modified in the same commit'
complete -f -c git -n '__fish_git_using_command blame' -s h -d 'Show help message'
complete -f -c git -n '__fish_git_using_command blame' -s c -d 'Use the same output mode as git-annotate'
complete -f -c git -n '__fish_git_using_command blame' -s f -l show-name -d 'Show the filename in the original commit'
complete -f -c git -n '__fish_git_using_command blame' -s n -l show-number -d 'Show the line number in the original commit'
complete -f -c git -n '__fish_git_using_command blame' -s s -d 'Suppress the author name and timestamp from the output'
complete -f -c git -n '__fish_git_using_command blame' -s e -l show-email -d 'Show the author email instead of author name'
complete -f -c git -n '__fish_git_using_command blame' -s w -d 'Ignore whitespace changes'
2014-09-20 02:00:29 +00:00
## Custom commands (git-* commands installed in the PATH)
complete -c git -n '__fish_git_needs_command' -a '(__fish_git_custom_commands)' -d 'Custom command'