From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17824 invoked by alias); 31 Oct 2015 13:02:38 -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: 37032 Received: (qmail 19254 invoked from network); 31 Oct 2015 13:02:32 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=Xu01r+H9SWvEMIC4 EIu5dVOY6u8=; b=dsez5S2Nx6z5gYVLksZjHsYvhmANU6YucArGXvaS/a0384lV 0RrMACxMfk5XJAbXiyFkeP10U00Dk8/X/C2pcCXdL2sUIno+d7tmJGf5NUkqok79 BwvyLcpksqZmWs4P4AJU2cc85lzUql0nKIk6kgYgNGUa/tduGIxlCvr99vY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=Xu01r+H9SWvEMIC 4EIu5dVOY6u8=; b=PRSWRCt48qvFdFXu0vXNzNEgbAFS7Ux48HeF2B/+P4nQZZY +QnIYmn4nWGffR2DuF4ddldvGkXPX5G8Nn5PNRWKlznrkrAh9aWKKjfEL7a1fzXV 2E9XoVDZoQ7Mm53RG1LahKNdjkET0hkOb76khTpSEuJUQa0zyccfiAKxbzZw= X-Sasl-enc: 6C53xtZ1tmi8zjsC3vUSDCXCYv7ZgI6veM4KwAgElLjQ 1446296113 Date: Sat, 31 Oct 2015 12:55:06 +0000 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: __git_recent_commits cannot be called twice Re: [PATCH 2/5] _git: Offer @~$n as completion of recent commits. Message-ID: <20151031125127.GA2360@tarsus.local2> References: <20151025183458.GK11372@tarsus.local2> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20151025183458.GK11372@tarsus.local2> User-Agent: Mutt/1.5.21 (2010-09-15) Daniel Shahaf wrote on Sun, Oct 25, 2015 at 18:34:58 +0000: > Suggested-by: Oliver Kiddle (users/20705) > --- > Output after the first two patches: > > % git commit --fixup= > ed49c5f @~0 - [HEAD] _git: Offer @~$n as completion of recent commits. (2 minutes ago) > ⋮ > 2685bbc @~6 - [HEAD~6] Merge branch 'master' of git://git.code.sf.net/p/zsh/code (15 hours ago) > 506d592 @~7 - [HEAD~7] 36943: restore scan for reclaimable blocks in freeheap() (15 hours ago) > e3c6845 - [e3c6845] unposted: _beep completion: Actually hook it for the 'beep' command. (15 hours ago) > 779b311 - [779b311] 36913 + 36945: vcs_info quilt: Pass patch subject lines to gen-applied-string (15 hours ago) > c62db9e - [c62db9e] 36912: vcs_info quilt: Tolerate being in child of .pc's parent (15 hours ago) > 272119b @~8 - [HEAD~8] unposted: small typo again (16 hours ago) > c8c42d6 @~9 - [HEAD~9] unposted: small typo (16 hours ago) The new output works fine in 'git commit --fixup=', but not in 'git show '. This is because the latter calls __git_recent_commits via two distinct codepaths. Here's a minimal example: 1 % autoload -Uz compinit 2 % compinit 3 % git 4 % cd $(mktemp -d) 5 % git init && git commit -mm --allow-empty 6 Initialized empty Git repository in /tmp/tmp.Y5qmiIcfSX/.git/ 7 [master (root-commit) 9b99116] m 8 % _f() { repeat 1 __git_recent_commits } 9 % compdef _f f ✓ 10 % f 11 HEAD master 12 9b99116 @~0 -- [HEAD] m (4 seconds ago) 13 % _f() { repeat 2 __git_recent_commits } 14 % compdef _f f ✗ 15 % f 16 HEAD master 17 9b99116 18 @~0 19 -- [HEAD] m (25 seconds ago) 20 9b99116 21 @~0 22 -- [HEAD] m (25 seconds ago) A workaround is to disable the list-grouped style: 23 % zstyle :completion::complete:f::commits list-grouped false ✓ 24 % f 25 HEAD master 26 @~0 -- [HEAD] m (71 seconds ago) 27 5d97266 -- [HEAD] m (71 seconds ago) This is only a workaround because grouping @~0 and 5d97266 is desirable, since they both refer to the same commit. I can't fix this issue properly right now, so I'll revert 36959 until a fix can be made: diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index ad1037e..dc9c296 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -5696,7 +5696,10 @@ __git_recent_commits () { else label="[HEAD~$distance_from_head]" fi - descr+=("@~${distance_from_head}":"${label} $k") # CROSSREF: use the same label as below + ## Disabled because _describe renders the output unhelpfuly when this function + ## is called twice during a single completion operation, and list-grouped is + ## in its default setting (enabled). + #descr+=("@~${distance_from_head}":"${label} $k") # CROSSREF: use the same label as below # Prepare for the next first-parent-ancestry commit. (( ++distance_from_head )) The underlying problematic behaviour is reproducible without _git: 1 $ zsh -f 2 % _f() { local -a x=(foo:aaa bar:aaa); repeat 2 _describe -tt 'desc' x } 3 % compdef _f f 4 % f 5 bar 6 foo 7 -- aaa 8 bar 9 foo 10 -- aaa Basically, __git_recent_commits should disable the "Print descriptions one per line, above the candidate completion" behaviour of _describe (which, IIRC, is ultimately implemented by the "-E" flag passed to compadd from the 'case CRT_EXPL' block in bin_compdescribe().) Help with any of this will be welcome. Daniel