From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12683 invoked by alias); 4 Mar 2015 02:40:08 -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: 34639 Received: (qmail 5990 invoked from network); 4 Mar 2015 02:40:04 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=x-sasl-enc:date:from:to:cc:subject :message-id:references:mime-version:content-type:in-reply-to; s= mesmtp; bh=xO/vf2v1HQd6ao5r8glwxkKEg0U=; b=tXEiHd8PNP1Huu58HgRKh va8V+u0p61H3yhZeOaA+J6c2wt/Xj+NCkSblBG0zFk3Q8CspcqaEQFSORCYHuVkF 5XAmSwdP6hJBxytrvkTuWf/3G2I9QbmP3sc2729xzE6SA16sx2hU8k4Rz+EAVsL5 CUI4e1g0PA5DBRREkjEFL0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=x-sasl-enc:date:from:to:cc:subject :message-id:references:mime-version:content-type:in-reply-to; s= smtpout; bh=xO/vf2v1HQd6ao5r8glwxkKEg0U=; b=LMAzio1qpdCxKQi8pxVP zASgPav7OmFHRkmwP1OVJg65aMs1ZVtPYnbDpXno7UQoCidvF07+3J4Y1zmwutIc VabtdzbpkiXrVhgJ7Cw/xSsl1LNvQLL6Vv50y8vwRfwz/9Jygb0K6K7X0dQocqgk caF4sjXSM/Fw9yoVofaTWlM= X-Sasl-enc: PdIeADHqAsfHXVVaWkgmUTBvr+K/7tcAwcU9gVKEysjA 1425436803 Date: Wed, 4 Mar 2015 02:40:00 +0000 From: Daniel Shahaf To: Daniel Hahler Cc: zsh-workers@zsh.org Subject: Re: Improved completion for git commit objects (__git_commit_objects) Message-ID: <20150304024000.GF2057@tarsus.local2> References: <54F647E2.5020400@thequod.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54F647E2.5020400@thequod.de> User-Agent: Mutt/1.5.21 (2010-09-15) Daniel Hahler wrote on Wed, Mar 04, 2015 at 00:46:42 +0100: > First, I've also added __git_commits to _git-commit where relevant: > > diff --git i/Completion/Unix/Command/_git w/Completion/Unix/Command/_git > index 9552780..0bfa057 100644 > --- i/Completion/Unix/Command/_git > +++ w/Completion/Unix/Command/_git > @@ -647,8 +647,8 @@ _git-commit () { > # TODO: --interactive isn't explicitly listed in the documentation. > _arguments -w -S -s \ > '(-a --all --interactive -o --only -i --include *)'{-a,--all}'[stage all modified and deleted paths]' \ > - '--fixup=[construct a commit message for use with rebase --autosquash]:commit to be amended:' \ > - '--squash=[construct a commit message for use with rebase --autosquash]:commit to be amended:' \ > + '--fixup=[construct a commit message for use with rebase --autosquash]:commit to be amended:__git_commits' \ > + '--squash=[construct a commit message for use with rebase --autosquash]:commit to be amended:__git_commits' \ > $reset_author_opt \ > '( --porcelain --dry-run)--short[output dry run in short format]' \ > '(--short --dry-run)--porcelain[output dry run in porcelain-ready format]' \ > Looks like we could apply this part immediately, it isn't WIP like the rest of your change. > + : ${(AA)commits::=${(f)"$(_call_program commits git --no-pager log --oneline -2 --format='%h%n%s')"}} You can remove '--oneline': it has no effect since you use '--format' later. > _guard '[[:xdigit:]](#c,40)' 'commit object name' > + > + : ${(AA)commits::=${(f)"$(_call_program commits git --no-pager log --oneline -2 --format='%h%n%s')"}} > + __git_command_successful $pipestatus || return 1 > + > + _wanted commits expl 'commit object name' compadd "$@" -k - commits && ret=0 > } > > I do not fully understand how "_guard" is meant to be used - I need to comment/remove it. > Should this get chained, e.g. with "_wanted", instead? What's the desired behaviour? Suppose that ${(k)commits} is [0123abc, 4567def] and the user types '--fixup=fedbca'. In this case, you'd still want the second argument to _guard to be displayed, right? In this case, I think you should retain _guard in the "the 'commits' tag is wanted, but none of ${(k)commits} matches the input so far" codepath. Makes sense? > As for using the commit objects in the completion, I would not like to have then for > "git checkout " by default, but with "git commit --fixup=". > With "git checkout", any partial matching commit objects should be completed though, > and the list would be useful to have on second "". > > What do you think? Haven't tried the patch, but I like the idea of offering recent commits as completions for --fixup. I use --fixup regularly, and that's exactly the completion offers I'd want. Cheers, Daniel