a1e90d9ea969682e3e6f9a708330e53bfe5e48c8 galt Wed Jun 30 18:57:39 2010 -0700 initial commit of gilt git status tool diff --git src/utils/gitTools/gilt src/utils/gitTools/gilt new file mode 100755 index 0000000..ab9bbde --- /dev/null +++ src/utils/gitTools/gilt @@ -0,0 +1,51 @@ +#!/bin/bash + +usage='gilt [-h] [dir] +Run git status on current or specified dir. + +Options: + -h or -help - print this message' + +while [[ $1 == -* ]] ; do + opt=$1 + shift + case "$opt" in + -h) echo "$usage" > /dev/stderr + exit 1 ;; + *) echo "Error: invalid option: $opt" > /dev/stderr + echo "$usage" > /dev/stderr + exit 1 ;; + esac +done + +dir="$1" +if [ "$dir" == "" ]; then + dir="." +fi +onbranch=`git branch | grep '^[*]' | sed -e 's/* //'` +mymaster=`git log HEAD ^origin/master | grep commit | wc -l` +omaster=`git log ^HEAD origin/master | grep commit | wc -l` +staged=`git diff --stat --cached $dir` +dirty=`git diff --stat $dir` + +echo "On $onbranch branch." + +echo "debug:mymaster=[$mymaster]" + +if [ "$mymaster" > 0 ] && [ "$omaster" > 0 ]; then + echo "Your branch is behind 'origin/master' by $omaster commits, and can be fast-forwarded." +elif (["$mymaster" == 0] && ["$omaster" > 0]); then + echo "Your branch is behind 'origin/master' by $omaster commits, and can be fast-forwarded." +elif (["$mymaster" > 0] && ["$omaster" == 0]); then + echo "Your branch is ahead of 'origin/master' by $mymaster commits." +fi + +if [ -n "$staged" ]; then + echo "staged:" + echo "$staged" +fi +if [ -n "$dirty" ]; then + echo "working-dir:" + echo "$dirty" +fi +