From mboxrd@z Thu Jan 1 00:00:00 1970 From: Scott Bronson Subject: Re: Bash tab completion for _git_fetch alias is broken on Git 1.7.7.1 Date: Sat, 12 Nov 2011 09:50:08 -0800 Message-ID: References: <7vehxgu0fy.fsf@alter.siamese.dyndns.org> <4EBB78C7.101@viscovery.net> <20111110151412.GA11479@goldbirke> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Nathan Broadbent , Johannes Sixt , Junio C Hamano , git@vger.kernel.org To: =?ISO-8859-1?Q?SZEDER_G=E1bor?= X-From: git-owner@vger.kernel.org Sat Nov 12 18:50:23 2011 Return-path: Envelope-to: gcvg-git-2@lo.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RPHie-0000ko-Na for gcvg-git-2@lo.gmane.org; Sat, 12 Nov 2011 18:50:21 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754215Ab1KLRuJ convert rfc822-to-quoted-printable (ORCPT ); Sat, 12 Nov 2011 12:50:09 -0500 Received: from mail-iy0-f174.google.com ([209.85.210.174]:62617 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753173Ab1KLRuI convert rfc822-to-8bit (ORCPT ); Sat, 12 Nov 2011 12:50:08 -0500 Received: by iage36 with SMTP id e36so5349764iag.19 for ; Sat, 12 Nov 2011 09:50:08 -0800 (PST) Received: by 10.42.161.69 with SMTP id s5mr16748047icx.23.1321120208165; Sat, 12 Nov 2011 09:50:08 -0800 (PST) Received: by 10.42.221.4 with HTTP; Sat, 12 Nov 2011 09:50:08 -0800 (PST) In-Reply-To: Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: 2011/11/12 Scott Bronson : > 2011/11/10 SZEDER G=E1bor >> > On Thu, Nov 10, 2011 at 3:09 PM, Johannes Sixt wrote: >> > > Am 11/10/2011 4:21, schrieb Junio C Hamano: >> > > > Nathan Broadbent writes: >> > > >> Dear git mailing list, >> > > >> I'm assigning the `_git_fetch` bash tab completion to the ali= as `gf`, >> > > >> with the following command: >> > > >> =A0 =A0 complete -o default -o nospace -F _git_fetch gf >> > > >> The tab completion then works fine in git 1.7.0.4, but breaks= on git >> > > >> 1.7.7.1, with the following error: >> I didn't actually tried, but I guess this is a side-effect of da4902= a7 >> (completion: remove unnecessary _get_comp_words_by_ref() invocations= , >> ... >> Alternatively, you could easily create your own wrapper function >> around _git_fetch(), like this: > Very true. =A0But if you tweak the completion variables, you can fool > _git_fetch into working perfectly: > * If I had more time, I'd be tempted to write a function that > would define all the wrapper functions. I couldn't stop thinking about it last night, I had to try it. Here's = the result, seems to work great: __define_git_completion () { eval " _git_$2_shortcut () { COMP_LINE=3D\"git $2\${COMP_LINE#$1}\" let COMP_POINT+=3D$((4+${#2}-${#1})) COMP_WORDS=3D(git $2 \"\${COMP_WORDS[@]:1}\") let COMP_CWORD+=3D1 local cur words cword prev _get_comp_words_by_ref -n =3D: cur words cword prev _git_$2 } " } __git_shortcut () { type _git_$2_shortcut &>/dev/null || __define_git_completion $1= $2 alias $1=3D"git $2 $3" complete -o default -o nospace -F _git_$2_shortcut $1 } __git_shortcut ga add __git_shortcut gb branch __git_shortcut gba branch -a __git_shortcut gco checkout __git_shortcut gci commit -v __git_shortcut gcia commit '-a -v' __git_shortcut gd diff __git_shortcut gdc diff --cached __git_shortcut gds diff --stat __git_shortcut gf fetch __git_shortcut gl log __git_shortcut glp log -p __git_shortcut gls log --stat On Github: https://github.com/bronson/dotfiles/blob/731bfd951be68f395247982ba1fb74= 5fbed2455c/.bashrc#L81 It would be nice to see the __define_git_completion function merged upstram. Possible? - Scott