2 # Generate an SVN-compatible diff against the tip of the tracking branch
4 # Get the tracking branch (if we're on a branch)
5 TRACKING_BRANCH
=`git svn info | grep URL | sed -e 's/.*\/branches\///'`
7 # If the tracking branch has 'URL' at the beginning, then the sed wasn't successful
8 # and we'll fall back to the svn-remote config option
9 if [[ "$TRACKING_BRANCH" =~ URL.
* ]]
11 TRACKING_BRANCH
=`git config --get svn-remote.svn.fetch | sed -e 's/.*:refs\/remotes\///'`
14 # Get the highest revision number
15 REV
=`git svn find-rev $(git rev-list --date-order --max-count=1 $TRACKING_BRANCH)`
16 #REV=`git svn info | grep 'Last Changed Rev:' | sed -E 's/^.*: ([[:digit:]]*)/\1/'`
18 # Then do the diff from the highest revision on the current branch and convert to SVN format
19 git
diff --no-prefix --no-indent-heuristic $
(git rev-list
--date-order --max-count=1 $TRACKING_BRANCH) $
* |
20 sed -e "/--- \/dev\/null/{ N; s|^--- /dev/null\n+++ \(.*\)|--- \1 (nonexistent)\n+++ \1 (working copy)|;n}" \
21 -e "s/^--- .*/& (revision $REV)/" \
22 -e "s/^+++ .*/& (working copy)/" \
23 -e "s/^\(@@.*@@\).*/\1/" \
24 -e "s/^diff --git [^[:space:]]*/Index:/" \
25 -e "s/^index.*/===================================================================/" \
26 -e "/^new file mode [0-9]\+$/d" \
27 -e "/^deleted file mode [0-9]\+$/d"