Skip to content

Instantly share code, notes, and snippets.

@andyscott
Created May 18, 2011 19:22
Show Gist options
  • Save andyscott/979320 to your computer and use it in GitHub Desktop.
Save andyscott/979320 to your computer and use it in GitHub Desktop.
Generate SVN Diff patches from GIT
#!/bin/sh
#
# git-svn-diff
# Generate an SVN-compatible diff against the tip of the tracking branch
# I didn't write this and I don't know who did!
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