From e754b18ca790e509dd28e3d29191637a27410c53 Mon Sep 17 00:00:00 2001 From: pseyfert Date: Mon, 21 May 2018 22:45:13 +0200 Subject: 42810: git remote set-url completion --- Completion/Unix/Command/_git | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'Completion/Unix/Command/_git') 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 ` 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 -- cgit v1.2.3 From 36ac12d0b6d29b6aacce1a2034811647e8f6dbae Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Fri, 31 Aug 2018 23:10:36 +0200 Subject: 43359: further review of git remote set-url completion --- ChangeLog | 3 +++ Completion/Unix/Command/_git | 43 +++++++++++++++++-------------------------- 2 files changed, 20 insertions(+), 26 deletions(-) (limited to 'Completion/Unix/Command/_git') diff --git a/ChangeLog b/ChangeLog index 1dcaa079b..6e793cfc0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2018-08-31 Oliver Kiddle + * 43359: Completion/Unix/Command/_git: + further review of git remote set-url completion + * 42810: pseyfert: Completion/Unix/Command/_git: git remote set-url completion diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 5f2d68999..1e19a03a4 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -3607,12 +3607,7 @@ _git-remote () { '(-m --master)'{-m,--master=}'[set HEAD of remote to point to given master branch]: :__git_branch_names' \ '--mirror[do not use separate remotes]::mirror type:(fetch pull)' \ ':name:__git_remotes' \ - ':repository:->repository' && ret=0 - case $state in - (repository) - __git_repositories_or_url && ret=0 - ;; - esac + ':repository:__git_repositories_or_urls' && ret=0 ;; (get-url) _arguments -S -s \ @@ -3641,17 +3636,13 @@ _git-remote () { '*: :__git_branch_names' && ret=0 ;; (set-url) - # 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:__git_repositories_or_url' \ - ':old url:__git_current_remote_url $line[1]' \ - && ret=0 + _arguments -S \ + '--push[manipulate push URLs instead of fetch URLs]' \ + '(3)--add[add URL to those already defined]' \ + '(2)--delete[delete all matching URLs]' \ + '1: :__git_remotes' \ + '2:new url:__git_repositories_or_urls' \ + '3:old url: __git_current_remote_urls ${(k)opt_args[--push]} $line[1]' && ret=0 ;; (show) _arguments -S \ @@ -6971,19 +6962,19 @@ __git_local_repositories () { _wanted local-repositories expl 'local repositories' _directories } -(( $+functions[__git_repositories_or_url] )) || -__git_repositories_or_url () { +(( $+functions[__git_repositories_or_urls] )) || +__git_repositories_or_urls () { _alternative \ 'repositories::__git_repositories' \ - 'url::_urls' + 'urls::_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 ` is completed - _wanted remote-urls expl 'current urls' \ - compadd ${(@)*[1,4]} - ${${(0)"$(_call_program remote-urls git remote get-url $5)"}%%$'\n'*} +(( $+functions[__git_current_remote_urls] )) || +__git_current_remote_urls () { + local expl + _description remote-urls expl 'current url' + compadd "$expl[@]" -M 'r:|/=* r:|=*' - ${(f)"$(_call_program remote-urls + git remote get-url "$@" --all)"} } (( $+functions[__git_any_repositories] )) || -- cgit v1.2.3 From 410c30a25b070fa7ef137ff35166323c322bcd53 Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Fri, 31 Aug 2018 23:17:28 +0200 Subject: unposted: git describe's --long and --abbrev options are not mutually exclusive --- ChangeLog | 3 +++ Completion/Unix/Command/_git | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'Completion/Unix/Command/_git') diff --git a/ChangeLog b/ChangeLog index 6e793cfc0..8dd3bd9e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2018-08-31 Oliver Kiddle + * unposted: Completion/Unix/Command/_git: git describe's + --long and --abbrev options are not mutually exclusive + * 43359: Completion/Unix/Command/_git: further review of git remote set-url completion diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 1e19a03a4..2cae4c82f 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -738,11 +738,11 @@ _git-describe () { '--all[use any ref found in "$GIT_DIR/refs/"]' \ '--tags[use any ref found in "$GIT_DIR/refs/tags"]' \ '(--tags)--contains[find the tag after the commit instead of before]' \ - '(--long)--abbrev=[set minimum SHA1 display-length]: :__git_guard_number length' \ + '--abbrev=[set minimum SHA1 display-length]: :__git_guard_number length' \ '( --exact-match)--candidates=[consider up to given number of candidates]: :__git_guard_number "number of candidates"' \ '(--candidates )--exact-match[only output exact matches, same as --candidates=0]' \ '--debug[display information about the searching strategy]' \ - '(--abbrev)--long[always show full format, even for exact matches]' \ + '--long[always show full format, even for exact matches]' \ '*--match=[only consider tags matching glob pattern]:pattern' \ "*--exclude=[don't consider tags matching glob pattern]:pattern" \ '--always[show uniquely abbreviated commit object as fallback]' \ -- cgit v1.2.3