zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Daniel Hahler <genml+zsh-workers@thequod.de>
Cc: Zsh Hackers' List <zsh-workers@zsh.org>
Subject: Re: completion: git: --fixup: problem with _describe -2V and duplicate commit subjects
Date: Mon, 30 Mar 2015 18:21:41 +0000	[thread overview]
Message-ID: <20150330182141.GC3767@tarsus.local2> (raw)
In-Reply-To: <20150329054753.GA2766@tarsus.local2>

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.

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 5524cb0..00b124d 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -5645,13 +5645,27 @@ __git_recent_commits () {
   local gitdir expl start
   declare -a descr tags heads commits
   local i j k
+  integer distance_from_head
 
   # Careful: most %d will expand to the empty string.  Quote properly!
   : "${(A)commits::=${(@f)"$(_call_program commits git --no-pager log -20 --format='%h%n%d%n%s')"}}"
   __git_command_successful $pipestatus || return 1
 
   for i j k in "$commits[@]" ; do
-    descr+=($i:$k)
+    # Note: the after-the-colon part must be unique across the entire array;
+    # see workers/34768
+    if (( distance_from_head == 0 )); then
+      descr+=($i:"[HEAD]    $k")
+    elif (( distance_from_head == 1 )); then
+      descr+=($i:"[HEAD^]   $k")
+    elif (( distance_from_head == 2 )); then
+      descr+=($i:"[HEAD^^]  $k")
+    elif (( distance_from_head < 10 )); then
+      descr+=($i:"[HEAD~$distance_from_head]  $k")
+    else
+      descr+=($i:"[HEAD~$distance_from_head] $k")
+    fi
+    (( ++distance_from_head ))
     j=${${j# \(}%\)} # strip leading ' (' and trailing ')'
     for j in ${(s:, :)j}; do
       if [[ $j == 'tag: '* ]] ; then

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'.


  reply	other threads:[~2015-03-30 18:21 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-23 22:05 Daniel Hahler
2015-03-24  0:07 ` Daniel Hahler
2015-03-29  5:47   ` Daniel Shahaf
2015-03-30 18:21     ` Daniel Shahaf [this message]
2015-05-13 12:41       ` Daniel Hahler
2015-05-14 14:28         ` Daniel Shahaf
2015-05-13 12:44     ` Daniel Hahler
2015-05-14 14:36     ` [PATCH] compdescribe fix for unsorted groups (workers/34814) (was: Re: completion: git: --fixup: problem with _describe -2V and duplicate commit subjects) Daniel Shahaf
2015-05-16 22:54       ` Daniel Shahaf
2015-05-17  4:07         ` Bart Schaefer
2015-05-17 23:40           ` Daniel Shahaf
2015-05-18  4:00             ` Bart Schaefer
2015-05-19  1:36               ` Daniel Shahaf
2015-05-19  4:37                 ` Bart Schaefer
2015-05-19 20:41                   ` Daniel Shahaf
2015-05-19 22:03                     ` Bart Schaefer
2015-05-19 20:44       ` Daniel Shahaf
2015-05-19 21:01         ` Daniel Shahaf
2015-05-19 22:23         ` Bart Schaefer
2015-05-20 23:51           ` Daniel Shahaf
2015-05-22  5:02             ` Bart Schaefer
2015-05-23 10:03             ` Daniel Shahaf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150330182141.GC3767@tarsus.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=genml+zsh-workers@thequod.de \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).