-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-svn-diff.sh
More file actions
executable file
·21 lines (18 loc) · 882 Bytes
/
git-svn-diff.sh
File metadata and controls
executable file
·21 lines (18 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh
# SPDX-License-Identifier: MIT
# Generate an SVN-compatible diff against the tip of the tracking branch
#
# usage: git-svn-diff [git-diff-args] > an-svn.patch
TRACKING_BRANCH=$(git config --get svn-remote.svn.fetch | sed -e 's/.*:refs\/remotes\///')
SVN_REV=$(git svn info | grep 'Last Changed Rev:' | sed -E 's/^.*: ([[:digit:]]*)/\1/')
ARGS=$(git rev-list --date-order --max-count=1 $TRACKING_BRANCH)
[ $# -gt 0 ] && ARGS="$@"
git diff --no-prefix $ARGS |
sed -e "/--- \/dev\/null/{ N; s|^--- /dev/null\n+++ \(.*\)|--- \1 (revision 0)\n+++ \1 (working copy)|;}" \
-e "s/^--- .*/& (revision $SVN_REV)/" \
-e "s/^+++ .*/& (working copy)/" \
-e "s/^\(@@.*@@\).*/\1/" \
-e "s/^diff --git [^[:space:]]*/Index:/" \
-e "s/^index.*/===================================================================/" \
-e "/^new file mode [0-9]\+$/d" \
--binary