darkrc/bin/git-pending

22 lines
427 B
Bash
Executable file

#!/bin/sh
repos() {
(for name in $@; do find -L $name -name '*.git' -type d | sed 's/\/.git$//'; done)
}
for line in $(repos "$@")
do
dir=$(pwd)
cd "$line"
if git log -0 2>/dev/null
then
stat=$(git branch -vv | grep -P '^\*' | grep -Po '\[.*\]')
if echo $stat | grep -P 'behind' > /dev/null
then echo behind $line
fi
if echo $stat | grep -P 'ahead' > /dev/null
then echo ahead $line
fi
fi
cd $dir
done