summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonid Volnitsky <Leonid@Volnitsky.com>2008-06-25 12:22:54 +0300
committerLeonid Volnitsky <Leonid@Volnitsky.com>2008-06-25 12:25:21 +0300
commitea5084073849ccad41b16e3a227f4eb625e1d048 (patch)
tree5255413d5262892b2880cb8997a98cc082dc9b49
parentadded init state (diff)
downloadgit-prompt-ea5084073849ccad41b16e3a227f4eb625e1d048.tar.gz
git-prompt-ea5084073849ccad41b16e3a227f4eb625e1d048.tar.bz2
git-prompt-ea5084073849ccad41b16e3a227f4eb625e1d048.zip
rfct: cleaner vcs_info composition
-rwxr-xr-xprompt36
1 files changed, 19 insertions, 17 deletions
diff --git a/prompt b/prompt
index c9c64a5..78f9889 100755
--- a/prompt
+++ b/prompt
@@ -258,6 +258,7 @@ parse_git_dir() {
vcs=git
+ ########################################################## GIT STATUS
eval `
git status 2>/dev/null |
sed -n "
@@ -288,6 +289,10 @@ parse_git_dir() {
"
`
+ if ! grep -q "^ref:" $git_dir/HEAD 2>/dev/null; then
+ detached=detached
+ fi
+
### OP
unset op
@@ -323,31 +328,28 @@ parse_git_dir() {
# branch="$(cut -c1-7 "$git_dir/HEAD")..."
fi
+ #####################################################################
+
+ rawhex=`git-rev-parse HEAD 2>/dev/null`
+ rawhex=${rawhex/HEAD/}
+ rawhex=${rawhex:0:6}
### branch
branch=${branch/master/M}
- # if rawhex in .git/HEAD, then detached head
- if ! grep -q "^ref:" $git_dir/HEAD 2>/dev/null; then
- detached=detached
- branch="<detached:`git-name-rev --name-only HEAD 2>/dev/null`>"
- fi
- #
- # another method of above:
- # branch=$(git-symbolic-ref -q HEAD || { echo -n "detached:" ; git-name-rev --name-only HEAD 2>/dev/null; } )
- # branch=${branch#refs/heads/}
- #
+ # another method of above:
+ # branch=$(git-symbolic-ref -q HEAD || { echo -n "detached:" ; git-name-rev --name-only HEAD 2>/dev/null; } )
+ # branch=${branch#refs/heads/}
- rawhex=`git-rev-parse HEAD 2>/dev/null`
- rawhex=${rawhex/HEAD/}
- rawhex=${rawhex:0:6}
+ ### compose vcs_info
- ### compose vcs_info
+ if [[ "$detached" ]] ; then
+ vcs_info="<detached:`git-name-rev --name-only HEAD 2>/dev/null`$white=$rawhex>"
- if [[ "$op" == "merge" ]] ; then
- vcs_info="$op: $branch <~ $(git-name-rev --name-only $(<$git_dir/MERGE_HEAD))$white/$rawhex"
+ elif [[ "$op" == "merge" ]] ; then
+ vcs_info="$op: $branch <~ $(git-name-rev --name-only $(<$git_dir/MERGE_HEAD))$white=$rawhex"
elif [[ "$op" ]]; then
vcs_info="<$op:$branch>"
@@ -356,7 +358,7 @@ parse_git_dir() {
vcs_info=init
else
- vcs_info="${branch}$white/$rawhex"
+ vcs_info="${branch}$white=$rawhex"
fi
}