Skip to content

Instantly share code, notes, and snippets.

@HEYRIX
Forked from tangqiaoboy/git-svn-diff.sh
Created January 28, 2016 03:28
Show Gist options
  • Save HEYRIX/178eb012f48e70eb23e7 to your computer and use it in GitHub Desktop.
Save HEYRIX/178eb012f48e70eb23e7 to your computer and use it in GitHub Desktop.
生成git-svn下svn兼容的diff文件
#!/bin/bash
# Get the tracking branch (if we're on a branch)
TRACKING_BRANCH=`git svn info | grep URL `
# If the tracking branch has 'URL' at the beginning, then the sed wasn't successful and
# we'll fall back to the svn-remote config option
if [[ "$TRACKING_BRANCH" =~ URL.* ]]
then
TRACKING_BRANCH=`git config --get svn-remote.svn.fetch | sed -e 's/.*:refs\/remotes\///'`
fi
# Get the highest revision number
REV=`git svn find-rev $(git rev-list --date-order --max-count=1 $TRACKING_BRANCH)`
# Then do the diff from the highest revition on the current 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.*/===================================================================/"
@HEYRIX
Copy link
Author

HEYRIX commented Nov 27, 2018

hix hirecandidate 2016153303920201

@HEYRIX
Copy link
Author

HEYRIX commented Nov 27, 2018

hix hirecandidate 2016153303920202

@HEYRIX
Copy link
Author

HEYRIX commented Nov 27, 2018

hix hirecandidate 2016153303920203

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