{"thread":{"id":"14108","subject":"[PATCH v2] git-svn: make rebuild respect rewriteRoot option","startedAt":"2008-06-24T00:17:36Z","lastAt":"2008-06-24T02:11:26Z","messageCount":2,"participants":["Jan Krüger","Joey Hess"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"80795","messageId":"20080624021736.2d272d9c@neuron","threadId":"14108","inReplyTo":null,"subject":"[PATCH v2] git-svn: make rebuild respect rewriteRoot option","fromName":"Jan Krüger","fromEmail":"jk@jk.gs","sentAt":"2008-06-24T00:17:36Z","receivedAt":"2008-06-24T00:17:36Z","isPatch":true,"sender":{"key":"jk@jk.gs","avatar":"https://avatars.githubusercontent.com/u/1774?v=4"},"body":"Suppose someone fetches git-svn-ified commits from another repo and then\nattempts to use 'git-svn init --rewrite-root=foo bar'. Using git svn rebase\nafter that will fail badly:\n\n * For each commit tried by working_head_info, rebuild is called indirectly.\n * rebuild will iterate over all commits and skip all of them because the\n   URL does not match. Because of that no rev_map file is generated at all.\n * Thus, rebuild will run once for every commit. This takes ages.\n * In the end there still isn't any rev_map file and thus working_head_info\n   fails.\n\nAddressing this behaviour fixes an apparently not too uncommon problem with\nproviding git-svn mirrors of Subversion repositories. Some repositories are\naccessed using different URLs depending on whether the user has push\nprivileges or not. In the latter case, an anonymous URL is often used that\ndiffers from the push URL. Providing a mirror that is usable in both cases\nbecomes a lot more possible with this change.\n\nSigned-off-by: Jan Krüger <jk@jk.gs>\n---\nFor reference, the previous version of this patch at\n<http://thread.gmane.org/gmane.comp.version-control.git/85551> was\nacked by Eric Wong (see that thread); the only change here is the added\ntest case as suggested by Eric.\n\nThe test doesn't exactly reproduce the original situation but it does\ntrigger the rebuild process to ensure it works correctly despite\n'rewriteRoot' being set to something not equal to 'url', which is what\nwe are after in the first place.\n\n git-svn.perl                                |    6 ++--\n t/t9123-git-svn-rebuild-with-rewriteroot.sh |   32 +++++++++++++++++++++++++++\n 2 files changed, 35 insertions(+), 3 deletions(-)\n create mode 100755 t/t9123-git-svn-rebuild-with-rewriteroot.sh\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex a54979d..4c9c59b 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -2577,8 +2577,8 @@ sub rebuild {\n \tmy ($log, $ctx) =\n \t    command_output_pipe(qw/rev-list --pretty=raw --no-color --reverse/,\n \t                        $self->refname, '--');\n-\tmy $full_url = $self->full_url;\n-\tremove_username($full_url);\n+\tmy $metadata_url = $self->metadata_url;\n+\tremove_username($metadata_url);\n \tmy $svn_uuid = $self->ra_uuid;\n \tmy $c;\n \twhile (<$log>) {\n@@ -2596,7 +2596,7 @@ sub rebuild {\n \t\t# if we merged or otherwise started elsewhere, this is\n \t\t# how we break out of it\n \t\tif (($uuid ne $svn_uuid) ||\n-\t\t    ($full_url && $url && ($url ne $full_url))) {\n+\t\t    ($metadata_url && $url && ($url ne $metadata_url))) {\n \t\t\tnext;\n \t\t}\n \ndiff --git a/t/t9123-git-svn-rebuild-with-rewriteroot.sh b/t/t9123-git-svn-rebuild-with-rewriteroot.sh\nnew file mode 100755\nindex 0000000..cf3f64d\n--- /dev/null\n+++ b/t/t9123-git-svn-rebuild-with-rewriteroot.sh\n@@ -0,0 +1,32 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2008 Jan Krüger\n+#\n+\n+test_description='git-svn respects rewriteRoot during rebuild'\n+\n+. ./lib-git-svn.sh\n+\n+mkdir import\n+cd import\n+\ttouch foo\n+\tsvn import -m 'import for git-svn' . \"$svnrepo\" >/dev/null\n+cd ..\n+rm -rf import\n+\n+test_expect_success 'init, fetch and checkout repository' '\n+\tgit svn init --rewrite-root=http://invalid.invalid/ \"$svnrepo\" &&\n+\tgit svn fetch\n+\tgit checkout -b mybranch remotes/git-svn\n+\t'\n+\n+test_expect_success 'remove rev_map' '\n+\trm \"$GIT_SVN_DIR\"/.rev_map.*\n+\t'\n+\n+test_expect_success 'rebuild rev_map' '\n+\tgit svn rebase >/dev/null\n+\t'\n+\n+test_done\n+\n-- \n1.5.6.2.g4316\n"},{"id":"80819","messageId":"20080624021126.GA31093@kodama.kitenet.net","threadId":"14108","inReplyTo":"20080624021736.2d272d9c@neuron","subject":"Re: [PATCH v2] git-svn: make rebuild respect rewriteRoot option","fromName":"Joey Hess","fromEmail":"joey@kitenet.net","sentAt":"2008-06-24T02:11:26Z","receivedAt":"2008-06-24T02:11:26Z","isPatch":true,"sender":{"key":"joey@kitenet.net","avatar":"https://avatars.githubusercontent.com/u/16392?v=4"},"body":"Jan Krüger wrote:\n> Suppose someone fetches git-svn-ified commits from another repo and then\n> attempts to use 'git-svn init --rewrite-root=foo bar'. Using git svn rebase\n> after that will fail badly:\n> \n>  * For each commit tried by working_head_info, rebuild is called indirectly.\n>  * rebuild will iterate over all commits and skip all of them because the\n>    URL does not match. Because of that no rev_map file is generated at all.\n>  * Thus, rebuild will run once for every commit. This takes ages.\n>  * In the end there still isn't any rev_map file and thus working_head_info\n>    fails.\n\nVery timely, I had just been beating my head against this problem.\nYour patch works great for me.\n\n-- \nsee shy jo\n"}]}