Hook fixes and much faster commitbranch
[socialgit.git] / bin / changebranch
blob896283de59626dfeb1d00e61ae891e5bbe6517ec
1 #!/bin/sh
2 # changebranch
4 CURBRANCH=`currentbranchname`
5 if [ "$CURBRANCH" = "$1" ]; then
6 exit
7 fi
9 if (( $(git diff HEAD | wc -l) > 0 )); then
10 git branch $CURBRANCH.dirty
11 git checkout $CURBRANCH.dirty
12 echo "stashing dirty working copy" | git commit -a -F -
15 git fetch
16 git checkout -b $1 origin/$1
17 git checkout $1
19 if [ `git branch | grep $1.dirty` ]; then
20 git diff $1 $1.dirty | git apply
21 git branch -D $1.dirty
24 # HOOK
25 HOOK_POST_CHANGE_BRANCH=./`git rev-parse --show-cdup`.socialgit/hooks/post-change-branch
26 ls $HOOK_POST_CHANGE_BRANCH 2>/dev/null && $HOOK_POST_CHANGE_BRANCH