Skip to content

Instantly share code, notes, and snippets.

@offby1
Created March 12, 2009 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save offby1/78059 to your computer and use it in GitHub Desktop.
Save offby1/78059 to your computer and use it in GitHub Desktop.
#!/bin/sh
# See if git-svn really does let me dcommit to more than one branch.
#set -x
set -e
base=/tmp/experiment
rm -rf $base
mkdir -p $base
svnrepo=$base/svnrepo # $(mktemp -d)
svnURL=file://$svnrepo
svnwc=$base/svnwc # $(mktemp -d)
gitrepo=$base/gitrepo # $(mktemp -d)
#trap "for d in $svnwc $svnrepo $gitrepo; do rm -rf \$d; done" EXIT
# First make a tiny svn repo.
svnadmin create $svnrepo
for d in branches tags trunk; do svn mkdir $svnURL/$d -m $d; done
svn co $svnURL/trunk $svnwc
cd $svnwc
touch file
svn add file
svn commit -m "Create empty file in svn"
svn cp $svnURL/trunk $svnURL/branches/ted -m "ooh, a branch"
echo "Trunk data from svn" > file
svn commit -m "$(tail -1 file)"
svn switch $svnURL/branches/ted .
echo "Branch data from svn" >> file
svn commit -m "$(tail -1 file)"
# Now dump out the entire svn repo.
svn switch $svnURL .
find . -type f -name file -exec echo {} ';' -exec cat -n {} ';'
# Now import that into git.
git svn clone --stdlayout $svnURL $gitrepo
cd $gitrepo
# Make a change on trunk; commit it ...
# This is the crucial command -- without it, "dcommit" will commit to the branch, not the trunk.
git reset --hard remotes/trunk
git svn info | egrep URL:
echo "Trunk data from git" >> file
git add file
git commit -m "$(tail -1 file)"
git svn dcommit
# Make a change on a branch; commit it.
git checkout -b localted remotes/ted
git svn info | egrep URL:
echo "Branch data from git" >> file
git add file
git commit -m "$(tail -1 file)"
git svn dcommit
# Ensure the two changes are indeed on separate branches in svn.
svn log -v $svnURL
for b in trunk branches/ted
do
echo $b
svn cat $svnURL/$b/file | cat -n
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment