summaryrefslogtreecommitdiff
path: root/t/t9107-git-svn-migrate.sh
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2007-01-19 01:50:01 (GMT)
committerEric Wong <normalperson@yhbt.net>2007-02-23 08:57:09 (GMT)
commit706587fc6d56db1ba6c7207d4c0c456bac6f77c2 (patch)
tree85b61d54b9e816ee3981838fd8adbe396f24c28e /t/t9107-git-svn-migrate.sh
parentd05d72e07e49869fe988d4d99e6ac60711570db5 (diff)
downloadgit-706587fc6d56db1ba6c7207d4c0c456bac6f77c2.zip
git-706587fc6d56db1ba6c7207d4c0c456bac6f77c2.tar.gz
git-706587fc6d56db1ba6c7207d4c0c456bac6f77c2.tar.bz2
git-svn: add support for metadata in .git/config
Of course, we handle metadata migrations from previous versions and we have added unit tests. The new .git/config remotes resemble non-SVN remotes. Below is an example with comments: [svn-remote "git-svn"] ; like non-svn remotes, we have one URL per-remote url = http://foo.bar.org/svn ; 'fetch' keys are done in the same way as non-svn ; remotes, too. With the left-hand-side of the ':' ; being the remote (SVN) repository path relative to the ; above 'url' key; and the right-hand-side being a ; remote ref in git (refs/remotes/*). ; An empty left-hand-side means that it will fetch ; the entire contents of the 'url' key. ; old-style (migrated from previous versions of git-svn) ; are like this: fetch = :refs/remotes/git-svn ; this is created by a current version of git-svn ; using the multi-init command with an explicit ; url (specified above). This allows multi-init ; to reuse SVN::Ra connections. fetch = trunk:refs/remotes/trunk fetch = branches/a:refs/remotes/a fetch = branches/b:refs/remotes/b fetch = tags/0.1:refs/remotes/tags/0.1 fetch = tags/0.2:refs/remotes/tags/0.2 fetch = tags/0.3:refs/remotes/tags/0.3 [svn-remote "alt"] ; this is another old-style remote migrated over ; to the new config format url = http://foo.bar.org/alt fetch = :refs/remotes/alt Signed-off-by: Eric Wong <normalperson@yhbt.net>
Diffstat (limited to 't/t9107-git-svn-migrate.sh')
-rwxr-xr-xt/t9107-git-svn-migrate.sh63
1 files changed, 63 insertions, 0 deletions
diff --git a/t/t9107-git-svn-migrate.sh b/t/t9107-git-svn-migrate.sh
new file mode 100755
index 0000000..53318f1
--- /dev/null
+++ b/t/t9107-git-svn-migrate.sh
@@ -0,0 +1,63 @@
+#!/bin/sh
+# Copyright (c) 2006 Eric Wong
+test_description='git-svn metadata migrations from previous versions'
+. ./lib-git-svn.sh
+
+test_expect_success 'setup old-looking metadata' "
+ cp $GIT_DIR/config $GIT_DIR/config-old-git-svn &&
+ git-svn init $svnrepo &&
+ git-svn fetch &&
+ for i in trunk branches/a branches/b tags/0.1 tags/0.2 tags/0.3; do
+ mkdir -p \$i && echo hello >> \$i/README || exit 1; done &&
+ git ls-files -o trunk branches tags | git update-index --add --stdin &&
+ git commit -m 'test' &&
+ git-svn dcommit &&
+ mv $GIT_DIR/svn/* $GIT_DIR/ &&
+ rmdir $GIT_DIR/svn &&
+ git-update-ref refs/heads/git-svn-HEAD refs/remotes/git-svn &&
+ git-update-ref refs/heads/svn-HEAD refs/remotes/git-svn &&
+ git-update-ref -d refs/remotes/git-svn refs/remotes/git-svn
+ "
+
+head=`git rev-parse --verify refs/heads/git-svn-HEAD^0`
+test_expect_success 'git-svn-HEAD is a real HEAD' "test -n '$head'"
+
+test_expect_success 'initialize old-style (v0) git-svn layout' "
+ mkdir -p $GIT_DIR/git-svn/info $GIT_DIR/svn/info &&
+ echo $svnrepo > $GIT_DIR/git-svn/info/url &&
+ echo $svnrepo > $GIT_DIR/svn/info/url &&
+ git-svn migrate &&
+ ! test -d $GIT_DIR/git-svn &&
+ git-rev-parse --verify refs/remotes/git-svn^0 &&
+ git-rev-parse --verify refs/remotes/svn^0 &&
+ test \`git repo-config --get svn-remote.git-svn.url\` = '$svnrepo' &&
+ test \`git repo-config --get svn-remote.git-svn.fetch\` = \
+ ':refs/remotes/git-svn'
+ "
+
+test_expect_success 'initialize a multi-repository repo' "
+ git-svn multi-init $svnrepo -T trunk -t tags -b branches &&
+ git-repo-config --get-all svn-remote.git-svn.fetch > fetch.out &&
+ grep '^trunk:refs/remotes/trunk$' fetch.out &&
+ grep '^branches/a:refs/remotes/a$' fetch.out &&
+ grep '^branches/b:refs/remotes/b$' fetch.out &&
+ grep '^tags/0\.1:refs/remotes/tags/0\.1$' fetch.out &&
+ grep '^tags/0\.2:refs/remotes/tags/0\.2$' fetch.out &&
+ grep '^tags/0\.3:refs/remotes/tags/0\.3$' fetch.out
+ "
+
+test_expect_success 'multi-fetch works on partial urls + paths' "
+ git-svn multi-fetch &&
+ for i in trunk a b tags/0.1 tags/0.2 tags/0.3; do
+ git rev-parse --verify refs/remotes/\$i^0 >> refs.out || exit 1;
+ done &&
+ test -z \"\`sort < refs.out | uniq -d\`\" &&
+ for i in trunk a b tags/0.1 tags/0.2 tags/0.3; do
+ for j in trunk a b tags/0.1 tags/0.2 tags/0.3; do
+ if test \$j != \$i; then continue; fi
+ test -z \"\`git diff refs/remotes/\$i \
+ refs/remotes/\$j\`\" ||exit 1; done; done
+ "
+
+test_done
+