{"thread":{"id":"20570","subject":"[PATCH] svn: initial \"master\" points to trunk if possible","startedAt":"2009-08-13T05:33:22Z","lastAt":"2009-08-13T05:33:22Z","messageCount":1,"participants":["Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"120490","messageId":"20090813053322.GA24694@dcvr.yhbt.net","threadId":"20570","inReplyTo":null,"subject":"[PATCH] svn: initial \"master\" points to trunk if possible","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-08-13T05:33:22Z","receivedAt":"2009-08-13T05:33:22Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Since \"trunk\" is a convention for the main development branch in\nthe SVN world, try to make that the master branch upon initial\ncheckout if it exists.  This is probably less surprising based\non user requests.\n\nt9135 was the only test which relied on the previous behavior\nand thus needed to be modified.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n\n  pushed out to git://yhbt.net/git-svn along with some others\n\n  Adam Brewster (1):\n        svn: allow branches outside of refs/remotes\n\n  Eric Wong (2):\n        svn: initial \"master\" points to trunk if possible\n        svn: (cleanup) use predefined constant for rev_map_fmt\n\n\n git-svn.perl                               |   11 +++++++++++\n t/t9135-git-svn-moved-branch-empty-file.sh |    7 ++++++-\n t/t9145-git-svn-master-branch.sh           |   25 +++++++++++++++++++++++++\n 3 files changed, 42 insertions(+), 1 deletions(-)\n create mode 100755 t/t9145-git-svn-master-branch.sh\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex b0bfb74..fad2960 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -1156,6 +1156,17 @@ sub post_fetch_checkout {\n \tmy $gs = $Git::SVN::_head or return;\n \treturn if verify_ref('refs/heads/master^0');\n \n+\t# look for \"trunk\" ref if it exists\n+\tmy $remote = Git::SVN::read_all_remotes()->{$gs->{repo_id}};\n+\tmy $fetch = $remote->{fetch};\n+\tif ($fetch) {\n+\t\tforeach my $p (keys %$fetch) {\n+\t\t\tbasename($fetch->{$p}) eq 'trunk' or next;\n+\t\t\t$gs = Git::SVN->new($fetch->{$p}, $gs->{repo_id}, $p);\n+\t\t\tlast;\n+\t\t}\n+\t}\n+\n \tmy $valid_head = verify_ref('HEAD^0');\n \tcommand_noisy(qw(update-ref refs/heads/master), $gs->refname);\n \treturn if ($valid_head || !verify_ref('HEAD^0'));\ndiff --git a/t/t9135-git-svn-moved-branch-empty-file.sh b/t/t9135-git-svn-moved-branch-empty-file.sh\nindex 03705fa..5280e5f 100755\n--- a/t/t9135-git-svn-moved-branch-empty-file.sh\n+++ b/t/t9135-git-svn-moved-branch-empty-file.sh\n@@ -10,7 +10,12 @@ test_expect_success 'load svn dumpfile'  '\n test_expect_success 'clone using git svn' 'git svn clone -s \"$svnrepo\" x'\n \n test_expect_success 'test that b1 exists and is empty' '\n-\t(cd x && test -f b1 && ! test -s b1)\n+\t(\n+\t\tcd x &&\n+\t\tgit reset --hard branch-c &&\n+\t\ttest -f b1 &&\n+\t\t! test -s b1\n+\t)\n \t'\n \n test_done\ndiff --git a/t/t9145-git-svn-master-branch.sh b/t/t9145-git-svn-master-branch.sh\nnew file mode 100755\nindex 0000000..16852d2\n--- /dev/null\n+++ b/t/t9145-git-svn-master-branch.sh\n@@ -0,0 +1,25 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2009 Eric Wong\n+#\n+test_description='git svn initial master branch is \"trunk\" if possible'\n+. ./lib-git-svn.sh\n+\n+test_expect_success 'setup test repository' '\n+\tmkdir i &&\n+\t> i/a &&\n+\tsvn_cmd import -m trunk i \"$svnrepo/trunk\" &&\n+\tsvn_cmd import -m b/a i \"$svnrepo/branches/a\" &&\n+\tsvn_cmd import -m b/b i \"$svnrepo/branches/b\"\n+'\n+\n+test_expect_success 'git svn clone --stdlayout sets up trunk as master' '\n+\tgit svn clone -s \"$svnrepo\" g &&\n+\t(\n+\t\tcd g &&\n+\t\ttest x`git rev-parse --verify refs/remotes/trunk^0` = \\\n+\t\t     x`git rev-parse --verify refs/heads/master^0`\n+\t)\n+'\n+\n+test_done\n-- \nEric Wong\n"}]}