{"thread":{"id":"20364","subject":"[PATCH] svn: Add && to t9107-git-svn-migrarte.sh","startedAt":"2009-08-04T01:40:36Z","lastAt":"2009-08-13T05:36:17Z","messageCount":12,"participants":["Adam Brewster","Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"119452","messageId":"1249350039-7338-1-git-send-email-adambrewster@gmail.com","threadId":"20364","inReplyTo":null,"subject":"[PATCH/RFC] svn manipulate refs ourside refs/remotes","fromName":"Adam Brewster","fromEmail":"adambrewster@gmail.com","sentAt":"2009-08-04T01:40:36Z","receivedAt":"2009-08-04T01:40:36Z","isPatch":true,"sender":{"key":"adambrewster@gmail.com","avatar":"https://avatars.githubusercontent.com/u/223816?v=4"},"body":"I took some time this weekend and tried to allow git-svn to manipulate\nbranches outside of refs/remotes.  Along the way I came across a couple\nof other issues that may or may not be bugs.\n\nI'd appreciate it if somebody could take a look at the following\npatches.  The first two are small and well described by their respective\ncommit messages.  The third has the bulk of the changes I made.\n\nNote that make t/t9107-git-svn-migrate.sh fails when the first or third\npatches are applied.  I can't tell if this is a false alarm or if the\ncode is really doing something it shouldn't.\n\n - Adam Brewster\n"},{"id":"119449","messageId":"1249350039-7338-2-git-send-email-adambrewster@gmail.com","threadId":"20364","inReplyTo":"1249350039-7338-1-git-send-email-adambrewster@gmail.com","subject":"[PATCH] svn: Add && to t9107-git-svn-migrarte.sh","fromName":"Adam Brewster","fromEmail":"adambrewster@gmail.com","sentAt":"2009-08-04T01:40:37Z","receivedAt":"2009-08-04T01:40:37Z","isPatch":true,"sender":{"key":"adambrewster@gmail.com","avatar":"https://avatars.githubusercontent.com/u/223816?v=4"},"body":"It was probably intended for the test to fail unless all of the\ncommands succeed.\n---\n t/t9107-git-svn-migrate.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/t/t9107-git-svn-migrate.sh b/t/t9107-git-svn-migrate.sh\nindex 3a9e077..145a367 100755\n--- a/t/t9107-git-svn-migrate.sh\n+++ b/t/t9107-git-svn-migrate.sh\n@@ -93,7 +93,7 @@ test_expect_success 'migrate --minimize on old inited layout' '\n \tgrep \"^branches/b:refs/remotes/b$\" fetch.out &&\n \tgrep \"^tags/0\\.1:refs/remotes/tags/0\\.1$\" fetch.out &&\n \tgrep \"^tags/0\\.2:refs/remotes/tags/0\\.2$\" fetch.out &&\n-\tgrep \"^tags/0\\.3:refs/remotes/tags/0\\.3$\" fetch.out\n+\tgrep \"^tags/0\\.3:refs/remotes/tags/0\\.3$\" fetch.out &&\n \tgrep \"^:refs/${remotes_git_svn}\" fetch.out\n \t'\n \n-- \n1.6.0.6\n"},{"id":"119450","messageId":"1249350039-7338-3-git-send-email-adambrewster@gmail.com","threadId":"20364","inReplyTo":"1249350039-7338-2-git-send-email-adambrewster@gmail.com","subject":"[PATCH] svn: Honor --prefix option in init without --stdlayout","fromName":"Adam Brewster","fromEmail":"adambrewster@gmail.com","sentAt":"2009-08-04T01:40:38Z","receivedAt":"2009-08-04T01:40:38Z","isPatch":true,"sender":{"key":"adambrewster@gmail.com","avatar":"https://avatars.githubusercontent.com/u/223816?v=4"},"body":"Most users who type\n\n  git svn init file:///tmp/repo --prefix=my-svn/\n\nwould expect the root of the svn repository to be tracked by\nrefs/remotes/my-svn/git-svn.\n---\n git-svn.perl |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 9369acc..51e3f92 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -3266,7 +3266,8 @@ sub _new {\n \t\t$repo_id = $Git::SVN::default_repo_id;\n \t}\n \tunless (defined $ref_id && length $ref_id) {\n-\t\t$_[2] = $ref_id = $Git::SVN::default_ref_id;\n+\t\t$_prefix = '' unless defined($_prefix);\n+\t\t$_[2] = $ref_id = $_prefix . $Git::SVN::default_ref_id;\n \t}\n \t$_[1] = $repo_id;\n \tmy $dir = \"$ENV{GIT_DIR}/svn/$ref_id\";\n-- \n1.6.0.6\n"},{"id":"119451","messageId":"1249350039-7338-4-git-send-email-adambrewster@gmail.com","threadId":"20364","inReplyTo":"1249350039-7338-3-git-send-email-adambrewster@gmail.com","subject":"[PATCH] svn: allow git-svn to update remotes outside of refs/remotes","fromName":"Adam Brewster","fromEmail":"adambrewster@gmail.com","sentAt":"2009-08-04T01:40:39Z","receivedAt":"2009-08-04T01:40:39Z","isPatch":true,"sender":{"key":"adambrewster@gmail.com","avatar":"https://avatars.githubusercontent.com/u/223816?v=4"},"body":"It may be convenient for some users to store svn remote tracking\nbranches outside of the refs/remotes/ heirarchy.  [1] and [2] indicate\nthat there is interest in making this possible.\n\n[1]  http://www.gitready.com/advanced/2009/02/16/convert-git-svn-tag-branches-to-real-tags.html\n[2] http://kerneltrap.org/mailarchive/git/2007/8/30/256359\n---\n git-svn.perl                     |   75 ++++++++++++++++++++------------------\n t/lib-git-svn.sh                 |    2 +-\n t/t9104-git-svn-follow-parent.sh |   10 +++---\n t/t9107-git-svn-migrate.sh       |   14 +++----\n 4 files changed, 51 insertions(+), 50 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 51e3f92..4d7175b 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -883,7 +883,7 @@ sub cmd_multi_init {\n \t}\n \tdo_git_init_db();\n \tif (defined $_trunk) {\n-\t\tmy $trunk_ref = $_prefix . 'trunk';\n+\t\tmy $trunk_ref = 'refs/remotes/' . $_prefix . 'trunk';\n \t\t# try both old-style and new-style lookups:\n \t\tmy $gs_trunk = eval { Git::SVN->new($trunk_ref) };\n \t\tunless ($gs_trunk) {\n@@ -1590,23 +1590,23 @@ sub resolve_local_globs {\n \treturn unless defined $glob_spec;\n \tmy $ref = $glob_spec->{ref};\n \tmy $path = $glob_spec->{path};\n-\tforeach (command(qw#for-each-ref --format=%(refname) refs/remotes#)) {\n-\t\tnext unless m#^refs/remotes/$ref->{regex}$#;\n+\tforeach (command(qw#for-each-ref --format=%(refname) refs/#)) {\n+\t\tnext unless m#^$ref->{regex}$#;\n \t\tmy $p = $1;\n \t\tmy $pathname = desanitize_refname($path->full_path($p));\n \t\tmy $refname = desanitize_refname($ref->full_path($p));\n \t\tif (my $existing = $fetch->{$pathname}) {\n \t\t\tif ($existing ne $refname) {\n \t\t\t\tdie \"Refspec conflict:\\n\",\n-\t\t\t\t    \"existing: refs/remotes/$existing\\n\",\n-\t\t\t\t    \" globbed: refs/remotes/$refname\\n\";\n+\t\t\t\t    \"existing: $existing\\n\",\n+\t\t\t\t    \" globbed: $refname\\n\";\n \t\t\t}\n-\t\t\tmy $u = (::cmt_metadata(\"refs/remotes/$refname\"))[0];\n+\t\t\tmy $u = (::cmt_metadata(\"$refname\"))[0];\n \t\t\t$u =~ s!^\\Q$url\\E(/|$)!! or die\n-\t\t\t  \"refs/remotes/$refname: '$url' not found in '$u'\\n\";\n+\t\t\t  \"$refname: '$url' not found in '$u'\\n\";\n \t\t\tif ($pathname ne $u) {\n \t\t\t\twarn \"W: Refspec glob conflict \",\n-\t\t\t\t     \"(ref: refs/remotes/$refname):\\n\",\n+\t\t\t\t     \"(ref: $refname):\\n\",\n \t\t\t\t     \"expected path: $pathname\\n\",\n \t\t\t\t     \"    real path: $u\\n\",\n \t\t\t\t     \"Continuing ahead with $u\\n\";\n@@ -1684,33 +1684,34 @@ sub read_all_remotes {\n \tmy $use_svm_props = eval { command_oneline(qw/config --bool\n \t    svn.useSvmProps/) };\n \t$use_svm_props = $use_svm_props eq 'true' if $use_svm_props;\n+\tmy $svn_refspec = qr{\\s*/?(.*?)\\s*:\\s*(.+?)\\s*};\n \tforeach (grep { s/^svn-remote\\.// } command(qw/config -l/)) {\n-\t\tif (m!^(.+)\\.fetch=\\s*(.*)\\s*:\\s*(.+)\\s*$!) {\n-\t\t\tmy ($remote, $local_ref, $_remote_ref) = ($1, $2, $3);\n-\t\t\tdie(\"svn-remote.$remote: remote ref '$_remote_ref' \"\n-\t\t\t    . \"must start with 'refs/remotes/'\\n\")\n-\t\t\t\tunless $_remote_ref =~ m{^refs/remotes/(.+)};\n-\t\t\tmy $remote_ref = $1;\n-\t\t\t$local_ref =~ s{^/}{};\n+\t\tif (m!^(.+)\\.fetch=$svn_refspec$!) {\n+\t\t\tmy ($remote, $local_ref, $remote_ref) = ($1, $2, $3);\n+\t\t\tdie(\"svn-remote.$remote: remote ref '$remote_ref' \"\n+\t\t\t    . \"must start with 'refs/'\\n\")\n+\t\t\t\tunless $remote_ref =~ m{^refs/};\n \t\t\t$r->{$remote}->{fetch}->{$local_ref} = $remote_ref;\n \t\t\t$r->{$remote}->{svm} = {} if $use_svm_props;\n \t\t} elsif (m!^(.+)\\.usesvmprops=\\s*(.*)\\s*$!) {\n \t\t\t$r->{$1}->{svm} = {};\n \t\t} elsif (m!^(.+)\\.url=\\s*(.*)\\s*$!) {\n \t\t\t$r->{$1}->{url} = $2;\n-\t\t} elsif (m!^(.+)\\.(branches|tags)=\n-\t\t           (.*):refs/remotes/(.+)\\s*$/!x) {\n-\t\t\tmy ($p, $g) = ($3, $4);\n+\t\t} elsif (m!^(.+)\\.(branches|tags)=$svn_refspec$!) {\n+\t\t\tmy ($remote, $t, $local_ref, $remote_ref) = ($1, $2, $3, $4);\n+\t\t\tdie(\"svn-remote.$remote: remote ref '$remote_ref' ($t) \"\n+\t\t\t    . \"must start with 'refs/'\\n\")\n+\t\t\t\tunless $remote_ref =~ m{^refs/};\n \t\t\tmy $rs = {\n-\t\t\t    t => $2,\n-\t\t\t    remote => $1,\n-\t\t\t    path => Git::SVN::GlobSpec->new($p),\n-\t\t\t    ref => Git::SVN::GlobSpec->new($g) };\n+\t\t\t    t => $t,\n+\t\t\t    remote => $remote,\n+\t\t\t    path => Git::SVN::GlobSpec->new($local_ref),\n+\t\t\t    ref => Git::SVN::GlobSpec->new($remote_ref) };\n \t\t\tif (length($rs->{ref}->{right}) != 0) {\n \t\t\t\tdie \"The '*' glob character must be the last \",\n-\t\t\t\t    \"character of '$g'\\n\";\n+\t\t\t\t    \"character of '$remote_ref'\\n\";\n \t\t\t}\n-\t\t\tpush @{ $r->{$1}->{$2} }, $rs;\n+\t\t\tpush @{ $r->{$remote}->{$t} }, $rs;\n \t\t}\n \t}\n \n@@ -1818,9 +1819,9 @@ sub init_remote_config {\n \t\t}\n \t}\n \tmy ($xrepo_id, $xpath) = find_ref($self->refname);\n-\tif (defined $xpath) {\n+\tif (!$no_write && defined $xpath) {\n \t\tdie \"svn-remote.$xrepo_id.fetch already set to track \",\n-\t\t    \"$xpath:refs/remotes/\", $self->refname, \"\\n\";\n+\t\t    \"$xpath:\", $self->refname, \"\\n\";\n \t}\n \tunless ($no_write) {\n \t\tcommand_noisy('config',\n@@ -1895,7 +1896,7 @@ sub find_ref {\n \tmy ($ref_id) = @_;\n \tforeach (command(qw/config -l/)) {\n \t\tnext unless m!^svn-remote\\.(.+)\\.fetch=\n-\t\t              \\s*(.*)\\s*:\\s*refs/remotes/(.+)\\s*$!x;\n+\t\t              \\s*/?(.*?)\\s*:\\s*(.+?)\\s*$!x;\n \t\tmy ($repo_id, $path, $ref) = ($1, $2, $3);\n \t\tif ($ref eq $ref_id) {\n \t\t\t$path = '' if ($path =~ m#^\\./?#);\n@@ -1912,16 +1913,16 @@ sub new {\n \t\tif (!defined $repo_id) {\n \t\t\tdie \"Could not find a \\\"svn-remote.*.fetch\\\" key \",\n \t\t\t    \"in the repository configuration matching: \",\n-\t\t\t    \"refs/remotes/$ref_id\\n\";\n+\t\t\t    \"$ref_id\\n\";\n \t\t}\n \t}\n \tmy $self = _new($class, $repo_id, $ref_id, $path);\n \tif (!defined $self->{path} || !length $self->{path}) {\n \t\tmy $fetch = command_oneline('config', '--get',\n \t\t                            \"svn-remote.$repo_id.fetch\",\n-\t\t                            \":refs/remotes/$ref_id\\$\") or\n+\t\t                            \":$ref_id\\$\") or\n \t\t     die \"Failed to read \\\"svn-remote.$repo_id.fetch\\\" \",\n-\t\t         \"\\\":refs/remotes/$ref_id\\$\\\" in config\\n\";\n+\t\t         \"\\\":$ref_id\\$\\\" in config\\n\";\n \t\t($self->{path}, undef) = split(/\\s*:\\s*/, $fetch);\n \t}\n \t$self->{url} = command_oneline('config', '--get',\n@@ -1932,7 +1933,7 @@ sub new {\n }\n \n sub refname {\n-\tmy ($refname) = \"refs/remotes/$_[0]->{ref_id}\" ;\n+\tmy ($refname) = $_[0]->{ref_id} ;\n \n \t# It cannot end with a slash /, we'll throw up on this because\n \t# SVN can't have directories with a slash in their name, either:\n@@ -3267,12 +3268,12 @@ sub _new {\n \t}\n \tunless (defined $ref_id && length $ref_id) {\n \t\t$_prefix = '' unless defined($_prefix);\n-\t\t$_[2] = $ref_id = $_prefix . $Git::SVN::default_ref_id;\n+\t\t$_[2] = $ref_id = 'refs/remotes/' . $_prefix . $Git::SVN::default_ref_id;\n \t}\n \t$_[1] = $repo_id;\n \tmy $dir = \"$ENV{GIT_DIR}/svn/$ref_id\";\n \t$_[3] = $path = '' unless (defined $path);\n-\tmkpath([\"$ENV{GIT_DIR}/svn\"]);\n+\tmkpath([\"$ENV{GIT_DIR}/svn/$ref_id\"]);\n \tbless {\n \t\tref_id => $ref_id, dir => $dir, index => \"$dir/index\",\n \t        path => $path, config => \"$ENV{GIT_DIR}/svn/config\",\n@@ -3301,7 +3302,9 @@ sub rev_db_path {\n sub map_path {\n \tmy ($self, $uuid) = @_;\n \t$uuid ||= $self->ra_uuid;\n-\t\"$self->{map_root}.$uuid\";\n+\tmy $map_path = \"$self->{map_root}.$uuid\";\n+\t( ! -d $map_path && $map_path =~ m{^refs/remotes/(.*)} && -d $1 ) ?\n+\t\t$1 : $map_path;\n }\n \n sub uri_encode {\n@@ -5441,7 +5444,7 @@ sub minimize_connections {\n \t\t\tmy $pfx = \"svn-remote.$x->{old_repo_id}\";\n \n \t\t\tmy $old_fetch = quotemeta(\"$x->{old_path}:\".\n-\t\t\t                          \"refs/remotes/$x->{ref_id}\");\n+\t\t\t                          \"$x->{ref_id}\");\n \t\t\tcommand_noisy(qw/config --unset/,\n \t\t\t              \"$pfx.fetch\", '^'. $old_fetch . '$');\n \t\t\tdelete $r->{$x->{old_repo_id}}->\n@@ -5510,7 +5513,7 @@ sub new {\n \tmy ($class, $glob) = @_;\n \tmy $re = $glob;\n \t$re =~ s!/+$!!g; # no need for trailing slashes\n-\t$re =~ m!^([^*]*)(\\*(?:/\\*)*)([^*]*)$!;\n+\t$re =~ m!^([^*]*)(\\*(?:/\\*)*)(.*)$!;\n \tmy $temp = $re;\n \tmy ($left, $right) = ($1, $3);\n \t$re = $2;\ndiff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh\nindex 5654962..fd8631f 100644\n--- a/t/lib-git-svn.sh\n+++ b/t/lib-git-svn.sh\n@@ -14,7 +14,7 @@ if ! test_have_prereq PERL; then\n fi\n \n GIT_DIR=$PWD/.git\n-GIT_SVN_DIR=$GIT_DIR/svn/git-svn\n+GIT_SVN_DIR=$GIT_DIR/svn/refs/remotes/git-svn\n SVN_TREE=$GIT_SVN_DIR/svn-tree\n \n svn >/dev/null 2>&1\ndiff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh\nindex 78610b6..bbfd7f4 100755\n--- a/t/t9104-git-svn-follow-parent.sh\n+++ b/t/t9104-git-svn-follow-parent.sh\n@@ -172,11 +172,11 @@ test_expect_success \"follow-parent is atomic\" '\n \tgit update-ref refs/remotes/flunk@18 refs/remotes/stunk~2 &&\n \tgit update-ref -d refs/remotes/stunk &&\n \tgit config --unset svn-remote.svn.fetch stunk &&\n-\tmkdir -p \"$GIT_DIR\"/svn/flunk@18 &&\n-\trev_map=$(cd \"$GIT_DIR\"/svn/stunk && ls .rev_map*) &&\n-\tdd if=\"$GIT_DIR\"/svn/stunk/$rev_map \\\n-\t   of=\"$GIT_DIR\"/svn/flunk@18/$rev_map bs=24 count=1 &&\n-\trm -rf \"$GIT_DIR\"/svn/stunk &&\n+\tmkdir -p \"$GIT_DIR\"/svn/refs/remotes/flunk@18 &&\n+\trev_map=$(cd \"$GIT_DIR\"/svn/refs/remotes/stunk && ls .rev_map*) &&\n+\tdd if=\"$GIT_DIR\"/svn/refs/remotes/stunk/$rev_map \\\n+\t   of=\"$GIT_DIR\"/svn/refs/remotes/flunk@18/$rev_map bs=24 count=1 &&\n+\trm -rf \"$GIT_DIR\"/svn/refs/remotes/stunk &&\n \tgit svn init --minimize-url -i flunk \"$svnrepo\"/flunk &&\n \tgit svn fetch -i flunk &&\n \tgit svn init --minimize-url -i stunk \"$svnrepo\"/stunk &&\ndiff --git a/t/t9107-git-svn-migrate.sh b/t/t9107-git-svn-migrate.sh\nindex 145a367..3a84eb5 100755\n--- a/t/t9107-git-svn-migrate.sh\n+++ b/t/t9107-git-svn-migrate.sh\n@@ -16,9 +16,7 @@ test_expect_success 'setup old-looking metadata' '\n \t\tcd .. &&\n \tgit svn init \"$svnrepo\" &&\n \tgit svn fetch &&\n-\tmv \"$GIT_DIR\"/svn/* \"$GIT_DIR\"/ &&\n-\tmv \"$GIT_DIR\"/svn/.metadata \"$GIT_DIR\"/ &&\n-\trmdir \"$GIT_DIR\"/svn &&\n+\trm -rf \"$GIT_DIR\"/svn &&\n \tgit update-ref refs/heads/git-svn-HEAD refs/${remotes_git_svn} &&\n \tgit update-ref refs/heads/svn-HEAD refs/${remotes_git_svn} &&\n \tgit update-ref -d refs/${remotes_git_svn} refs/${remotes_git_svn}\n@@ -79,7 +77,7 @@ test_expect_success 'migrate --minimize on old inited layout' '\n \trm -rf \"$GIT_DIR\"/svn &&\n \tfor i in `cat fetch.out`; do\n \t\tpath=`expr $i : \"\\([^:]*\\):.*$\"`\n-\t\tref=`expr $i : \"[^:]*:refs/remotes/\\(.*\\)$\"`\n+\t\tref=`expr $i : \"[^:]*:\\(refs/remotes/.*\\)$\"`\n \t\tif test -z \"$ref\"; then continue; fi\n \t\tif test -n \"$path\"; then path=\"/$path\"; fi\n \t\t( mkdir -p \"$GIT_DIR\"/svn/$ref/info/ &&\n@@ -99,16 +97,16 @@ test_expect_success 'migrate --minimize on old inited layout' '\n \n test_expect_success  \".rev_db auto-converted to .rev_map.UUID\" '\n \tgit svn fetch -i trunk &&\n-\ttest -z \"$(ls \"$GIT_DIR\"/svn/trunk/.rev_db.* 2>/dev/null)\" &&\n-\texpect=\"$(ls \"$GIT_DIR\"/svn/trunk/.rev_map.*)\" &&\n+\ttest -z \"$(ls \"$GIT_DIR\"/svn/refs/remotes/trunk/.rev_db.* 2>/dev/null)\" &&\n+\texpect=\"$(ls \"$GIT_DIR\"/svn/refs/remotes/trunk/.rev_map.*)\" &&\n \ttest -n \"$expect\" &&\n \trev_db=\"$(echo $expect | sed -e \"s,_map,_db,\")\" &&\n \tconvert_to_rev_db \"$expect\" \"$rev_db\" &&\n \trm -f \"$expect\" &&\n \ttest -f \"$rev_db\" &&\n \tgit svn fetch -i trunk &&\n-\ttest -z \"$(ls \"$GIT_DIR\"/svn/trunk/.rev_db.* 2>/dev/null)\" &&\n-\ttest ! -e \"$GIT_DIR\"/svn/trunk/.rev_db &&\n+\ttest -z \"$(ls \"$GIT_DIR\"/svn/refs/remotes/trunk/.rev_db.* 2>/dev/null)\" &&\n+\ttest ! -e \"$GIT_DIR\"/svn/refs/remotes/trunk/.rev_db &&\n \ttest -f \"$expect\"\n \t'\n \n-- \n1.6.0.6\n"},{"id":"119836","messageId":"20090806212841.GA13437@dcvr.yhbt.net","threadId":"20364","inReplyTo":"1249350039-7338-2-git-send-email-adambrewster@gmail.com","subject":"Re: [PATCH] svn: Add && to t9107-git-svn-migrarte.sh","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-08-06T21:28:41Z","receivedAt":"2009-08-06T21:28:41Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Adam Brewster <adambrewster@gmail.com> wrote:\n> It was probably intended for the test to fail unless all of the\n> commands succeed.\n\nI think you've uncovered some major breakage in this test that never got\nnoticed until now.  I'll try to take a harder look tonight or this\nweekend.\n\nFortunately, this functionality is rarely needed these days :)\nThanks for the heads up!\n\n> ---\n>  t/t9107-git-svn-migrate.sh |    2 +-\n>  1 files changed, 1 insertions(+), 1 deletions(-)\n> \n> diff --git a/t/t9107-git-svn-migrate.sh b/t/t9107-git-svn-migrate.sh\n> index 3a9e077..145a367 100755\n> --- a/t/t9107-git-svn-migrate.sh\n> +++ b/t/t9107-git-svn-migrate.sh\n> @@ -93,7 +93,7 @@ test_expect_success 'migrate --minimize on old inited layout' '\n>  \tgrep \"^branches/b:refs/remotes/b$\" fetch.out &&\n>  \tgrep \"^tags/0\\.1:refs/remotes/tags/0\\.1$\" fetch.out &&\n>  \tgrep \"^tags/0\\.2:refs/remotes/tags/0\\.2$\" fetch.out &&\n> -\tgrep \"^tags/0\\.3:refs/remotes/tags/0\\.3$\" fetch.out\n> +\tgrep \"^tags/0\\.3:refs/remotes/tags/0\\.3$\" fetch.out &&\n>  \tgrep \"^:refs/${remotes_git_svn}\" fetch.out\n"},{"id":"120113","messageId":"20090810083234.GA8698@dcvr.yhbt.net","threadId":"20364","inReplyTo":"20090806212841.GA13437@dcvr.yhbt.net","subject":"Re: [PATCH] svn: Add && to t9107-git-svn-migrarte.sh","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-08-10T08:32:34Z","receivedAt":"2009-08-10T08:32:34Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Eric Wong <normalperson@yhbt.net> wrote:\n> Adam Brewster <adambrewster@gmail.com> wrote:\n> > It was probably intended for the test to fail unless all of the\n> > commands succeed.\n> \n> I think you've uncovered some major breakage in this test that never got\n> noticed until now.  I'll try to take a harder look tonight or this\n> weekend.\n> \n> Fortunately, this functionality is rarely needed these days :)\n> Thanks for the heads up!\n\nActually, the test should look like this, I'll push it out\nalong with the other one in a few.\n\n>From 4ebe6e92c3b62d5192b6cc8158fde701bf2c0dcb Mon Sep 17 00:00:00 2001\nFrom: Adam Brewster <adambrewster@gmail.com>\nDate: Mon, 3 Aug 2009 21:40:37 -0400\nSubject: [PATCH] svn: Add && to t9107-git-svn-migrate.sh\n\nIt was probably intended for the test to fail unless all of the\ncommands succeed.\n\n[ew: fixed tests to actually work]\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n t/t9107-git-svn-migrate.sh |   14 +++++++++++---\n 1 files changed, 11 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t9107-git-svn-migrate.sh b/t/t9107-git-svn-migrate.sh\nindex 3a9e077..c0098d9 100755\n--- a/t/t9107-git-svn-migrate.sh\n+++ b/t/t9107-git-svn-migrate.sh\n@@ -56,7 +56,15 @@ test_expect_success 'initialize a multi-repository repo' '\n \tgit config --add svn-remote.svn.fetch \"branches/b:refs/remotes/b\" &&\n \tfor i in tags/0.1 tags/0.2 tags/0.3; do\n \t\tgit config --add svn-remote.svn.fetch \\\n-\t\t                 $i:refs/remotes/$i || exit 1; done\n+\t\t                 $i:refs/remotes/$i || exit 1; done &&\n+\tgit config --get-all svn-remote.svn.fetch > fetch.out &&\n+\tgrep \"^trunk:refs/remotes/trunk$\" fetch.out &&\n+\tgrep \"^branches/a:refs/remotes/a$\" fetch.out &&\n+\tgrep \"^branches/b:refs/remotes/b$\" fetch.out &&\n+\tgrep \"^tags/0\\.1:refs/remotes/tags/0\\.1$\" fetch.out &&\n+\tgrep \"^tags/0\\.2:refs/remotes/tags/0\\.2$\" fetch.out &&\n+\tgrep \"^tags/0\\.3:refs/remotes/tags/0\\.3$\" fetch.out &&\n+\tgrep \"^:refs/${remotes_git_svn}\" fetch.out\n \t'\n \n # refs should all be different, but the trees should all be the same:\n@@ -86,14 +94,14 @@ test_expect_success 'migrate --minimize on old inited layout' '\n \t\techo \"$svnrepo\"$path > \"$GIT_DIR\"/svn/$ref/info/url ) || exit 1;\n \tdone &&\n \tgit svn migrate --minimize &&\n-\ttest -z \"`git config -l |grep -v \"^svn-remote\\.git-svn\\.\"`\" &&\n+\ttest -z \"`git config -l | grep \"^svn-remote\\.git-svn\\.\"`\" &&\n \tgit config --get-all svn-remote.svn.fetch > fetch.out &&\n \tgrep \"^trunk:refs/remotes/trunk$\" fetch.out &&\n \tgrep \"^branches/a:refs/remotes/a$\" fetch.out &&\n \tgrep \"^branches/b:refs/remotes/b$\" fetch.out &&\n \tgrep \"^tags/0\\.1:refs/remotes/tags/0\\.1$\" fetch.out &&\n \tgrep \"^tags/0\\.2:refs/remotes/tags/0\\.2$\" fetch.out &&\n-\tgrep \"^tags/0\\.3:refs/remotes/tags/0\\.3$\" fetch.out\n+\tgrep \"^tags/0\\.3:refs/remotes/tags/0\\.3$\" fetch.out &&\n \tgrep \"^:refs/${remotes_git_svn}\" fetch.out\n \t'\n \n-- \nEric Wong\n"},{"id":"120115","messageId":"20090810083818.GB8698@dcvr.yhbt.net","threadId":"20364","inReplyTo":"1249350039-7338-4-git-send-email-adambrewster@gmail.com","subject":"Re: [PATCH] svn: allow git-svn to update remotes outside of refs/remotes","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-08-10T08:38:18Z","receivedAt":"2009-08-10T08:38:18Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Adam Brewster <adambrewster@gmail.com> wrote:\n> It may be convenient for some users to store svn remote tracking\n> branches outside of the refs/remotes/ heirarchy.  [1] and [2] indicate\n> that there is interest in making this possible.\n> \n> [1]  http://www.gitready.com/advanced/2009/02/16/convert-git-svn-tag-branches-to-real-tags.html\n> [2] http://kerneltrap.org/mailarchive/git/2007/8/30/256359\n\nI definitely agree with the direction of this...\n\nWe'll need a mechanism for migrating existing repos from\n.git/svn/foo/* => .git/svn/refs/remotes/foo/* to avoid breaking\nthings for people with existing repos.  I guess that's why\nyou've been looking at (and helping fix) the migrate test :)\n\n-- \nEric Wong\n"},{"id":"120357","messageId":"1250046867-13655-1-git-send-email-adambrewster@gmail.com","threadId":"20364","inReplyTo":"20090810083234.GA8698@dcvr.yhbt.net","subject":"Re: [PATCH] svn: Add && to t9107-git-svn-migrarte.sh","fromName":"Adam Brewster","fromEmail":"adambrewster@gmail.com","sentAt":"2009-08-12T03:14:26Z","receivedAt":"2009-08-12T03:14:26Z","isPatch":true,"sender":{"key":"adambrewster@gmail.com","avatar":"https://avatars.githubusercontent.com/u/223816?v=4"},"body":"Eric,\n\nAny thoughts on the other patch?\n\nAm I close or is there a better way to go about this?\n\nI didn't really know what to do with .git/svn/*.  The easy answer is\n\n  mkdir -p $GIT_DIR/svn/refs/remotes &&\n  mv $GIT_DIR/svn/* $GIT_DIR/svn/refs/remotes\n\n>From the comments in the Migration module, it seems like that's frowned\nupon, so I came up with looking for .rev_map (or .rev_db) in both\nlocations (.git/svn/git-svn and .git/svn/refs/remotes/svn) and letting\nit stay in whichever location it already exists.  (The next email has a\nslightly improved version of the patch.)\n\nThis solution is particularly inelegant in it's handling of\nunhandled.log, but as far as I know that file is unused.\n\nThere's also the problem of what to do if someone has a ref called\nref/remotes/refs/remotes/..., but that seems unlikely enough to not\ncause concern.\n\nAdam\n"},{"id":"120358","messageId":"1250046867-13655-2-git-send-email-adambrewster@gmail.com","threadId":"20364","inReplyTo":"1250046867-13655-1-git-send-email-adambrewster@gmail.com","subject":"[PATCH] svn: allow branches outside of refs/remotes","fromName":"Adam Brewster","fromEmail":"adambrewster@gmail.com","sentAt":"2009-08-12T03:14:27Z","receivedAt":"2009-08-12T03:14:27Z","isPatch":true,"sender":{"key":"adambrewster@gmail.com","avatar":"https://avatars.githubusercontent.com/u/223816?v=4"},"body":"It may be convenient for some users to store svn remote tracking\nbranches outside of the refs/remotes/ heirarchy.\n\nTo accomplish this feat, this patch includes the entire path to\nthe ref in $r->{'refname'} in &read_all_remotes and tries to change\nreferences to this entry so the new value makes sense.\n\nSigned-off-by: Adam Brewster <adambrewster@gmail.com>\n---\n git-svn.perl                     |   82 +++++++++++++++++++++----------------\n t/lib-git-svn.sh                 |    2 +-\n t/t9104-git-svn-follow-parent.sh |   10 ++--\n t/t9107-git-svn-migrate.sh       |   14 +++----\n t/t9143-git-svn-gc.sh            |   10 ++--\n 5 files changed, 63 insertions(+), 55 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex b0bfb74..cafd7fe 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -909,7 +909,7 @@ sub cmd_multi_init {\n \t}\n \tdo_git_init_db();\n \tif (defined $_trunk) {\n-\t\tmy $trunk_ref = $_prefix . 'trunk';\n+\t\tmy $trunk_ref = 'refs/remotes/' . $_prefix . 'trunk';\n \t\t# try both old-style and new-style lookups:\n \t\tmy $gs_trunk = eval { Git::SVN->new($trunk_ref) };\n \t\tunless ($gs_trunk) {\n@@ -1643,23 +1643,23 @@ sub resolve_local_globs {\n \treturn unless defined $glob_spec;\n \tmy $ref = $glob_spec->{ref};\n \tmy $path = $glob_spec->{path};\n-\tforeach (command(qw#for-each-ref --format=%(refname) refs/remotes#)) {\n-\t\tnext unless m#^refs/remotes/$ref->{regex}$#;\n+\tforeach (command(qw#for-each-ref --format=%(refname) refs/#)) {\n+\t\tnext unless m#^$ref->{regex}$#;\n \t\tmy $p = $1;\n \t\tmy $pathname = desanitize_refname($path->full_path($p));\n \t\tmy $refname = desanitize_refname($ref->full_path($p));\n \t\tif (my $existing = $fetch->{$pathname}) {\n \t\t\tif ($existing ne $refname) {\n \t\t\t\tdie \"Refspec conflict:\\n\",\n-\t\t\t\t    \"existing: refs/remotes/$existing\\n\",\n-\t\t\t\t    \" globbed: refs/remotes/$refname\\n\";\n+\t\t\t\t    \"existing: $existing\\n\",\n+\t\t\t\t    \" globbed: $refname\\n\";\n \t\t\t}\n-\t\t\tmy $u = (::cmt_metadata(\"refs/remotes/$refname\"))[0];\n+\t\t\tmy $u = (::cmt_metadata(\"$refname\"))[0];\n \t\t\t$u =~ s!^\\Q$url\\E(/|$)!! or die\n-\t\t\t  \"refs/remotes/$refname: '$url' not found in '$u'\\n\";\n+\t\t\t  \"$refname: '$url' not found in '$u'\\n\";\n \t\t\tif ($pathname ne $u) {\n \t\t\t\twarn \"W: Refspec glob conflict \",\n-\t\t\t\t     \"(ref: refs/remotes/$refname):\\n\",\n+\t\t\t\t     \"(ref: $refname):\\n\",\n \t\t\t\t     \"expected path: $pathname\\n\",\n \t\t\t\t     \"    real path: $u\\n\",\n \t\t\t\t     \"Continuing ahead with $u\\n\";\n@@ -1737,33 +1737,34 @@ sub read_all_remotes {\n \tmy $use_svm_props = eval { command_oneline(qw/config --bool\n \t    svn.useSvmProps/) };\n \t$use_svm_props = $use_svm_props eq 'true' if $use_svm_props;\n+\tmy $svn_refspec = qr{\\s*/?(.*?)\\s*:\\s*(.+?)\\s*};\n \tforeach (grep { s/^svn-remote\\.// } command(qw/config -l/)) {\n-\t\tif (m!^(.+)\\.fetch=\\s*(.*)\\s*:\\s*(.+)\\s*$!) {\n-\t\t\tmy ($remote, $local_ref, $_remote_ref) = ($1, $2, $3);\n-\t\t\tdie(\"svn-remote.$remote: remote ref '$_remote_ref' \"\n-\t\t\t    . \"must start with 'refs/remotes/'\\n\")\n-\t\t\t\tunless $_remote_ref =~ m{^refs/remotes/(.+)};\n-\t\t\tmy $remote_ref = $1;\n-\t\t\t$local_ref =~ s{^/}{};\n+\t\tif (m!^(.+)\\.fetch=$svn_refspec$!) {\n+\t\t\tmy ($remote, $local_ref, $remote_ref) = ($1, $2, $3);\n+\t\t\tdie(\"svn-remote.$remote: remote ref '$remote_ref' \"\n+\t\t\t    . \"must start with 'refs/'\\n\")\n+\t\t\t\tunless $remote_ref =~ m{^refs/};\n \t\t\t$r->{$remote}->{fetch}->{$local_ref} = $remote_ref;\n \t\t\t$r->{$remote}->{svm} = {} if $use_svm_props;\n \t\t} elsif (m!^(.+)\\.usesvmprops=\\s*(.*)\\s*$!) {\n \t\t\t$r->{$1}->{svm} = {};\n \t\t} elsif (m!^(.+)\\.url=\\s*(.*)\\s*$!) {\n \t\t\t$r->{$1}->{url} = $2;\n-\t\t} elsif (m!^(.+)\\.(branches|tags)=\n-\t\t           (.*):refs/remotes/(.+)\\s*$/!x) {\n-\t\t\tmy ($p, $g) = ($3, $4);\n+\t\t} elsif (m!^(.+)\\.(branches|tags)=$svn_refspec$!) {\n+\t\t\tmy ($remote, $t, $local_ref, $remote_ref) = ($1, $2, $3, $4);\n+\t\t\tdie(\"svn-remote.$remote: remote ref '$remote_ref' ($t) \"\n+\t\t\t    . \"must start with 'refs/'\\n\")\n+\t\t\t\tunless $remote_ref =~ m{^refs/};\n \t\t\tmy $rs = {\n-\t\t\t    t => $2,\n-\t\t\t    remote => $1,\n-\t\t\t    path => Git::SVN::GlobSpec->new($p),\n-\t\t\t    ref => Git::SVN::GlobSpec->new($g) };\n+\t\t\t    t => $t,\n+\t\t\t    remote => $remote,\n+\t\t\t    path => Git::SVN::GlobSpec->new($local_ref),\n+\t\t\t    ref => Git::SVN::GlobSpec->new($remote_ref) };\n \t\t\tif (length($rs->{ref}->{right}) != 0) {\n \t\t\t\tdie \"The '*' glob character must be the last \",\n-\t\t\t\t    \"character of '$g'\\n\";\n+\t\t\t\t    \"character of '$remote_ref'\\n\";\n \t\t\t}\n-\t\t\tpush @{ $r->{$1}->{$2} }, $rs;\n+\t\t\tpush @{ $r->{$remote}->{$t} }, $rs;\n \t\t}\n \t}\n \n@@ -1871,9 +1872,9 @@ sub init_remote_config {\n \t\t}\n \t}\n \tmy ($xrepo_id, $xpath) = find_ref($self->refname);\n-\tif (defined $xpath) {\n+\tif (!$no_write && defined $xpath) {\n \t\tdie \"svn-remote.$xrepo_id.fetch already set to track \",\n-\t\t    \"$xpath:refs/remotes/\", $self->refname, \"\\n\";\n+\t\t    \"$xpath:\", $self->refname, \"\\n\";\n \t}\n \tunless ($no_write) {\n \t\tcommand_noisy('config',\n@@ -1948,7 +1949,7 @@ sub find_ref {\n \tmy ($ref_id) = @_;\n \tforeach (command(qw/config -l/)) {\n \t\tnext unless m!^svn-remote\\.(.+)\\.fetch=\n-\t\t              \\s*(.*)\\s*:\\s*refs/remotes/(.+)\\s*$!x;\n+\t\t              \\s*/?(.*?)\\s*:\\s*(.+?)\\s*$!x;\n \t\tmy ($repo_id, $path, $ref) = ($1, $2, $3);\n \t\tif ($ref eq $ref_id) {\n \t\t\t$path = '' if ($path =~ m#^\\./?#);\n@@ -1965,16 +1966,16 @@ sub new {\n \t\tif (!defined $repo_id) {\n \t\t\tdie \"Could not find a \\\"svn-remote.*.fetch\\\" key \",\n \t\t\t    \"in the repository configuration matching: \",\n-\t\t\t    \"refs/remotes/$ref_id\\n\";\n+\t\t\t    \"$ref_id\\n\";\n \t\t}\n \t}\n \tmy $self = _new($class, $repo_id, $ref_id, $path);\n \tif (!defined $self->{path} || !length $self->{path}) {\n \t\tmy $fetch = command_oneline('config', '--get',\n \t\t                            \"svn-remote.$repo_id.fetch\",\n-\t\t                            \":refs/remotes/$ref_id\\$\") or\n+\t\t                            \":$ref_id\\$\") or\n \t\t     die \"Failed to read \\\"svn-remote.$repo_id.fetch\\\" \",\n-\t\t         \"\\\":refs/remotes/$ref_id\\$\\\" in config\\n\";\n+\t\t         \"\\\":$ref_id\\$\\\" in config\\n\";\n \t\t($self->{path}, undef) = split(/\\s*:\\s*/, $fetch);\n \t}\n \t$self->{url} = command_oneline('config', '--get',\n@@ -1985,7 +1986,7 @@ sub new {\n }\n \n sub refname {\n-\tmy ($refname) = \"refs/remotes/$_[0]->{ref_id}\" ;\n+\tmy ($refname) = $_[0]->{ref_id} ;\n \n \t# It cannot end with a slash /, we'll throw up on this because\n \t# SVN can't have directories with a slash in their name, either:\n@@ -3320,12 +3321,12 @@ sub _new {\n \t}\n \tunless (defined $ref_id && length $ref_id) {\n \t\t$_prefix = '' unless defined($_prefix);\n-\t\t$_[2] = $ref_id = $_prefix . $Git::SVN::default_ref_id;\n+\t\t$_[2] = $ref_id = 'refs/remotes/' . $_prefix . $Git::SVN::default_ref_id;\n \t}\n \t$_[1] = $repo_id;\n \tmy $dir = \"$ENV{GIT_DIR}/svn/$ref_id\";\n \t$_[3] = $path = '' unless (defined $path);\n-\tmkpath([\"$ENV{GIT_DIR}/svn\"]);\n+\tmkpath([\"$ENV{GIT_DIR}/svn/$ref_id\"]);\n \tbless {\n \t\tref_id => $ref_id, dir => $dir, index => \"$dir/index\",\n \t        path => $path, config => \"$ENV{GIT_DIR}/svn/config\",\n@@ -3354,7 +3355,16 @@ sub rev_db_path {\n sub map_path {\n \tmy ($self, $uuid) = @_;\n \t$uuid ||= $self->ra_uuid;\n-\t\"$self->{map_root}.$uuid\";\n+\tmy $map_path = \"$self->{map_root}.$uuid\";\n+\treturn $map_path if ( -f $map_path );\n+\n+\tmy $db_path = $map_path;\n+\t$db_path =~ s/\\.rev_map/.rev_db/;\n+\treturn $map_path if ( -f $db_path );\n+\n+\treturn $1 if ($map_path =~ m(refs/remotes/(.*)) && -f $1);\n+\treturn $1 if ($db_path =~ m(refs/remotes/(.*)) && -f $1);\n+\treturn $map_path;\n }\n \n sub uri_encode {\n@@ -5498,7 +5508,7 @@ sub minimize_connections {\n \t\t\tmy $pfx = \"svn-remote.$x->{old_repo_id}\";\n \n \t\t\tmy $old_fetch = quotemeta(\"$x->{old_path}:\".\n-\t\t\t                          \"refs/remotes/$x->{ref_id}\");\n+\t\t\t                          \"$x->{ref_id}\");\n \t\t\tcommand_noisy(qw/config --unset/,\n \t\t\t              \"$pfx.fetch\", '^'. $old_fetch . '$');\n \t\t\tdelete $r->{$x->{old_repo_id}}->\n@@ -5567,7 +5577,7 @@ sub new {\n \tmy ($class, $glob) = @_;\n \tmy $re = $glob;\n \t$re =~ s!/+$!!g; # no need for trailing slashes\n-\t$re =~ m!^([^*]*)(\\*(?:/\\*)*)([^*]*)$!;\n+\t$re =~ m!^([^*]*)(\\*(?:/\\*)*)(.*)$!;\n \tmy $temp = $re;\n \tmy ($left, $right) = ($1, $3);\n \t$re = $2;\ndiff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh\nindex 5654962..fd8631f 100644\n--- a/t/lib-git-svn.sh\n+++ b/t/lib-git-svn.sh\n@@ -14,7 +14,7 @@ if ! test_have_prereq PERL; then\n fi\n \n GIT_DIR=$PWD/.git\n-GIT_SVN_DIR=$GIT_DIR/svn/git-svn\n+GIT_SVN_DIR=$GIT_DIR/svn/refs/remotes/git-svn\n SVN_TREE=$GIT_SVN_DIR/svn-tree\n \n svn >/dev/null 2>&1\ndiff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh\nindex 78610b6..bbfd7f4 100755\n--- a/t/t9104-git-svn-follow-parent.sh\n+++ b/t/t9104-git-svn-follow-parent.sh\n@@ -172,11 +172,11 @@ test_expect_success \"follow-parent is atomic\" '\n \tgit update-ref refs/remotes/flunk@18 refs/remotes/stunk~2 &&\n \tgit update-ref -d refs/remotes/stunk &&\n \tgit config --unset svn-remote.svn.fetch stunk &&\n-\tmkdir -p \"$GIT_DIR\"/svn/flunk@18 &&\n-\trev_map=$(cd \"$GIT_DIR\"/svn/stunk && ls .rev_map*) &&\n-\tdd if=\"$GIT_DIR\"/svn/stunk/$rev_map \\\n-\t   of=\"$GIT_DIR\"/svn/flunk@18/$rev_map bs=24 count=1 &&\n-\trm -rf \"$GIT_DIR\"/svn/stunk &&\n+\tmkdir -p \"$GIT_DIR\"/svn/refs/remotes/flunk@18 &&\n+\trev_map=$(cd \"$GIT_DIR\"/svn/refs/remotes/stunk && ls .rev_map*) &&\n+\tdd if=\"$GIT_DIR\"/svn/refs/remotes/stunk/$rev_map \\\n+\t   of=\"$GIT_DIR\"/svn/refs/remotes/flunk@18/$rev_map bs=24 count=1 &&\n+\trm -rf \"$GIT_DIR\"/svn/refs/remotes/stunk &&\n \tgit svn init --minimize-url -i flunk \"$svnrepo\"/flunk &&\n \tgit svn fetch -i flunk &&\n \tgit svn init --minimize-url -i stunk \"$svnrepo\"/stunk &&\ndiff --git a/t/t9107-git-svn-migrate.sh b/t/t9107-git-svn-migrate.sh\nindex c0098d9..901b8e0 100755\n--- a/t/t9107-git-svn-migrate.sh\n+++ b/t/t9107-git-svn-migrate.sh\n@@ -16,9 +16,7 @@ test_expect_success 'setup old-looking metadata' '\n \t\tcd .. &&\n \tgit svn init \"$svnrepo\" &&\n \tgit svn fetch &&\n-\tmv \"$GIT_DIR\"/svn/* \"$GIT_DIR\"/ &&\n-\tmv \"$GIT_DIR\"/svn/.metadata \"$GIT_DIR\"/ &&\n-\trmdir \"$GIT_DIR\"/svn &&\n+\trm -rf \"$GIT_DIR\"/svn &&\n \tgit update-ref refs/heads/git-svn-HEAD refs/${remotes_git_svn} &&\n \tgit update-ref refs/heads/svn-HEAD refs/${remotes_git_svn} &&\n \tgit update-ref -d refs/${remotes_git_svn} refs/${remotes_git_svn}\n@@ -87,7 +85,7 @@ test_expect_success 'migrate --minimize on old inited layout' '\n \trm -rf \"$GIT_DIR\"/svn &&\n \tfor i in `cat fetch.out`; do\n \t\tpath=`expr $i : \"\\([^:]*\\):.*$\"`\n-\t\tref=`expr $i : \"[^:]*:refs/remotes/\\(.*\\)$\"`\n+\t\tref=`expr $i : \"[^:]*:\\(refs/remotes/.*\\)$\"`\n \t\tif test -z \"$ref\"; then continue; fi\n \t\tif test -n \"$path\"; then path=\"/$path\"; fi\n \t\t( mkdir -p \"$GIT_DIR\"/svn/$ref/info/ &&\n@@ -107,16 +105,16 @@ test_expect_success 'migrate --minimize on old inited layout' '\n \n test_expect_success  \".rev_db auto-converted to .rev_map.UUID\" '\n \tgit svn fetch -i trunk &&\n-\ttest -z \"$(ls \"$GIT_DIR\"/svn/trunk/.rev_db.* 2>/dev/null)\" &&\n-\texpect=\"$(ls \"$GIT_DIR\"/svn/trunk/.rev_map.*)\" &&\n+\ttest -z \"$(ls \"$GIT_DIR\"/svn/refs/remotes/trunk/.rev_db.* 2>/dev/null)\" &&\n+\texpect=\"$(ls \"$GIT_DIR\"/svn/refs/remotes/trunk/.rev_map.*)\" &&\n \ttest -n \"$expect\" &&\n \trev_db=\"$(echo $expect | sed -e \"s,_map,_db,\")\" &&\n \tconvert_to_rev_db \"$expect\" \"$rev_db\" &&\n \trm -f \"$expect\" &&\n \ttest -f \"$rev_db\" &&\n \tgit svn fetch -i trunk &&\n-\ttest -z \"$(ls \"$GIT_DIR\"/svn/trunk/.rev_db.* 2>/dev/null)\" &&\n-\ttest ! -e \"$GIT_DIR\"/svn/trunk/.rev_db &&\n+\ttest -z \"$(ls \"$GIT_DIR\"/svn/refs/remotes/trunk/.rev_db.* 2>/dev/null)\" &&\n+\ttest ! -e \"$GIT_DIR\"/svn/refs/remotes/trunk/.rev_db &&\n \ttest -f \"$expect\"\n \t'\n \ndiff --git a/t/t9143-git-svn-gc.sh b/t/t9143-git-svn-gc.sh\nindex f2ba2d1..99f69c6 100755\n--- a/t/t9143-git-svn-gc.sh\n+++ b/t/t9143-git-svn-gc.sh\n@@ -28,26 +28,26 @@ test_expect_success 'Setup repo' 'git svn init \"$svnrepo\"'\n test_expect_success 'Fetch repo' 'git svn fetch'\n \n test_expect_success 'make backup copy of unhandled.log' '\n-\t cp .git/svn/git-svn/unhandled.log tmp\n+\t cp .git/svn/refs/remotes/git-svn/unhandled.log tmp\n \t'\n \n-test_expect_success 'create leftover index' '> .git/svn/git-svn/index'\n+test_expect_success 'create leftover index' '> .git/svn/refs/remotes/git-svn/index'\n \n test_expect_success 'git svn gc runs' 'git svn gc'\n \n-test_expect_success 'git svn index removed' '! test -f .git/svn/git-svn/index'\n+test_expect_success 'git svn index removed' '! test -f .git/svn/refs/remotes/git-svn/index'\n \n if perl -MCompress::Zlib -e 0 2>/dev/null\n then\n \ttest_expect_success 'git svn gc produces a valid gzip file' '\n-\t\t gunzip .git/svn/git-svn/unhandled.log.gz\n+\t\t gunzip .git/svn/refs/remotes/git-svn/unhandled.log.gz\n \t\t'\n else\n \tsay \"Perl Compress::Zlib unavailable, skipping gunzip test\"\n fi\n \n test_expect_success 'git svn gc does not change unhandled.log files' '\n-\t test_cmp .git/svn/git-svn/unhandled.log tmp/unhandled.log\n+\t test_cmp .git/svn/refs/remotes/git-svn/unhandled.log tmp/unhandled.log\n \t'\n \n test_done\n-- \n1.6.0.6\n"},{"id":"120395","messageId":"20090812094940.GA22273@dcvr.yhbt.net","threadId":"20364","inReplyTo":"1250046867-13655-1-git-send-email-adambrewster@gmail.com","subject":"Re: [PATCH] svn: Add && to t9107-git-svn-migrarte.sh","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-08-12T09:49:40Z","receivedAt":"2009-08-12T09:49:40Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Adam Brewster <adambrewster@gmail.com> wrote:\n> Eric,\n> \n> Any thoughts on the other patch?\n> \n> Am I close or is there a better way to go about this?\n> \n> I didn't really know what to do with .git/svn/*.  The easy answer is\n> \n>   mkdir -p $GIT_DIR/svn/refs/remotes &&\n>   mv $GIT_DIR/svn/* $GIT_DIR/svn/refs/remotes\n\nThat should be acceptable.  I don't think it's worth the trouble to\nforce the majority of existing repos to move over to the new layout\n(in case the user wants to switch between multiple versions of git).\n\n> From the comments in the Migration module, it seems like that's frowned\n> upon, so I came up with looking for .rev_map (or .rev_db) in both\n> locations (.git/svn/git-svn and .git/svn/refs/remotes/svn) and letting\n> it stay in whichever location it already exists.  (The next email has a\n> slightly improved version of the patch.)\n> \n> This solution is particularly inelegant in it's handling of\n> unhandled.log, but as far as I know that file is unused.\n\nI'd still rather avoid creating unhandled.log in two places and\nhaving an unused set of directories.\n\nI think the following change on top of yours would make most\nsense:\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex cafd7fe..1117f28 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -3325,8 +3325,18 @@ sub _new {\n \t}\n \t$_[1] = $repo_id;\n \tmy $dir = \"$ENV{GIT_DIR}/svn/$ref_id\";\n+\n+\t# Older repos imported by us used $GIT_DIR/svn/foo instead of\n+\t# $GIT_DIR/svn/refs/remotes/foo when tracking refs/remotes/foo\n+\tif ($ref_id =~ m{^refs/remotes/(.*)}) {\n+\t\tmy $old_dir = \"$ENV{GIT_DIR}/svn/$1\";\n+\t\tif (-d $old_dir && ! -d $dir) {\n+\t\t\t$dir = $old_dir;\n+\t\t}\n+\t}\n+\n \t$_[3] = $path = '' unless (defined $path);\n-\tmkpath([\"$ENV{GIT_DIR}/svn/$ref_id\"]);\n+\tmkpath([$dir]);\n \tbless {\n \t\tref_id => $ref_id, dir => $dir, index => \"$dir/index\",\n \t        path => $path, config => \"$ENV{GIT_DIR}/svn/config\",\n@@ -3355,16 +3365,7 @@ sub rev_db_path {\n sub map_path {\n \tmy ($self, $uuid) = @_;\n \t$uuid ||= $self->ra_uuid;\n-\tmy $map_path = \"$self->{map_root}.$uuid\";\n-\treturn $map_path if ( -f $map_path );\n-\n-\tmy $db_path = $map_path;\n-\t$db_path =~ s/\\.rev_map/.rev_db/;\n-\treturn $map_path if ( -f $db_path );\n-\n-\treturn $1 if ($map_path =~ m(refs/remotes/(.*)) && -f $1);\n-\treturn $1 if ($db_path =~ m(refs/remotes/(.*)) && -f $1);\n-\treturn $map_path;\n+\t\"$self->{map_root}.$uuid\";\n }\n \n sub uri_encode {\n----\n\nThe map_path() changes you originally made didn't work, either, since\nthe -f $1 never took GIT_DIR or GIT_DIR/svn into account.\n\n> There's also the problem of what to do if someone has a ref called\n> ref/remotes/refs/remotes/..., but that seems unlikely enough to not\n> cause concern.\n\nI concur.  There's always cases where things will be ambiguous\nand cases where a user is just asking for trouble :)\n\nI think the below is a good enough test case to for compatibility\nagainst existing repos.  Let me know what you think, thanks!\n\ndiff --git a/t/t9144-git-svn-old-rev_map.sh b/t/t9144-git-svn-old-rev_map.sh\nnew file mode 100755\nindex 0000000..7600a35\n--- /dev/null\n+++ b/t/t9144-git-svn-old-rev_map.sh\n@@ -0,0 +1,31 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2009 Eric Wong\n+\n+test_description='git svn old rev_map preservd'\n+. ./lib-git-svn.sh\n+\n+test_expect_success 'setup test repository with old layout' '\n+\tmkdir i &&\n+\t(cd i && > a) &&\n+\tsvn_cmd import -m- i \"$svnrepo\" &&\n+\tgit svn init \"$svnrepo\" &&\n+\tgit svn fetch &&\n+\ttest -d .git/svn/refs/remotes/git-svn/ &&\n+\t! test -e .git/svn/git-svn/ &&\n+\tmv .git/svn/refs/remotes/git-svn .git/svn/ &&\n+\trm -r .git/svn/refs\n+'\n+\n+test_expect_success 'old layout continues to work' '\n+\tsvn_cmd import -m- i \"$svnrepo/b\" &&\n+\tgit svn rebase &&\n+\techo a >> b/a &&\n+\tgit add b/a &&\n+\tgit commit -m- -a &&\n+\tgit svn dcommit &&\n+\t! test -d .git/svn/refs/ &&\n+\ttest -e .git/svn/git-svn/\n+'\n+\n+test_done\n-- \nEric Wong\n"},{"id":"120468","messageId":"c376da900908121735w7ee3c581pd1281efc83a2075d@mail.gmail.com","threadId":"20364","inReplyTo":"20090812094940.GA22273@dcvr.yhbt.net","subject":"Re: [PATCH] svn: Add && to t9107-git-svn-migrarte.sh","fromName":"Adam Brewster","fromEmail":"adambrewster@gmail.com","sentAt":"2009-08-13T00:35:12Z","receivedAt":"2009-08-13T00:35:12Z","isPatch":true,"sender":{"key":"adambrewster@gmail.com","avatar":"https://avatars.githubusercontent.com/u/223816?v=4"},"body":"Eric,\n\nThanks the help in getting this right.\n\n> I think the following change on top of yours would make most\n> sense:\n>\n\nLooks good to me.\n\n> The map_path() changes you originally made didn't work, either, since\n> the -f $1 never took GIT_DIR or GIT_DIR/svn into account.\n>\n\nIt was ugly, too.\n\n> I think the below is a good enough test case to for compatibility\n> against existing repos.  Let me know what you think, thanks!\n>\n\nLooks about right.\n\nThanks,\nAdam\n"},{"id":"120492","messageId":"20090813053617.GA18588@dcvr.yhbt.net","threadId":"20364","inReplyTo":"c376da900908121735w7ee3c581pd1281efc83a2075d@mail.gmail.com","subject":"Re: [PATCH] svn: Add && to t9107-git-svn-migrarte.sh","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-08-13T05:36:17Z","receivedAt":"2009-08-13T05:36:17Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Adam Brewster <adambrewster@gmail.com> wrote:\n> Eric,\n> \n> Thanks the help in getting this right.\n\nNo problem!  Thanks for fixing a long-standing issue with git svn.\n\nI've pushed this last patch out along with a few others to\ngit://yhbt.net/git-svn for Junio\n\n-- \nEric Wong\n"}]}