4 echo "Invalid arguments!"
5 echo "$0 <commit to revert>"
9 if [ -n "$(git status -uno -s --porcelain)" ]; then
10 echo "You have unstashed changes. Please stash and then revert."
17 SVN_REVISION=$(git log -1 $COMMIT | grep git-svn-id | tr -s "@" " " | cut -f 4 -d " ")
19 if [ -z "$SVN_REVISION" ]; then
20 echo "Error! Given commit is not a git-svn revision!"
24 # Grab the one line message for our revert commit message.
25 ONE_LINE_MSG=$(git log --oneline $COMMIT -1 | cut -f2- -d " ")
28 git revert --no-commit $COMMIT 2>/dev/null
30 echo "Error! Failed to revert commit $COMMIT. Resetting to head."
35 # Create a template in our .git directory.
36 TEMPLATE="`git rev-parse --git-dir`/git-svn-revert-template"
38 Revert "$ONE_LINE_MSG"
40 This reverts commit r$SVN_REVISION.
43 # Begin the commit but give our user an opportunity to edit it.
44 git commit --file="$TEMPLATE" --edit
46 echo "Error! Failed to commit reverting commit for commit $COMMIT. Reverting to head."