From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: pseyfert <pseyfert.mathphys@gmail.com>
Cc: zsh-workers@zsh.org
Subject: Re: git remote set-url completion
Date: Wed, 30 May 2018 01:46:48 +0200 [thread overview]
Message-ID: <14151.1527637608@thecus> (raw)
In-Reply-To: <20180521204513.GA26538@robusta>
On 21 May, pseyfert wrote:
>
> I was not happy with the completion of
> git remote set-url <some remote> TAB
>
> in my usage this should yield the same completions as `git clone TAB`
> (a url like https://gitlab.my_project.tld or git@github.com or some path to a local repository)
git clone doesn't seem to complete http: style URLs either.
> So I put the below patch together which uses __git_repositories (and _urls) instead of _urls.
Thanks for this. I've got a few comments.
> I also saw there was a todo left in _git for doing
> git remote set-url <some remote> <new url> <old url>
> which used to just use _urls for the completion of old url,
> here I get the output of `git remote get-url <some remote> --all`
Except the --all is missing.
> + # TODO: Old URL does not get completed if --push, --add, or --delete are present
With --push, the old URL is, I believe, still valid. And with --delete, it
is the new one that should be excluded.
The (3) exclusion should work. Perhaps add the numbers into the next arg
specifications to make it clearer given that they're being referenced.
> + # TODO: assumes $line[1] is always the remote name
That seems correct to me and not an assumption.
> + _message "the line is: $line"
That looks like leftover debug.
> +(( $+functions[__git_repositories_or_url] )) ||
> +__git_repositories_or_url () {
> + _alternative \
> + 'repositories::__git_repositories' \
> + 'url::_urls'
The tag should be 'urls' rather than 'url'.
> +}
> +
> +(( $+functions[__git_current_remote_url] )) ||
> +__git_current_remote_url () {
> + # TODO: is ${(@)*[1,4]} a proper replacement for $* and passing extra arguments?
NO.
Various styles can affect what _description adds. matcher-list for
example. Don't rely on that.
I'd be inclined to throw away the inherited arguments. A space in the
_arguments spec prevents them from being added:
'3:old url: __git_current_remote_url $line[1]'
Or make the helper function not be a completion function so that you
have something like:
'3:old url:compadd - $(__git_current_remote_url $line[1])'
> + # TODO: add --push to the `git remote get-url` command in case `git remote set-url --push origin <new url> <TAB>` is completed
Adding ${(k)opt_args[--push]} should get you that. It also needs --all
adding in case there are more than one.
Oliver
next prev parent reply other threads:[~2018-05-29 23:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-21 20:45 pseyfert
2018-05-29 23:46 ` Oliver Kiddle [this message]
2018-08-31 20:54 ` Oliver Kiddle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=14151.1527637608@thecus \
--to=okiddle@yahoo.co.uk \
--cc=pseyfert.mathphys@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).