llvm.org GIT mirror llvm / 19c3735
Added the scripts git-svnup/git-svnrevert to utils/git-svn. It makes more sense to have git-svnup here than catting said file in the documentation (where we should rather point users to this directory). I included git-svnrevert as an additional gift to the community. I will update the documentation in a second commit later today. git-svnrevert takes in a git hash for a commit, looks up the svn revision for said commit and then creates the normal git revert commit message with the one liner message, except instead of saying Revert "<<<INSERT ONELINER HERE>>>" This reverts commit <<<INSERT GITHASH HERE>>> It says: Revert "<<<INSERT ONELINER HERE>>>" This reverts commit r<<<INSERT SVN REVISION HERE>>> so git hashes will not escape into our svn logs (which just look unseemly). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180587 91177308-0d34-0410-b5e6-96231b3b80d8 Michael Gottesman 6 years ago
2 changed file(s) with 68 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 #!/bin/bash
1
2 if [ $# -ne 1 ]; then
3 echo "Invalid arguments!"
4 echo "$0 "
5 exit 1
6 fi
7
8 if [ -n "$(git status -uno -s --porcelain)" ]; then
9 echo "You have unstashed changes. Please stash and then revert."
10 git status -uno
11 exit 1
12 fi
13
14 COMMIT=$1
15
16 SVN_REVISION=$(git log -1 $COMMIT | grep git-svn-id | tr -s "@" " " | cut -f 4 -d " ")
17
18 if [ -z "$SVN_REVISION" ]; then
19 echo "Error! Given commit is not a git-svn revision!"
20 exit 1
21 fi
22
23 # Grab the one line message for our revert commit message.
24 ONE_LINE_MSG=$(git log --oneline $COMMIT -1 | cut -f2- -d " ")
25
26 # Revert the commit.
27 git revert --no-commit $COMMIT 2>/dev/null
28 if [ $? -ne 0 ]; then
29 echo "Error! Failed to revert commit $COMMIT. Resetting to head."
30 git reset --hard HEAD
31 exit 1
32 fi
33
34 # Create a template in our .git directory.
35 TEMPLATE="`git rev-parse --git-dir`/git-svn-revert-template"
36 cat > $TEMPLATE <
37 Revert "$ONE_LINE_MSG"
38
39 This reverts commit r$SVN_REVISION.
40 EOF
41
42 # Begin the commit but give our user an opportunity to edit it.
43 git commit --file="$TEMPLATE" --edit
44 if [ $? -ne 0 ]; then
45 echo "Error! Failed to commit reverting commit for commit $COMMIT. Reverting to head."
46 git reset --hard HEAD
47 rm -rf $TEMPLATE
48 exit 1
49 fi
50
51 rm -rf $TEMPLATE
52
0 #!/bin/bash
1
2 if [ -n "`git status -uno -s --porcelain`" ]; then
3 echo "You have unstashed changes. Can not update repository..."
4 git status -uno
5 exit 1
6 fi
7
8 git fetch
9 OLD_BRANCH=$(git rev-parse --abbrev-ref HEAD)
10 git checkout master 2> /dev/null
11 git svn rebase -l
12 git checkout $OLD_BRANCH 2> /dev/null
13
14 exit 0