Skip to content

Instantly share code, notes, and snippets.

@anthonywong
Last active February 1, 2018 07:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anthonywong/824fb7ef6138c63431b08872da1b7883 to your computer and use it in GitHub Desktop.
Save anthonywong/824fb7ef6138c63431b08872da1b7883 to your computer and use it in GitHub Desktop.
Calculate total number of commits from merges
n=0
PATTERN=ti-linux-4.14.y
while read line; do
hash=`echo "$line" | cut -f1 -d' '`
nn=`git show "$hash" | head -2 | tail -1 | awk '{ print $2".."$3 }' | xargs git log --pretty=oneline | wc -l`
echo "$nn": "$line"
n=$(($n + $nn))
done <<< "$(git log --grep 'Merge branch' --abbrev-commit --pretty=oneline | grep $PATTERN)"
echo "Total number of commits:" $n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment