_git-remote 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #compdef git-remote
  2. # NOTE: --track is undocumented.
  3. # TODO: --track, -t, --master, and -m should take remote branches, I guess.
  4. # NOTE: --master is undocumented.
  5. # NOTE: --fetch is undocumented.
  6. _git-remote () {
  7. local curcontext=$curcontext state line
  8. declare -A opt_args
  9. _arguments -C \
  10. ':command:->command' \
  11. '*::options:->options' && ret=0
  12. case $state in
  13. (command)
  14. declare -a commands
  15. commands=(
  16. 'add:add a new remote'
  17. 'show:show information about a given remote'
  18. 'prune:delete all stale tracking branches for a given remote'
  19. 'update:fetch updates for a set of remotes'
  20. 'rm:remove a remote from .git/config and all associated tracking branches'
  21. 'rename:rename a remote from .git/config and update all associated tracking branches'
  22. 'set-head:sets or deletes the default branch'
  23. 'set-branches:changes the list of branches tracked by the named remote.'
  24. 'set-url:changes URL remote points to.'
  25. )
  26. _describe -t commands 'sub-command' commands && ret=0
  27. ;;
  28. (options)
  29. case $line[1] in
  30. (add)
  31. _arguments \
  32. '*'{--track,-t}'[track given branch instead of default glob refspec]:branch:__git_branch_names' \
  33. '(--master -m)'{--master,-m}'[set the remote'\''s HEAD to point to given master branch]:branch:__git_branch_names' \
  34. '(--fetch -f)'{--fetch,-f}'[run git-fetch on the new remote after it has been created]' \
  35. ':branch name:__git_remotes' \
  36. ':url:_urls' && ret=0
  37. ;;
  38. (show)
  39. _arguments \
  40. '-n[do not contact the remote for a list of branches]' \
  41. ':remote:__git_remotes' && ret=0
  42. ;;
  43. (prune)
  44. _arguments \
  45. '(--dry-run -n)'{-n,--dry-run}'[do not actually prune, only list what would be done]' \
  46. ':remote:__git_remotes' && ret=0
  47. ;;
  48. (update)
  49. __git_remote-groups && ret=0
  50. ;;
  51. (rm)
  52. __git_remotes && ret=0
  53. ;;
  54. (rename)
  55. __git_remotes && ret=0
  56. ;;
  57. (set-url)
  58. _arguments \
  59. '*--push[manipulate push URLs]' \
  60. '(--add)--add[add URL]' \
  61. '(--delete)--delete[delete URLs]' \
  62. ':branch name:__git_remotes' \
  63. ':url:_urls' && ret=0
  64. ;;
  65. esac
  66. ;;
  67. esac
  68. }