summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-10-23 20:21:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-10-23 20:21:45 (GMT)
commit807c895fcbf004d7a8f2bfd9aae5ea3b4f0c760b (patch)
treea5dc9fe5f5fe73b37c4bb583ee63c453f1f8a26f /contrib
parentf2c1b01c24b6c1df962a6526661cf3a58f3c6a56 (diff)
parent1f6806cf2da84e30d162ca3aee15d16db4f1daef (diff)
downloadgit-807c895fcbf004d7a8f2bfd9aae5ea3b4f0c760b.zip
git-807c895fcbf004d7a8f2bfd9aae5ea3b4f0c760b.tar.gz
git-807c895fcbf004d7a8f2bfd9aae5ea3b4f0c760b.tar.bz2
Merge branch 'jc/prompt-upstream'
An enhancement to the GIT_PS1_SHOWUPSTREAM facility. * jc/prompt-upstream: git-prompt.sh: optionally show upstream branch name
Diffstat (limited to 'contrib')
-rw-r--r--contrib/completion/git-prompt.sh7
1 files changed, 6 insertions, 1 deletions
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index d6c61b2..202e2e5 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -60,6 +60,7 @@
# of values:
#
# verbose show number of commits ahead/behind (+/-) upstream
+# name if verbose, then also show the upstream abbrev name
# legacy don't use the '--count' option available in recent
# versions of git-rev-list
# git always compare HEAD to @{upstream}
@@ -94,7 +95,7 @@ __git_ps1_show_upstream ()
{
local key value
local svn_remote svn_url_pattern count n
- local upstream=git legacy="" verbose=""
+ local upstream=git legacy="" verbose="" name=""
svn_remote=()
# get some config options from git-config
@@ -122,6 +123,7 @@ __git_ps1_show_upstream ()
git|svn) upstream="$option" ;;
verbose) verbose=1 ;;
legacy) legacy=1 ;;
+ name) name=1 ;;
esac
done
@@ -204,6 +206,9 @@ __git_ps1_show_upstream ()
*) # diverged from upstream
p=" u+${count#* }-${count% *}" ;;
esac
+ if [[ -n "$count" && -n "$name" ]]; then
+ p="$p $(git rev-parse --abbrev-ref "$upstream" 2>/dev/null)"
+ fi
fi
}