X-Git-Url: https://git.phdru.name/?p=git-scripts.git;a=blobdiff_plain;f=ls-not-pushed;h=506019032b285f5975682ef83a423b4091754756;hp=7e9bb4e59f172f61605966b9d1fb5e0273b4429b;hb=HEAD;hpb=396a2fe8b0c7352fac32db0f7c0e65b92930904b diff --git a/ls-not-pushed b/ls-not-pushed index 7e9bb4e..4cbd831 100755 --- a/ls-not-pushed +++ b/ls-not-pushed @@ -1,6 +1,21 @@ #! /bin/sh - -exec "`dirname \"$0\"`"/do-all \ - 'test "$g" = "$d/.git" || continue; cd "$d" &&' \ - 'test -n "`git status --branch --short | grep "ahead\|behind"`" && - echo "$d"' +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