Skip to content

Instantly share code, notes, and snippets.

@0livier
Created June 28, 2016 07:12
Show Gist options
  • Save 0livier/61656cb3a6b99f47e49469bdc31fb20c to your computer and use it in GitHub Desktop.
Save 0livier/61656cb3a6b99f47e49469bdc31fb20c to your computer and use it in GitHub Desktop.
Git grep in all merges/commits into the current branch since a specif data
#!/usr/bin/env bash
if [ $# -eq 0 ]
then
self=$(basename $0)
echo "Usage: $self pattern directory"
exit 1
fi
pattern=$1
since="--since=2015-12-01"
for revision in `git --no-pager log $since --first-parent --format="%H"`
do
timestamp=`git --no-pager log --format='%at' -n 1 $revision`
count=`git --no-pager grep --extended-regexp $pattern $revision | wc -l | tr -d '[[:space:]]'`
echo $revision,$timestamp,$count
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment