From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23113 invoked by alias); 14 Aug 2017 12:03:54 -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: X-Seq: 41545 Received: (qmail 11158 invoked by uid 1010); 14 Aug 2017 12:03:54 -0000 X-Qmail-Scanner-Diagnostics: from nm36-vm7.bullet.mail.ir2.yahoo.com 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(212.82.97.139):SA:0(-4.7/5.0):. Processed in 6.468655 secs); 14 Aug 2017 12:03:54 -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=-4.7 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: okiddle@yahoo.co.uk X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1502711854; bh=BNpsCY45V1Lt6Ri56A4PsJVbecUY2nGj5DR+cKyeSAY=; h=In-reply-to:From:References:To:Subject:Date:From:Subject; b=PfGIhqqAwcxRa7/2lyoHnF8f6Oh50oELFkD4GRTC3pwkC5AGRGG4rrqaJs1BesPeTS7KAsUESCwvcAv7iZs4ZvzipPapQYY9HAOTtqdMZzUqLcjpyMI8behgjPDKKvr1MO8PPpsJy8tFocjLDrTr2a11Q7j5zozLNlH7mHB577qoiFg6sbeNz9Hh2pP+HKuIlCsyUubn+aadVHuH5yB82nmXr195OzES9nYI9S5rpY3q8+tTwKIvzNVODpBlFfF+jVF4P7ZEDb2+MilQjrmL9Plgbwbhuqg0jrXk7M1GDaQklUQw1PxeQqthtRKga3CSxhZXLv4+XtFL+eSvMMzkBA== X-Yahoo-Newman-Id: 855941.37191.bm@smtp110.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: uRxlGEEVM1mE.cKvA4I3g89_06lwlAAAzR6zoyKfhf0j23d bo_W09IaexrgSFclyRP5DeC8CuZIddsl77Vbeiou2BIcNSU6nh9Hg.Ws2dNE SNMll_6UgLeTzxOTIl0q4rLND0Kiypkgu2chFvsgWNQh42uQnhQYtZAu1TPx IkIEefGAhfCHF8ZkjGwSuVJww2uyCVVquKx22sl3AftwUywTOgxmeLctGZGC XSvO8iQEL4yrjMxPmeJ8m_161UE5e3sNJ5iW16K5pi2krkXkb5wjAfGGA5Cv OXlbGkxwiS.lRY_0C8K9p5QtjDUsPRBFlH_gHmJ7ACgl_GxoHbgVZHC8Ul.C IgagAd8q1RB9_f4I15cIK5e0tE587frXSTCgOVRTbV6qU9_fvziBuWOfmPvt QyZXKCV2e.DBX61dChgHQTSGCZ1ykwxPX8gmwGEuaSZ6UOYcFXOURicfrn.G zd9fT8ANxUcP6G7RszghM336qtQTn_igIT5mHmy6elIcbHg-- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- In-reply-to: <20170809193113.3gjq3ezigb6yvdu4@tarpaulin.shahaf.local2> From: Oliver Kiddle References: <20170809193113.3gjq3ezigb6yvdu4@tarpaulin.shahaf.local2> To: Zsh workers Subject: Re: git worktree add /foo MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <15765.1502711853.1@thecus.kiddle.eu> Content-Transfer-Encoding: 8bit Date: Mon, 14 Aug 2017 13:57:33 +0200 Message-ID: <15766.1502711853@thecus.kiddle.eu> On 9 Aug, Daniel Shahaf wrote: > The second argument to 'git worktree add' can be any committish. That > committish becomes HEAD of the new worktree, and if it's a branch name, > then that branch becomes the current branch of the new worktree, else > the new worktree starts as a detached HEAD. > > How should that be completed? > > Currently it's completed as follows: > > +++ b/Completion/Unix/Command/_git > @@ -2026,11 +2026,7 @@ _git-worktree() { > curcontext=${curcontext%:*}-$line[1]: > case $line[1] in > (add) > if (( $words[(I)--detach] )); then > args=( ':commit:__git_commits' ) > else > args=( ':branch:__git_branch_names' ) > fi I can't remember why it was done this way but I'm wondering if the two halves of the if…else…fi are the opposite way around from the intention. Specifying --detach would be superfluous for anything but a branch because it is the default for any other committish so after --detach there is sense in only completing branches. I often apply logic such as this but it might not always be helpful, such as if --detach comes from an alias. Otherwise, as you say, any committish is valid and our usual approach is to just complete them all and expect user's to set tag-order to give preference to the matches they find most useful. I suggested years back that we perhaps add a mechanism for giving a default tag-order and perhaps should consider it again. > I see __git_recent_branches but it's not precisely what I have in mind. What would be useful in this case? Oliver