* [PATCH]: vcs_info git: Describe detached heads symbolically.
@ 2014-05-06 12:05 Daniel Shahaf
2014-05-06 12:22 ` Frank Terbeck
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Shahaf @ 2014-05-06 12:05 UTC (permalink / raw)
To: zsh-workers
[-- 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH]: vcs_info git: Describe detached heads symbolically.
2014-05-06 12:05 [PATCH]: vcs_info git: Describe detached heads symbolically Daniel Shahaf
@ 2014-05-06 12:22 ` Frank Terbeck
2014-05-06 12:26 ` Daniel Shahaf
0 siblings, 1 reply; 3+ messages in thread
From: Frank Terbeck @ 2014-05-06 12:22 UTC (permalink / raw)
To: Daniel Shahaf; +Cc: zsh-workers
Hey Daniel,
Daniel Shahaf wrote:
[...]
> With this patch:
>
> master ccc840470aa9
> % git checkout $(git rev-parse HEAD)
>
> heads/master ccc840470aa9
> %
[...]
> - 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)"
[...]
That sounds reasonable, so it's applied. Thanks!
Regards, Frank
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH]: vcs_info git: Describe detached heads symbolically.
2014-05-06 12:22 ` Frank Terbeck
@ 2014-05-06 12:26 ` Daniel Shahaf
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Shahaf @ 2014-05-06 12:26 UTC (permalink / raw)
To: Frank Terbeck; +Cc: zsh-workers
Frank Terbeck wrote on Tue, May 06, 2014 at 14:22:38 +0200:
> Daniel Shahaf wrote:
> [...]
> > With this patch:
> >
> > master ccc840470aa9
> > % git checkout $(git rev-parse HEAD)
> >
> > heads/master ccc840470aa9
> > %
> [...]
> > - 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)"
> [...]
>
> That sounds reasonable, so it's applied. Thanks!
That was quick, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-05-06 12:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-06 12:05 [PATCH]: vcs_info git: Describe detached heads symbolically Daniel Shahaf
2014-05-06 12:22 ` Frank Terbeck
2014-05-06 12:26 ` Daniel Shahaf
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).