Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH 1/5] _git: Fix recent commit completion descriptions.
- X-seq: zsh-workers 36958
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH 1/5] _git: Fix recent commit completion descriptions.
- Date: Sun, 25 Oct 2015 18:34:08 +0000
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=g2L pE27OO2E5XsjYR3DXUV9qk5k=; b=goQo2MdIdvLlpBAtxiQll3eOKYKPdMYgj1a vxSbvfK8K+0JDDLpTUYQemmGWz++6/YFoSOw0NUzYaP3S8Mtk3Ke4BgZjc++9lAl 0pvgowdx9wSkXKnB9kWelX/sCM0/VAPBiISqTAd3tzduv5f7BDMqe2Dq6xSYi+cR Rohoab/g=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=g2 LpE27OO2E5XsjYR3DXUV9qk5k=; b=qAvE8Yq9o3kV3HE1Y1ucl0UesCMoNlf3cp f0dYoGJXwAH7Eg2dwc1bnlluMYO9gzE55EJFwd10umoSKQqAfoyDHS7Wc8Q/G1hd 6DiBydnVl+plaOKQRHR3YPQGq6hszIBHwixq1GiVSEqiLFpO4WXJ9PwbUZ9EXFt3 /wiOMkNGA=
- 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
The uniquifiers 'HEAD~$n' were incorrect when a recent commit was the second
parent of a merge commit. Detect that case and print something correct
instead.
---
Completion/Unix/Command/_git | 41 +++++++++++++++++++++++++++++------------
1 file changed, 29 insertions(+), 12 deletions(-)
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 719d717..7f9881f 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -5650,6 +5650,8 @@ __git_recent_commits () {
local i j k ret
integer distance_from_head
local label
+ local parents
+ local next_first_parent_ancestral_line_commit
zparseopts -D -E O:=argument_array_names
# Turn (-O foo:bar) to (foo bar)
@@ -5659,10 +5661,10 @@ __git_recent_commits () {
# Careful: most %d will expand to the empty string. Quote properly!
# NOTE: we could use %D directly, but it's not available in git 1.9.1 at least.
- commits=("${(f)"$(_call_program commits git --no-pager log $commit_opts -20 --format='%h%n%d%n%s\ \(%cr\)')"}")
+ commits=("${(f)"$(_call_program commits git --no-pager log $commit_opts -20 --format='%h%n%d%n%s\ \(%cr\)%n%p')"}")
__git_command_successful $pipestatus || return 1
- for i j k in "$commits[@]" ; do
+ for i j k parents in "$commits[@]" ; do
# Note: the after-the-colon part must be unique across the entire array;
# see workers/34768
if (( $#commit_opts )); then
@@ -5671,20 +5673,35 @@ __git_recent_commits () {
# description unique (due to workers/34768), which we do by including the
# hash. Git always prints enough hash digits to make the output unique.)
label="[$i]"
- elif (( distance_from_head == 0 )); then
- label="[HEAD] "
- elif (( distance_from_head == 1 )); then
- label="[HEAD^] "
- elif (( distance_from_head == 2 )); then
- label="[HEAD^^] "
- elif (( distance_from_head < 10 )); then
- label="[HEAD~$distance_from_head] "
+ elif (( distance_from_head )) && [[ $i != $next_first_parent_ancestral_line_commit ]]; then
+ # The first commit (HEAD), and its ancestors along the first-parent line,
+ # get HEAD~$n labels.
+ #
+ # For other commits, we just print the hash. (${parents} does provide enough
+ # information to compute HEAD~3^2~4 -style labels, though, if somebody cared
+ # enough to implement that.)
+ label="[$i]"
else
- label="[HEAD~$distance_from_head]"
+ # Compute a first-parent-ancestry commit's label.
+ if false ; then
+ elif (( distance_from_head == 0 )); then
+ label="[HEAD] "
+ elif (( distance_from_head == 1 )); then
+ label="[HEAD^] "
+ elif (( distance_from_head == 2 )); then
+ label="[HEAD^^] "
+ elif (( distance_from_head < 10 )); then
+ label="[HEAD~$distance_from_head] "
+ else
+ label="[HEAD~$distance_from_head]"
+ fi
+
+ # Prepare for the next first-parent-ancestry commit.
+ (( ++distance_from_head ))
+ next_first_parent_ancestral_line_commit=${parents%% *}
fi
# label is now 9 bytes, so the descriptions ($k) will be aligned.
descr+=($i:"${label} $k")
- (( ++distance_from_head ))
j=${${j# \(}%\)} # strip leading ' (' and trailing ')'
j=${j/ ->/,} # Convert " -> master, origin/master".
--
2.1.4
Messages sorted by:
Reverse Date,
Date,
Thread,
Author