From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13673 invoked by alias); 3 Mar 2015 23:55:16 -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: 34638 Received: (qmail 9404 invoked from network); 3 Mar 2015 23:55:10 -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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=thequod.de; h= content-type:content-type:subject:subject:mime-version :user-agent:from:from:date:date:message-id:received:received; s= postfix2; t=1425426402; bh=T+oGTFQ6L0zgXRkPt6QOYgiWmgp3RIHsUifqw IyiSps=; b=tYuSrdqxoHA5jJcSBrUBPhK1iu+ZPGN2IJpTAMUoDSdv/1Jjxa+5y 9wGbXPVE6fapjlPHWn5IKK/v3Hu03HK6bjbvR+6hu1B4fVhXDU/51mCe0+ktkorB plxzcxlT+51KsPK9kbLyfdu2T7HPhwWH4SbDmdjAeypA/BlXZv3Au8= Message-ID: <54F647E2.5020400@thequod.de> Date: Wed, 04 Mar 2015 00:46:42 +0100 From: Daniel Hahler User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: zsh-workers@zsh.org Subject: Improved completion for git commit objects (__git_commit_objects) Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Ac9cLb2wxKMbRHKoRnF22rJCBjwIFpSmm" --Ac9cLb2wxKMbRHKoRnF22rJCBjwIFpSmm Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, I am trying to improve completion for Git commit objects. __git_commit_objects is defined as follows (in Completion/Unix/Command/_g= it): __git_commit_objects () { _guard '[[:xdigit:]](#c,40)' 'commit object name' } I think it would be great if it actually (optionally?) could provide completion for commit objects, maybe only on second invocation / as fallb= ack. I am not sure what to use for completion here, but having completion of t= he (shortened) hashes, with more information (subject of the commit) in the description would be nice! E.g., using the output from "git --no-pager log --oneline -20 --format=3D= '%h%n%s'" I've experimented a bit with this: 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=3D[construct a commit message for use with rebase --autosqu= ash]:commit to be amended:' \ - '--squash=3D[construct a commit message for use with rebase --autosq= uash]:commit to be amended:' \ + '--fixup=3D[construct a commit message for use with rebase --autosqu= ash]:commit to be amended:__git_commits' \ + '--squash=3D[construct a commit message for use with rebase --autosq= uash]:commit to be amended:__git_commits' \ $reset_author_opt \ '( --porcelain --dry-run)--short[output dry run in short form= at]' \ '(--short --dry-run)--porcelain[output dry run in porcel= ain-ready format]' \ And then this (very much WIP): @@ -5631,7 +5631,23 @@ __git_heads () { =20 (( $+functions[__git_commit_objects] )) || __git_commit_objects () { + local gitdir expl start + declare -A commits + + # local -a logs + # logs=3D(${(f)"$(git --no-pager log --oneline -20)"}) + # __git_command_successful $pipestatus || return 1 + # + # for l in $logs; do + # commits[${l%% *}]=3D${l#* } + # done + _guard '[[:xdigit:]](#c,40)' 'commit object name' + + : ${(AA)commits::=3D${(f)"$(_call_program commits git --no-pager log -= -oneline -2 --format=3D'%h%n%s')"}} + __git_command_successful $pipestatus || return 1 + + _wanted commits expl 'commit object name' compadd "$@" -k - commits &&= ret=3D0 } I do not fully understand how "_guard" is meant to be used - I need to co= mment/remove it. Should this get chained, e.g. with "_wanted", instead? =20 As for using the commit objects in the completion, I would not like to ha= ve then for "git checkout " by default, but with "git commit --fixup=3D". With "git checkout", any partial matching commit objects should be comple= ted though, and the list would be useful to have on second "". What do you think? Can the completion be improved in this regard? Thanks, Daniel. --Ac9cLb2wxKMbRHKoRnF22rJCBjwIFpSmm Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iD8DBQFU9kfifAK/hT/mPgARAmYOAJ0ZMzT2ayNKEVJ5cvPYR+jX+vU2ngCgmES4 vnOue0MD6Pi3ur5vy1Nxg5U= =URCb -----END PGP SIGNATURE----- --Ac9cLb2wxKMbRHKoRnF22rJCBjwIFpSmm--