{"thread":{"id":"14046","subject":"[PATCH] git-svn: make rebuild respect rewriteRoot option","startedAt":"2008-06-19T22:33:59Z","lastAt":"2008-06-21T21:39:33Z","messageCount":2,"participants":["Jan Krüger","Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"80391","messageId":"20080620003359.0dbb7725@neuron","threadId":"14046","inReplyTo":null,"subject":"[PATCH] git-svn: make rebuild respect rewriteRoot option","fromName":"Jan Krüger","fromEmail":"jk@jk.gs","sentAt":"2008-06-19T22:33:59Z","receivedAt":"2008-06-19T22:33:59Z","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---\nSince this patch focuses on a case that is discouraged by the git-svn\nmanpage (use rewriteRoot even though commits already exist), a bit of\ndiscussion might be helpful. On the up side, I think it doesn't affect any\nother cases.\n\nThe specific problem situation looks like this:\n\n% git fetch git://.../clone-of-some-svn-repo (...)\n% git svn init -s --rewrite-root=<url contained in fetched commits> <url \\\n      we want to use>\n% git svn rebase\n[Boom]\n\nThis patch passes all existing git-svn tests; feel free to suggest\nadditional test(s) to cover this sort of situation.\n\n git-svn.perl |    6 +++---\n 1 files changed, 3 insertions(+), 3 deletions(-)\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 \n-- \n1.5.5.1\n"},{"id":"80568","messageId":"20080621213911.GA19691@untitled","threadId":"14046","inReplyTo":"20080620003359.0dbb7725@neuron","subject":"Re: [PATCH] git-svn: make rebuild respect rewriteRoot option","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2008-06-21T21:39:33Z","receivedAt":"2008-06-21T21:39:33Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Jan Krüger <jk@jk.gs> 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> \n> Addressing this behaviour fixes an apparently not too uncommon problem with\n> providing git-svn mirrors of Subversion repositories. Some repositories are\n> accessed using different URLs depending on whether the user has push\n> privileges or not. In the latter case, an anonymous URL is often used that\n> differs from the push URL. Providing a mirror that is usable in both cases\n> becomes a lot more possible with this change.\n> \n> Signed-off-by: Jan Krüger <jk@jk.gs>\n> ---\n> Since this patch focuses on a case that is discouraged by the git-svn\n> manpage (use rewriteRoot even though commits already exist), a bit of\n> discussion might be helpful. On the up side, I think it doesn't affect any\n> other cases.\n> \n> The specific problem situation looks like this:\n> \n> % git fetch git://.../clone-of-some-svn-repo (...)\n> % git svn init -s --rewrite-root=<url contained in fetched commits> <url \\\n>       we want to use>\n> % git svn rebase\n> [Boom]\n> \n> This patch passes all existing git-svn tests; feel free to suggest\n> additional test(s) to cover this sort of situation.\n\nSeems to make sense to me...  If you have a test case for this\nit'd be nicer :)\n\nAcked-by: Eric Wong <normalperson@yhbt.net>\n\n>  git-svn.perl |    6 +++---\n>  1 files changed, 3 insertions(+), 3 deletions(-)\n> \n> diff --git a/git-svn.perl b/git-svn.perl\n> index 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>  \n"}]}