Skip to content

Commit

Permalink
completion: enhance "current branch" display
Browse files Browse the repository at this point in the history
Introduce GIT_PS1_DESCRIBE option you can set to "contains", "branch", or
"describe" to tweak the way how a detached HEAD is described.

The default behaviour is to describe only exact match with some tag
(otherwise use the first 7 hexdigits) as before.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed May 17, 2009
1 parent ff790b6 commit dd42c2f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions contrib/completion/git-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,21 @@ __git_ps1 ()
fi

b="$(git symbolic-ref HEAD 2>/dev/null)" || {
b="$(git describe --exact-match HEAD 2>/dev/null)" ||

b="$(
case "${GIT_PS1_DESCRIBE_STYLE-}" in
(contains)
git describe --contains HEAD ;;
(branch)
git describe --contains --all HEAD ;;
(describe)
git describe HEAD ;;
(* | default)
git describe --exact-match HEAD ;;
esac 2>/dev/null)" ||

b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." ||
b="unknown"

b="($b)"
}
fi
Expand Down

0 comments on commit dd42c2f

Please sign in to comment.