{"thread":{"id":"20135","subject":"git svn clone -r HEAD","startedAt":"2009-07-16T19:12:12Z","lastAt":"2009-07-23T06:56:28Z","messageCount":5,"participants":["Ka-Hing Cheung","Eric Wong"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"118127","messageId":"1247771532.7382.115.camel@localhost","threadId":"20135","inReplyTo":null,"subject":"git svn clone -r HEAD","fromName":"Ka-Hing Cheung","fromEmail":"kcheung@riverbed.com","sentAt":"2009-07-16T19:12:12Z","receivedAt":"2009-07-16T19:12:12Z","isPatch":false,"sender":{"key":"kcheung@riverbed.com","avatar":null},"body":"Hi (not subscribed),\n\ngit-svn uses $ra->get_latest_revnum to find out the latest revision, but\nthat can be problematic, because get_latest_revnum returns the latest\nrevnum in the entire repository, not restricted by whatever URL you used\nto construct $ra. So if you do git svn clone -r HEAD\nsvn://blah/blah/trunk, it won't work if the latest checkin is in one of\nthe branches (it will try to fetch a rev that doesn't exist in trunk,\nmaking the clone useless).\n\nThis change seems to work, sorry it's not a proper diff:\n@sub fetch_all {\n-       my $head = $ra->get_latest_revnum;\n+       my $head = undef;\n+       $ra->get_log(\"\", -1, 0, 1, 0, 1, sub { $head = $_[1] });\n\n-khc\n"},{"id":"118281","messageId":"20090720055514.GA3229@dcvr.yhbt.net","threadId":"20135","inReplyTo":"1247771532.7382.115.camel@localhost","subject":"Re: git svn clone -r HEAD","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-07-20T05:55:14Z","receivedAt":"2009-07-20T05:55:14Z","isPatch":false,"sender":{"key":"e@80x24.org","avatar":null},"body":"Ka-Hing Cheung <kcheung@riverbed.com> wrote:\n> Hi (not subscribed),\n> \n> git-svn uses $ra->get_latest_revnum to find out the latest revision, but\n> that can be problematic, because get_latest_revnum returns the latest\n> revnum in the entire repository, not restricted by whatever URL you used\n> to construct $ra. So if you do git svn clone -r HEAD\n> svn://blah/blah/trunk, it won't work if the latest checkin is in one of\n> the branches (it will try to fetch a rev that doesn't exist in trunk,\n> making the clone useless).\n> \n> This change seems to work, sorry it's not a proper diff:\n> @sub fetch_all {\n> -       my $head = $ra->get_latest_revnum;\n> +       my $head = undef;\n> +       $ra->get_log(\"\", -1, 0, 1, 0, 1, sub { $head = $_[1] });\n\nThanks Ka-Hing,\n\nThere's an unrelated issue with $ra->get_log being broken with http(s)\nURLs that need escaping, so t9118 is failing on me when SVN_HTTPD_PORT\nis set (I just found another fix that broke that test, too).  I'll push\nout this fix when I can get t9118 fixed with HTTP.\n\n-- \nEric Wong\n"},{"id":"118560","messageId":"20090723064357.GA19062@dcvr.yhbt.net","threadId":"20135","inReplyTo":"20090720055514.GA3229@dcvr.yhbt.net","subject":"[PATCH] git svn: fix shallow clone when upstream revision is too new","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-07-23T06:43:57Z","receivedAt":"2009-07-23T06:43:57Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Thanks to Ka-Hing Cheung for the initial bug report and patch:\n> git-svn uses $ra->get_latest_revnum to find out the latest\n> revision, but that can be problematic, because get_latest_revnum\n> returns the latest revnum in the entire repository, not\n> restricted by whatever URL you used to construct $ra. So if you\n> do git svn clone -r HEAD svn://blah/blah/trunk, it won't work if\n> the latest checkin is in one of the branches (it will try to\n> fetch a rev that doesn't exist in trunk, making the clone\n> useless).\n\nRelying on SVN::Core::INVALID_REVNUM (-1) as the \"start\"\nargument to SVN::Ra::get_log() proved unreliable with http(s)\nURLs so the result of SVN::Ra::get_latest_revnum() is used as\nthe \"start\" argument instead.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n\n Junio: Pushed out to git://git.bogomips.org/git-svn several\n days ago, I thought I had sent this email days ago but\n I had to leave in a hurry and never sent it.\n\n git-svn.perl                     |    1 +\n t/t9142-git-svn-shallow-clone.sh |   30 ++++++++++++++++++++++++++++++\n 2 files changed, 31 insertions(+), 0 deletions(-)\n create mode 100755 t/t9142-git-svn-shallow-clone.sh\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 43c86e8..9369acc 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -1647,6 +1647,7 @@ sub fetch_all {\n \tmy $ra = Git::SVN::Ra->new($url);\n \tmy $uuid = $ra->get_uuid;\n \tmy $head = $ra->get_latest_revnum;\n+\t$ra->get_log(\"\", $head, 0, 1, 0, 1, sub { $head = $_[1] });\n \tmy $base = defined $fetch ? $head : 0;\n \n \t# read the max revs for wildcard expansion (branches/*, tags/*)\ndiff --git a/t/t9142-git-svn-shallow-clone.sh b/t/t9142-git-svn-shallow-clone.sh\nnew file mode 100755\nindex 0000000..fd5ad49\n--- /dev/null\n+++ b/t/t9142-git-svn-shallow-clone.sh\n@@ -0,0 +1,30 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2009 Eric Wong\n+#\n+\n+test_description='git svn shallow clone'\n+. ./lib-git-svn.sh\n+\n+test_expect_success 'setup test repository' '\n+\tsvn_cmd mkdir -m \"create standard layout\" \\\n+\t  \"$svnrepo\"/trunk \"$svnrepo\"/branches \"$svnrepo\"/tags &&\n+\tsvn_cmd cp -m \"branch off trunk\" \\\n+\t  \"$svnrepo\"/trunk \"$svnrepo\"/branches/a &&\n+\tsvn_cmd co \"$svnrepo\"/branches/a &&\n+\t(\n+\t\tcd a &&\n+\t\t> foo &&\n+\t\tsvn_cmd add foo &&\n+\t\tsvn_cmd commit -m \"add foo\"\n+\t)\n+'\n+\n+start_httpd\n+\n+test_expect_success 'clone trunk with \"-r HEAD\"' '\n+\tgit svn clone -r HEAD \"$svnrepo/trunk\" g &&\n+\t( cd g && git rev-parse --symbolic --verify HEAD )\n+'\n+\n+test_done\n-- \nEric Wong\n"},{"id":"118561","messageId":"20090723064759.GA2002@dcvr.yhbt.net","threadId":"20135","inReplyTo":"20090723064357.GA19062@dcvr.yhbt.net","subject":"Re: [PATCH] git svn: fix shallow clone when upstream revision is too new","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-07-23T06:47:59Z","receivedAt":"2009-07-23T06:47:59Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Eric Wong <normalperson@yhbt.net> wrote:\n>  Junio: Pushed out to git://git.bogomips.org/git-svn several\n>  days ago, I thought I had sent this email days ago but\n>  I had to leave in a hurry and never sent it.\n\nWait, that patch may be botched and that's why I didn't send\nbefore leaving the other day... Oops.\n\n-- \nEric Wong\n"},{"id":"118562","messageId":"20090723065628.GA31960@dcvr.yhbt.net","threadId":"20135","inReplyTo":"20090723064759.GA2002@dcvr.yhbt.net","subject":"Re: [PATCH] git svn: fix shallow clone when upstream revision is too new","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-07-23T06:56:28Z","receivedAt":"2009-07-23T06:56:28Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Eric Wong <normalperson@yhbt.net> wrote:\n> Eric Wong <normalperson@yhbt.net> wrote:\n> >  Junio: Pushed out to git://git.bogomips.org/git-svn several\n> >  days ago, I thought I had sent this email days ago but\n> >  I had to leave in a hurry and never sent it.\n> \n> Wait, that patch may be botched and that's why I didn't send\n> before leaving the other day... Oops.\n\nOops, false alarm, sorry about that.  All should be well with\n4aacaeb3dc82bb6479e70e120053dc27a399460e\n\n-- \nEric Wong\n"}]}