Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: completion: git: --fixup: problem with _describe -2V and duplicate commit subjects



Daniel Hahler wrote on Wed, May 13, 2015 at 14:41:16 +0200:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On 30.03.2015 20:21, Daniel Shahaf wrote:
> > Daniel Shahaf wrote on Sun, Mar 29, 2015 at 05:47:53 +0000:
> >>> As a workaround I could imagine also adding the date, which is useful
> >>> by itself:
> > ...
> >> Actually, I'm tempted to deduplicate it by throwing the hash into the
> >> description:
> > 
> > Another option: add the "HEAD~15" gitrevisions(7) identifier of the
> > commit to the description, which also uniquifies, isn't redundant, and
> > may be easier to type.
> >
> > ...
> >
> > I came up with this because copying the hex digits is annoying.  (It's
> > basically a captcha.)  I'm half seriously considering binding '=' to
> > a widget that inserts '=<TAB>HEAD~' if [[ $LBUFFER == *--fixup ]], to
> > allow me to type just '--fixup=12' to get '--fixup=HEAD~12'.
> 
> I like this idea.  Have you experimented further with it?

Nope, but here it is if anyone wants it:

equal_for_git_fixup() {
  zle .self-insert
  if [[ $LBUFFER == *--fixup= ]] ; then
    zle complete-word
    LBUFFER+="HEAD~"
  fi
}
zle -N equal_for_git_fixup
bindkey '=' equal_for_git_fixup

It'd be especially useful if "HEAD~15" were offered as completions (not
just as descriptions).  However, we can't simply add both the hash and
the HEAD~$n name of the commit to the 'descr' array, due to the bug in
'_describe -2V' when a description is repeated (workers/34814).

So we'd need to fix 34814 in order to add the HEAD~$n as completions.
I'll post about that separately.

Daniel



Messages sorted by: Reverse Date, Date, Thread, Author