zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: [PATCH]: vcs_info git: Describe detached heads symbolically.
Date: Tue, 6 May 2014 12:05:21 +0000	[thread overview]
Message-ID: <20140506120521.GC1948@tarsus.local2> (raw)

[-- Attachment #1: Type: text/plain, Size: 587 bytes --]

A one-liner patch that makes the vcs_info prompt display symbolic names
in one more case.

Without this patch:
[[[
master ccc840470aa9
% git checkout $(git rev-parse HEAD)
                                                                                                                                       
ccc8404... ccc840470aa9
% 
]]]

With this patch:
[[[
master ccc840470aa9
% git checkout $(git rev-parse HEAD)
                                                                                                                                       
heads/master ccc840470aa9
% 
]]]

[-- Attachment #2: 0003-vcs_info-git-Try-harder-to-get-a-non-sha1-branch-nam.patch --]
[-- Type: text/x-patch, Size: 1346 bytes --]

>From 0aac472424ca671d2c2715eaac880684ad59c9d6 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf <d.s@daniel.shahaf.name>
Date: Tue, 8 Apr 2014 21:07:28 +0000
Subject: [PATCH 3/3] vcs_info git: Describe detached heads symbolically.

This makes %b expand to a refname rather than a sha1 when HEAD is detached but
happens to match some ref (branch, tag, etc).  The resulting output will
typically contain a slash (e.g., "tags/v1.0.2", "heads/mybranch"), which helps
distinguish it from the output in the "HEAD is a symbolic ref" case.
---
 Functions/VCS_Info/Backends/VCS_INFO_get_data_git |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index 6512851..a48dc39 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -97,7 +97,7 @@ VCS_INFO_git_getbranch () {
         gitbranch="$(${(z)gitsymref} 2> /dev/null)"
 
         if [[ $? -ne 0 ]] ; then
-            gitbranch="refs/tags/$(${vcs_comm[cmd]} describe --exact-match HEAD 2>/dev/null)"
+            gitbranch="refs/tags/$(${vcs_comm[cmd]} describe --all --exact-match HEAD 2>/dev/null)"
 
             if [[ $? -ne 0 ]] ; then
                 gitbranch="${${"$(< $gitdir/HEAD)"}[1,7]}..."
-- 
1.7.10.4


             reply	other threads:[~2014-05-06 12:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-06 12:05 Daniel Shahaf [this message]
2014-05-06 12:22 ` Frank Terbeck
2014-05-06 12:26   ` 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=20140506120521.GC1948@tarsus.local2 \
    --to=d.s@daniel.shahaf.name \
    --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).