File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -18,11 +18,16 @@ find_git_branch() {
1818 if tag=$( git describe --exact-match >&1 2> /dev/null) ; then
1919 branch=" +$tag "
2020 else
21- # branch='<detached>'
22- # Or show the short hash
23- branch=' #' $( git rev-parse --short HEAD 2> /dev/null)
24- # Or the long hash, with no leading '#'
25- # branch=$(git rev-parse HEAD 2> /dev/null)
21+ # If it a remote branch, show that.
22+ branch=$( git name-rev --name-only HEAD | sed ' s+^remotes/++' )
23+ # But name-rev will also return if it is a few steps back from a remote branch, which sucks, so don't display that.
24+ if [[ " $branch " == " undefined" ]] || grep ' \~' <<< " $branch" > /dev/null; then
25+ # branch='<detached>'
26+ # Or show the short hash
27+ branch=' #' $( git rev-parse --short HEAD 2> /dev/null)
28+ # Or the long hash, with no leading '#'
29+ # branch=$(git rev-parse HEAD 2> /dev/null)
30+ fi
2631 fi
2732 else
2833 # This is a named branch. (It might be local or remote.)
You can’t perform that action at this time.
0 commit comments