summaryrefslogtreecommitdiff
path: root/Completion/Unix/Command/_git
diff options
context:
space:
mode:
authorpseyfert <pseyfert.mathphys@gmail.com>2018-05-21 22:45:13 +0200
committerOliver Kiddle <okiddle@yahoo.co.uk>2018-08-31 22:58:52 +0200
commite754b18ca790e509dd28e3d29191637a27410c53 (patch)
treeb8987015681c069d9e1de5f72fe48962ac54d03c /Completion/Unix/Command/_git
parent7d905fd4feaf574c25142ec650d865c7f575f421 (diff)
downloadzsh-e754b18ca790e509dd28e3d29191637a27410c53.tar.gz
zsh-e754b18ca790e509dd28e3d29191637a27410c53.zip
42810: git remote set-url completion
Diffstat (limited to 'Completion/Unix/Command/_git')
-rw-r--r--Completion/Unix/Command/_git29
1 files changed, 22 insertions, 7 deletions
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index eac0c8476..5f2d68999 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -3610,10 +3610,7 @@ _git-remote () {
':repository:->repository' && ret=0
case $state in
(repository)
- _alternative \
- 'local-repositories::__git_local_repositories' \
- 'remote-repositories::__git_remote_repositories' \
- 'urls::_urls' && ret=0
+ __git_repositories_or_url && ret=0
;;
esac
;;
@@ -3644,14 +3641,17 @@ _git-remote () {
'*: :__git_branch_names' && ret=0
;;
(set-url)
- # TODO: Old URL should be one of those defined for the remote.
+ # TODO: Old URL does not get completed if --push, --add, or --delete are present
+ # TODO: assumes $line[1] is always the remote name
+ _message "the line is: $line"
_arguments -S -s \
'(3)--push[manipulate push URLs instead of fetch URLs]' \
'--add[add URL to those already defined]' \
'(3)--delete[delete all matching URLs]' \
': :__git_remotes' \
- ':new url:_urls' \
- ':old url:_urls' && ret=0
+ ':new url:__git_repositories_or_url' \
+ ':old url:__git_current_remote_url $line[1]' \
+ && ret=0
;;
(show)
_arguments -S \
@@ -6971,6 +6971,21 @@ __git_local_repositories () {
_wanted local-repositories expl 'local repositories' _directories
}
+(( $+functions[__git_repositories_or_url] )) ||
+__git_repositories_or_url () {
+ _alternative \
+ 'repositories::__git_repositories' \
+ 'url::_urls'
+}
+
+(( $+functions[__git_current_remote_url] )) ||
+__git_current_remote_url () {
+ # TODO: is ${(@)*[1,4]} a proper replacement for $* and passing extra arguments?
+ # TODO: add --push to the `git remote get-url` command in case `git remote set-url --push origin <new url> <TAB>` is completed
+ _wanted remote-urls expl 'current urls' \
+ compadd ${(@)*[1,4]} - ${${(0)"$(_call_program remote-urls git remote get-url $5)"}%%$'\n'*}
+}
+
(( $+functions[__git_any_repositories] )) ||
__git_any_repositories () {
# TODO: should also be $GIT_DIR/remotes/origin