Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH 7/7] completion: git: add distance_from_head to __git_recent_commits
- X-seq: zsh-workers 35105
- From: Daniel Hahler <genml+zsh-workers@xxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH 7/7] completion: git: add distance_from_head to __git_recent_commits
- Date: Wed, 13 May 2015 16:26:31 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=thequod.de; h= references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received; s=postfix2; t= 1431527205; bh=gKaRezVVDm+IufXxkGyx9ipncf9XpSmM/Vqb/ZpbUfQ=; b=N X0HWWu5J7armpCa26ETPK5gvlG+yA4JuXOD/BIwytzHQ1AJP7taSvhZr2rD++jBX BJCmjJ2sSn5D/u3mPQMwJ1GVylYcqjXM7oCsM0hcL1XzKbdfn12FF2mVcD7IXNcO gjywhyLdYNMfe3qZAD568nfu8Z7BEpLLCR+8GGxSjg=
- In-reply-to: <1431527191-32165-1-git-send-email-genml+zsh-workers@thequod.de>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <1431527191-32165-1-git-send-email-genml+zsh-workers@thequod.de>
From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
This adds the "HEAD~15" gitrevisions(7) identifier of the commit to the
description, which also uniquifies, isn't redundant, and may be easier
to type.
Ref: zsh-workers/34820 (http://www.zsh.org/mla/workers/2015/msg00744.html)
---
Completion/Unix/Command/_git | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 09ea68b..ef95dfd 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -5671,6 +5671,7 @@ __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\ \(%cr\)')"}}"
@@ -5679,7 +5680,19 @@ __git_recent_commits () {
for i j k in "$commits[@]" ; do
# Note: the after-the-colon part must be unique across the entire array;
# see workers/34768
- descr+=("$i:[$i] $k")
+ 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%% ->*} # Remove " -> master, origin/master" etc.
for j in ${(s:, :)j}; do
if [[ $j == 'tag: '* ]] ; then
--
2.4.0.dirty
Messages sorted by:
Reverse Date,
Date,
Thread,
Author