Skip to content

Instantly share code, notes, and snippets.

@Ronnie76er
Forked from mojodna/git-svn-diff.sh
Created May 5, 2010 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ronnie76er/391247 to your computer and use it in GitHub Desktop.
Save Ronnie76er/391247 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# 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:]]*/--- /"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment