From 40d9681b6294fbc6727056320e0f84b06885eeeb Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sat, 18 Aug 2018 15:49:47 +0000 Subject: 43313 (log message tweaked): vcs_info git: For the branch name, try to find a symbolic name before falling back to a raw commit hash. Ask git-describe(1) and git-name-rev(1) to compute a gitrevisions(7) 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". This would also happen during bisects, e.g., "bisect/bad~22". --- ChangeLog | 5 +++++ Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index c69774286..a0df4b107 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2018-08-24 Daniel Shahaf + * 43313 (log message tweaked): + Functions/VCS_Info/Backends/VCS_INFO_get_data_git: vcs_info git: + For the branch name, try to find a symbolic name before falling + back to a raw commit hash. + * 43314: Functions/VCS_Info/Backends/VCS_INFO_get_data_git: vcs_info git: Flatten a nested if. 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 -- cgit 1.4.1