Created
July 10, 2013 08:07
-
-
Save gorenje/5964348 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parse_git_branch () | |
{ | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return; | |
local a=""; | |
lb=${ref#refs/heads/}; | |
local ro=$(git config --get branch.${lb}.remote || echo "origin"); | |
local rb=$(git config --get branch.${lb}.merge); | |
rb=${rb#refs/heads/}; | |
local ab=; | |
if [ "" != "${rb}" ]; then | |
ab="(+$(git log --pretty=format:%H ${ro}/${rb}..${lb} | wc -w | sed s'/ //'g))"; | |
if [ "(+0)" = "${ab}" ]; then | |
ab="(-$(git log --pretty=format:%H ${lb}..${ro}/${rb} | wc -w | sed s'/ //'g))"; | |
fi; | |
if [ "(-0)" = "${ab}" ]; then | |
ab=""; | |
fi; | |
fi; | |
echo "("${ref#refs/heads/}")${ab}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment