Skip to content

Instantly share code, notes, and snippets.

@Bigcheese
Forked from mojodna/git-svn-diff.sh
Created June 10, 2010 08:03
Show Gist options
  • Save Bigcheese/432690 to your computer and use it in GitHub Desktop.
Save Bigcheese/432690 to your computer and use it in GitHub Desktop.
#!/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.*/===================================================================/" \
-e "/\/dev\/null/{N; s|/dev/null[^(]*\([^\n]*\)\n+++ \([^ ]*\).*|\2 \1\n+++ \2 (working copy)|;}"
@Bigcheese
Copy link
Author

This fixes a /dev/null problem I was having with mojodna's on windows git.

It takes:
--- /dev/null (revision 42)

+++ some/cool/file.txt (working copy)

and converts it to:
--- some/cool/file.txt (revision 42)

+++ some/cool/file.txt (working copy)

To work with TortoiseSVN patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment