Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH 2/2] vcs_info git: For the branch name, try to find a symbolic name before falling back to a raw commit hex.
- X-seq: zsh-workers 43313
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH 2/2] vcs_info git: For the branch name, try to find a symbolic name before falling back to a raw commit hex.
- Date: Sat, 18 Aug 2018 15:57:19 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=NE1BAXIasBvdRGBeed2aBCGdwCdU23KdwVelISO+ifE=; b=RzaF5xqG gk6rS3zjmK9rXoGGd9mKsP09wR+HTzFW3jp0dvC0Nx1zNec/y3X1ltGGfc76QE3R Q9pwZ3PH6Agt4DKnSysp5HW93226TjgDKpYooKGcBPPHCgeg3pmeNyWFGLTZJ9cI LHqgtALHyyzucwxVvv/y9A5xpMw15edHuc8DWjeDeHbLvylu6LQpoGZPB6WqaKBK km629ZokBdhTwVEM8ZFAKNK5EXAMvhyY9CFjLvd9g429tLlWf3Iim4+QzbrsNQmX wkSZ78hqKmFKU6t1M4LQp9UkZ/2Wvzw8EJtHSx5y1Th/ih0Z2JwvuYlTqZw0rVFk jqQ7ie0NJ4ZYDQ==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=NE1BAXIasBvdRGBeed2aBCGdwCdU23KdwVelISO+ifE=; b=NQ4Ha/3H ZhWBoJXtE8LLWYUzrTej6ncQOHrHKPi1RGfOhHemSXo1JrYNQ45imftc+gMAQXdE KiDRaV4IhtGOXp+ZexBhub9vQPRiByMonVpv84JpFWV6Zd52H1dxrMEoaXYZYMUF kAh7/pZ+Jq98AgUTkweY0AcBgJ+TfLLWLgNC/CLy/OJ32gexN7fHQweyQA+O8t3i MH+/PZXCAqu+tqDfxaJ31FIMQN/06Kkzla55Qv5/NA3gC5mLLeJJL39xRbUOLc5q GzvuRq8anqb7JJi2DP6g7Lyac3955S7TfpusxWcvVclTeJDhzOhJhY7O9ASiKrS1 fbqivIiuseE5ZQ==
- In-reply-to: <20180818155719.23574-1-danielsh@tarpaulin.shahaf.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>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20180818155719.23574-1-danielsh@tarpaulin.shahaf.local2>
Ask git-describe(1) and git-name-rev(1) to compute a gitrevisions(1)
name in terms of a branch or tag that contains (= is a descendant of,
is younger than) HEAD.
In this repository, the output changes from "9567bfe..." to
"master~1" or "remotes/origin/HEAD~1".
---
WDYT?
Cheers,
Daniel
(In HEAD, the branch name is already set to "heads/master" after `git checkout --detach master`.)
Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index a44a62c79..c3e62db3a 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -106,6 +106,10 @@ VCS_INFO_git_getbranch () {
elif gitbranch="$(${(z)gitsymref} 2> /dev/null)" ; then
elif gitbranch="refs/tags/$(${vcs_comm[cmd]} describe --all --exact-match HEAD 2>/dev/null)" ; then
+ elif gitbranch="$(${vcs_comm[cmd]} describe --contains HEAD 2>/dev/null)" ; then
+ ## Commented out because we don't know of a case in which 'describe --contains' fails and 'name-rev --tags' succeeds.
+ #elif gitbranch="$(${vcs_comm[cmd]} name-rev --name-only --no-undefined --tags HEAD 2>/dev/null)" ; then
+ elif gitbranch="$(${vcs_comm[cmd]} name-rev --name-only --no-undefined --always HEAD 2>/dev/null)" ; then
elif gitbranch="${${"$(< $gitdir/HEAD)"}[1,7]}..." ; then
else
# Can't happen
Messages sorted by:
Reverse Date,
Date,
Thread,
Author