From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9363 invoked by alias); 29 May 2018 23:47:46 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 42882 Received: (qmail 21694 invoked by uid 1010); 29 May 2018 23:47:46 -0000 X-Qmail-Scanner-Diagnostics: from park01.gkg.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(205.235.26.22):SA:0(-1.4/5.0):. Processed in 1.419411 secs); 29 May 2018 23:47:46 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_PASS,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: SRS0=ogym=IQ=yahoo.co.uk=okiddle@bounces.park01.gkg.net X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-Virus-Scanned: by amavisd-new at gkg.net Authentication-Results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.co.uk X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1527637614; bh=0u3c0fkA35ZePsgtDuoj2ZH5aNELmA2qvpySIkxWHUM=; h=From:References:To:Subject:Date:From:Subject; b=t30+b8m3Pp0/J7L+6rSchrOrUsuWoOJTAwA5HckGtAh45sggLjfbEI8wX1Zc/4ZEB5dwcozBYK+iu+IV61LQkMmQd2dx/qBvVCwZqvSPoCby/EvtVUKsF0VNwIAqDZQkdmTTl2eH7lKUV/DFgk+mYwfvKYRa8XoxPM42bJ8OGBsSAOmZlmhYhqKDMoPE/TWaWT3kwWowfxbl9QFloYRFZrhnaEcWmQhMohOQaknyfi/YKWD+skZqx0uhd7jhSGShOwm5BzM582A+FbVHBsIbT9VkBt5P0iX5caebekcIg/EwXPYqgLJ5/SRL7KIVf9w1Y/O+spqa2tAglY25Ti5nKA== X-YMail-OSG: ES17XhUVM1nbDYbII8Y43EvU_4alFeFX2QtHWsgJqkTwZgtijFbF6rXMDGs2hW7 KspktGpoEf09dZ8W4a0ZD_CCviXZj0rNzi2m84rffS56BLrbtSW_wQ9jZ.LgRRPK0ysAGPbgI43b EKt4GEMHW67Ga2Djj_t0tA1RnwJmp5IgT8VORTETY4h1qte1Ma6qpt9AqpFpZA6ZG8V5CtDtqa3T OUfZSjOLkr1Xef15.Of9WtzfkNJ0geMVUje32YjlQlqcgEAWVn0tpPJ_EWmvisBew.vYoKQ3YGj7 b0.LT3DEF6UgD8WUGkOIumr0vzYG4AMqtoEBEBToyTgnRqXTY3gyOHuhWwZgChnI7W1maCPx0mkO 7HLR2f2_6Nt0ViQp2V02G.kYPLvSUXMNBETZ.cUzKoE3RY7KE_o1YK4oD35U9pRz.8O57Ea1KX_C Ebuui.CLYt.F_73BZGD9BfkNFiuuHqeRSn_DBK2lckudC5iUtH_JwDQYM4n8r9fUA96rH82sQoqD RadHc96sz0zMtCCM8aykfocYpPr9zSYYJLwsjGVcC0xxrilCmOdh_05IyZQfbjYIMf.bDGTz6B_t aQi_FDdHm5C9hS4TZVlQYlK.0obj3t3tOkZqsA1Sx2PNKslUVca_tw2z917x.5QN3BlmLMeyJwAq WSn8GUHs2OH0Ww21sUaHj6k6VS50Bvw-- cc: zsh-workers@zsh.org In-reply-to: <20180521204513.GA26538@robusta> From: Oliver Kiddle References: <20180521204513.GA26538@robusta> To: pseyfert Subject: Re: git remote set-url completion MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <14150.1527637608.1@thecus> Date: Wed, 30 May 2018 01:46:48 +0200 Message-ID: <14151.1527637608@thecus> On 21 May, pseyfert wrote: > > I was not happy with the completion of > git remote set-url 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 > which used to just use _urls for the completion of old url, > here I get the output of `git remote get-url --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 ` is completed Adding ${(k)opt_args[--push]} should get you that. It also needs --all adding in case there are more than one. Oliver