Skip to content

Instantly share code, notes, and snippets.

Forked from mojodna/
Created May 5, 2010 18:43
What would you like to do?
# git-create-review
# Generates a diff based on a grep in the comments of the commits
REV_NUMS=`git log --grep=$1 --oneline -i --reverse | awk '{print $1;}'`
for revhash in $REV_NUMS; do
PREV_SVN_REV=`git svn find-rev $revhash^`
SVN_REV=`git svn find-rev $revhash`
git diff --no-prefix $revhash^..$revhash |
sed -e "/^diff --git [^[:space:]]*/{h;}" \
-e "s/^diff --git [^[:space:]]*/Index:/" \
-e "s/^index.*/===================================================================/" \
-e "/^new file .*/d" \
-e "/^--- \/dev\/null/{g;}" \
-e "s/^diff --git [^[:space:]]*/-+-/" \
-e "s/^+++ .*/&\t(revision $SVN_REV)/" -e "s/^--- .*/&\t(revision $PREV_SVN_REV)/" -e "s/^-+- .*/&\t(revision 0)/" \
-e "s/^-+- [[:space:]]*/--- /"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment