{"thread":{"id":"24096","subject":"[PATCH/RFC] git-svn: strip off leading slashes on --trunk argument","startedAt":"2010-06-13T11:27:43Z","lastAt":"2010-06-14T04:57:35Z","messageCount":2,"participants":["Jonathan Nieder","Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"143606","messageId":"20100613112743.GA21855@burratino","threadId":"24096","inReplyTo":"20090915113634.GC22524@ra.ncl.ac.uk","subject":"[PATCH/RFC] git-svn: strip off leading slashes on --trunk argument","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-13T11:27:43Z","receivedAt":"2010-06-13T11:27:43Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"The following command\n\n git svn clone \\\n\t-r9500:10006 \\\n\tsvn://svn.debian.org/svn/pkg-games/packages \\\n\t--trunk=/trunk/freedoom \\\n\t--branches=/branches/freedoom \\\n\t--tags=/tags/freedoom \\\n\tfreedoom.git.2009091\n\nproduces strange results:\n\nWith v1.6.3.3 (and perhaps earlier versions), this would fetch up to\nand including r9978 (the last revision of the no_iwad_alternatives\nbranch before it was deleted), check it out, and prematurely declare\nsuccess, leaving out some commits to the trunk (r9984, r9985, r10006)\nfrom after the branch was merged.\n\nWith v1.6.5-rc0~74 (svn: allow branches outside of refs/remotes,\n2009-08-11) and later, this fetches up to and including r9978 and then\nattempts a post-fetch checkout and fails.\n\n r9978 = 25f0920175c395f0f22f54ae7a2318147f745274\n (refs/remotes/no_iwad_alternatives)\n fatal: refs/remotes/trunk: not a valid SHA1\n update-ref refs/heads/master refs/remotes/trunk: command returned error: 128\n\nChecking .git/config reveals\n\n fetch = packages//trunk/freedoom:refs/remotes/trunk\n\nAnd with both 1.6.3.3 and 1.7.1, using --trunk=trunk/freedom without\nthe leading slash (/) works fine.\n\nMoral: git-svn needs to scrub an initial / from $_trunk and related\narguments it receives.  Make it so.\n\nReported-by: Jon Dowland <jmtd@debian.org>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nHi Eric,\n\nIt’s not clear to me what’s going on here, but this seems to fix it.  Insights?\n\nJonathan\n\nFrom\n\n  http://bugs.debian.org/546733\n  http://bugs.debian.org/572847\n\n git-svn.perl |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 265852f..a352000 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -959,6 +959,7 @@ sub cmd_multi_init {\n \t}\n \tdo_git_init_db();\n \tif (defined $_trunk) {\n+\t\t$_trunk =~ s#^/+##;\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-- \n1.7.0.dirty\n"},{"id":"143627","messageId":"20100614045735.GA22999@dcvr.yhbt.net","threadId":"24096","inReplyTo":"20100613112743.GA21855@burratino","subject":"Re: [PATCH/RFC] git-svn: strip off leading slashes on --trunk argument","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2010-06-14T04:57:35Z","receivedAt":"2010-06-14T04:57:35Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Jonathan Nieder <jrnieder@gmail.com> wrote:\n> The following command\n> \n>  git svn clone \\\n> \t-r9500:10006 \\\n> \tsvn://svn.debian.org/svn/pkg-games/packages \\\n> \t--trunk=/trunk/freedoom \\\n> \t--branches=/branches/freedoom \\\n> \t--tags=/tags/freedoom \\\n> \tfreedoom.git.2009091\n> \n> produces strange results:\n> \n> With v1.6.3.3 (and perhaps earlier versions), this would fetch up to\n> and including r9978 (the last revision of the no_iwad_alternatives\n> branch before it was deleted), check it out, and prematurely declare\n> success, leaving out some commits to the trunk (r9984, r9985, r10006)\n> from after the branch was merged.\n> \n> With v1.6.5-rc0~74 (svn: allow branches outside of refs/remotes,\n> 2009-08-11) and later, this fetches up to and including r9978 and then\n> attempts a post-fetch checkout and fails.\n> \n>  r9978 = 25f0920175c395f0f22f54ae7a2318147f745274\n>  (refs/remotes/no_iwad_alternatives)\n>  fatal: refs/remotes/trunk: not a valid SHA1\n>  update-ref refs/heads/master refs/remotes/trunk: command returned error: 128\n> \n> Checking .git/config reveals\n> \n>  fetch = packages//trunk/freedoom:refs/remotes/trunk\n> \n> And with both 1.6.3.3 and 1.7.1, using --trunk=trunk/freedom without\n> the leading slash (/) works fine.\n> \n> Moral: git-svn needs to scrub an initial / from $_trunk and related\n> arguments it receives.  Make it so.\n> \n> Reported-by: Jon Dowland <jmtd@debian.org>\n> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n\nAcked-by: Eric Wong <normalperson@yhbt.net>\n\n...and pushed out to git://git.bogomips.org/git-svn along with\none follow-up patch:\n\nEric Wong (1):\n      git svn: avoid unnecessary '/' in paths for SVN\n\nJonathan Nieder (1):\n      git-svn: strip off leading slashes on --trunk argument\n\n> ---\n> Hi Eric,\n> \n> It’s not clear to me what’s going on here, but this seems to fix it.\n> Insights?\n\nThe svn:// server is more picky about the \"//\" than http:// or file://.\n\nSo we were skipping fetches from trunk completely, and never created\na ref for it.  Since git-svn attempts to checkout a \"master\" ref based\non trunk, it fails since trunk is a non-existent ref.\n\nFrom b1a954a37cea7d5a0a123758f6c2ad9005d4481e Mon Sep 17 00:00:00 2001\nFrom: Eric Wong <normalperson@yhbt.net>\nDate: Mon, 14 Jun 2010 04:31:10 +0000\nSubject: [PATCH] git svn: avoid unnecessary '/' in paths for SVN\n\nsvn:// servers are more picky regarding redundant slashes\nthan file:// and http(s)://-backed respositories.  Since\nthe last commit, we avoid putting unnecessary slashes in\n$GIT_CONFIG, but this doesn't help users who are already\nset up that way.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n git-svn.perl |    3 +++\n 1 files changed, 3 insertions(+), 0 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 80ab450..19d6848 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -2055,6 +2055,9 @@ sub new {\n \t\t         \"\\\":$ref_id\\$\\\" in config\\n\";\n \t\t($self->{path}, undef) = split(/\\s*:\\s*/, $fetch);\n \t}\n+\t$self->{path} =~ s{/+}{/}g;\n+\t$self->{path} =~ s{\\A/}{};\n+\t$self->{path} =~ s{/\\z}{};\n \t$self->{url} = command_oneline('config', '--get',\n \t                               \"svn-remote.$repo_id.url\") or\n                   die \"Failed to read \\\"svn-remote.$repo_id.url\\\" in config\\n\";\n-- \nEric Wong\n"}]}