Skip to content

Instantly share code, notes, and snippets.

@BenWard
Forked from mojodna/git-svn-diff.sh
Created February 10, 2010 19:57
Show Gist options
  • Save BenWard/300776 to your computer and use it in GitHub Desktop.
Save BenWard/300776 to your computer and use it in GitHub Desktop.
A script to generate svn-style diffs from git repositories, compatible with Review Board
#!/bin/sh
#
# git-svn-diff
# Generate an SVN-compatible diff against the tip of the tracking branch
TRACKING_BRANCH=`git config --get svn-remote.svn.fetch | sed -e 's/.*:refs\/remotes\///'`
REV=`git svn find-rev $(git rev-list --date-order --max-count=1 $TRACKING_BRANCH)`
git diff --no-prefix $(git rev-list --date-order --max-count=1 $TRACKING_BRANCH) $* |
sed -e "s/^+++ .*/& (working copy)/" -e "s/^--- .*/& (revision $REV)/" \
-e "s/^diff --git [^[:space:]]*/Index:/" \
-e "s/^index.*/===================================================================/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment