X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=ls-not-pushed;h=4cbd831713773fad4b39c3cd8ec6c939bffb0bd7;hb=05a269340e7584e2a963c07907ce706bdcb8ee53;hp=bc950e5c678b24217b34858b1366418a66133d69;hpb=e364445d1adb40b906101cb3ce1acde85b2ffd36;p=git-scripts.git diff --git a/ls-not-pushed b/ls-not-pushed index bc950e5..4cbd831 100755 --- a/ls-not-pushed +++ b/ls-not-pushed @@ -1,2 +1,21 @@ #! /bin/sh -if git branch --verbose | grep -q "ahead\|behind"; then pwd; fi +if git branch --verbose | grep -q "\(ahead\|behind\) [0-9]"; then + up=`git rev-parse --abbrev-ref @{u} 2>/dev/null` + if [ -n "$up" -a "$up" != "@{u}" ]; then + set -- `git rev-list --count --left-right @{u}...HEAD` + left=$1 + right=$2 + s='' + if [ "$left" -gt 0 ]; then + s="$s-$left" + fi + if [ "$right" -gt 0 ]; then + s="$s+$right" + fi + fi + if [ -n "$s" ]; then + echo `pwd`: $s + else + pwd + fi +fi