Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: completion: git: --fixup: problem with _describe -2V and duplicate commit subjects
- X-seq: zsh-workers 34820
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Daniel Hahler <genml+zsh-workers@xxxxxxxxxx>
- Subject: Re: completion: git: --fixup: problem with _describe -2V and duplicate commit subjects
- Date: Mon, 30 Mar 2015 18:21:41 +0000
- Cc: Zsh Hackers' List <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=y2rpeVtfReQ2KGd8Om7bpGFtlP0=; b=c+fNkS wWW7lXqKBg6ad4QhiLx3V0ddV+Hl/wSRhrWtJSXkA3FZkdB/mf4M+X8bkTsUo7z1 fObEx+wVH4B/rfwTA3D26stq+W1z92ebUcYm6E7tZElNTYg86hXOz/hn1so8g1jd 17VxU4Bp25FnBHw0CNFbH9EiKNtAWemAg6HC0=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=y2rpeVtfReQ2KGd8Om7bpGFtlP0=; b=dU7Lg baM/BXnzc4x2WisweM4bsX6GOvxp0/Pm87OelhR8jaJaZeJ9ST/9BTzaIBermZTg sjQghYDpT2APxdmF2eW0GcScnMY+ZcpOsYqD2vOxZEdDFpWb0jjD65Y1+dzbVa12 ZUJ6AmfDJrMxAM1AWvyqOLYTBHvMBjTFhI0qpE=
- In-reply-to: <20150329054753.GA2766@tarsus.local2>
- 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: <5510AAD4.8040807@thequod.de> <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'.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author