git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git svn clone -r HEAD
@ 2009-07-16 19:12 Ka-Hing Cheung
  2009-07-20  5:55 ` Eric Wong
  0 siblings, 1 reply; 5+ messages in thread
From: Ka-Hing Cheung @ 2009-07-16 19:12 UTC (permalink / raw)
  To: git; +Cc: normalperson

Hi (not subscribed),

git-svn uses $ra->get_latest_revnum to find out the latest revision, but
that can be problematic, because get_latest_revnum returns the latest
revnum in the entire repository, not restricted by whatever URL you used
to construct $ra. So if you do git svn clone -r HEAD
svn://blah/blah/trunk, it won't work if the latest checkin is in one of
the branches (it will try to fetch a rev that doesn't exist in trunk,
making the clone useless).

This change seems to work, sorry it's not a proper diff:
@sub fetch_all {
-       my $head = $ra->get_latest_revnum;
+       my $head = undef;
+       $ra->get_log("", -1, 0, 1, 0, 1, sub { $head = $_[1] });

-khc

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git svn clone -r HEAD
  2009-07-16 19:12 git svn clone -r HEAD Ka-Hing Cheung
@ 2009-07-20  5:55 ` Eric Wong
  2009-07-23  6:43   ` [PATCH] git svn: fix shallow clone when upstream revision is too new Eric Wong
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Wong @ 2009-07-20  5:55 UTC (permalink / raw)
  To: Ka-Hing Cheung; +Cc: git

Ka-Hing Cheung <kcheung@riverbed.com> wrote:
> Hi (not subscribed),
> 
> git-svn uses $ra->get_latest_revnum to find out the latest revision, but
> that can be problematic, because get_latest_revnum returns the latest
> revnum in the entire repository, not restricted by whatever URL you used
> to construct $ra. So if you do git svn clone -r HEAD
> svn://blah/blah/trunk, it won't work if the latest checkin is in one of
> the branches (it will try to fetch a rev that doesn't exist in trunk,
> making the clone useless).
> 
> This change seems to work, sorry it's not a proper diff:
> @sub fetch_all {
> -       my $head = $ra->get_latest_revnum;
> +       my $head = undef;
> +       $ra->get_log("", -1, 0, 1, 0, 1, sub { $head = $_[1] });

Thanks Ka-Hing,

There's an unrelated issue with $ra->get_log being broken with http(s)
URLs that need escaping, so t9118 is failing on me when SVN_HTTPD_PORT
is set (I just found another fix that broke that test, too).  I'll push
out this fix when I can get t9118 fixed with HTTP.

-- 
Eric Wong

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] git svn: fix shallow clone when upstream revision is too new
  2009-07-20  5:55 ` Eric Wong
@ 2009-07-23  6:43   ` Eric Wong
  2009-07-23  6:47     ` Eric Wong
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Wong @ 2009-07-23  6:43 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Ka-Hing Cheung

Thanks to Ka-Hing Cheung for the initial bug report and patch:
> git-svn uses $ra->get_latest_revnum to find out the latest
> revision, but that can be problematic, because get_latest_revnum
> returns the latest revnum in the entire repository, not
> restricted by whatever URL you used to construct $ra. So if you
> do git svn clone -r HEAD svn://blah/blah/trunk, it won't work if
> the latest checkin is in one of the branches (it will try to
> fetch a rev that doesn't exist in trunk, making the clone
> useless).

Relying on SVN::Core::INVALID_REVNUM (-1) as the "start"
argument to SVN::Ra::get_log() proved unreliable with http(s)
URLs so the result of SVN::Ra::get_latest_revnum() is used as
the "start" argument instead.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
---

 Junio: Pushed out to git://git.bogomips.org/git-svn several
 days ago, I thought I had sent this email days ago but
 I had to leave in a hurry and never sent it.

 git-svn.perl                     |    1 +
 t/t9142-git-svn-shallow-clone.sh |   30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 0 deletions(-)
 create mode 100755 t/t9142-git-svn-shallow-clone.sh

diff --git a/git-svn.perl b/git-svn.perl
index 43c86e8..9369acc 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1647,6 +1647,7 @@ sub fetch_all {
 	my $ra = Git::SVN::Ra->new($url);
 	my $uuid = $ra->get_uuid;
 	my $head = $ra->get_latest_revnum;
+	$ra->get_log("", $head, 0, 1, 0, 1, sub { $head = $_[1] });
 	my $base = defined $fetch ? $head : 0;
 
 	# read the max revs for wildcard expansion (branches/*, tags/*)
diff --git a/t/t9142-git-svn-shallow-clone.sh b/t/t9142-git-svn-shallow-clone.sh
new file mode 100755
index 0000000..fd5ad49
--- /dev/null
+++ b/t/t9142-git-svn-shallow-clone.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+#
+# Copyright (c) 2009 Eric Wong
+#
+
+test_description='git svn shallow clone'
+. ./lib-git-svn.sh
+
+test_expect_success 'setup test repository' '
+	svn_cmd mkdir -m "create standard layout" \
+	  "$svnrepo"/trunk "$svnrepo"/branches "$svnrepo"/tags &&
+	svn_cmd cp -m "branch off trunk" \
+	  "$svnrepo"/trunk "$svnrepo"/branches/a &&
+	svn_cmd co "$svnrepo"/branches/a &&
+	(
+		cd a &&
+		> foo &&
+		svn_cmd add foo &&
+		svn_cmd commit -m "add foo"
+	)
+'
+
+start_httpd
+
+test_expect_success 'clone trunk with "-r HEAD"' '
+	git svn clone -r HEAD "$svnrepo/trunk" g &&
+	( cd g && git rev-parse --symbolic --verify HEAD )
+'
+
+test_done
-- 
Eric Wong

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] git svn: fix shallow clone when upstream revision is too new
  2009-07-23  6:43   ` [PATCH] git svn: fix shallow clone when upstream revision is too new Eric Wong
@ 2009-07-23  6:47     ` Eric Wong
  2009-07-23  6:56       ` Eric Wong
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Wong @ 2009-07-23  6:47 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Ka-Hing Cheung

Eric Wong <normalperson@yhbt.net> wrote:
>  Junio: Pushed out to git://git.bogomips.org/git-svn several
>  days ago, I thought I had sent this email days ago but
>  I had to leave in a hurry and never sent it.

Wait, that patch may be botched and that's why I didn't send
before leaving the other day... Oops.

-- 
Eric Wong

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] git svn: fix shallow clone when upstream revision is too new
  2009-07-23  6:47     ` Eric Wong
@ 2009-07-23  6:56       ` Eric Wong
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2009-07-23  6:56 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Ka-Hing Cheung

Eric Wong <normalperson@yhbt.net> wrote:
> Eric Wong <normalperson@yhbt.net> wrote:
> >  Junio: Pushed out to git://git.bogomips.org/git-svn several
> >  days ago, I thought I had sent this email days ago but
> >  I had to leave in a hurry and never sent it.
> 
> Wait, that patch may be botched and that's why I didn't send
> before leaving the other day... Oops.

Oops, false alarm, sorry about that.  All should be well with
4aacaeb3dc82bb6479e70e120053dc27a399460e

-- 
Eric Wong

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-07-23  6:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-16 19:12 git svn clone -r HEAD Ka-Hing Cheung
2009-07-20  5:55 ` Eric Wong
2009-07-23  6:43   ` [PATCH] git svn: fix shallow clone when upstream revision is too new Eric Wong
2009-07-23  6:47     ` Eric Wong
2009-07-23  6:56       ` Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).