{"thread":{"id":"21717","subject":"Re: git-svn: Fails to drop leading path from empty dir name","startedAt":"2009-11-22T13:46:38Z","lastAt":"2009-11-23T02:21:36Z","messageCount":4,"participants":["Eric Wong","Björn Steinbrink"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"129240","messageId":"20091122134638.GA12233@atjola.homenet","threadId":"21717","inReplyTo":null,"subject":"git-svn: Fails to drop leading path from empty dir name","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2009-11-22T13:46:38Z","receivedAt":"2009-11-22T13:46:38Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"Hi Eric,\n\nthe stuff to create empty directories fails to strip leading path\ncomponents, e.g. when using\n\"git svn clone -s svn://whatever/project/trunk\".\n\nInstead of creating the empty directory \"foo\" in the repo root, it\ncreates \"project/trunk/foo\".\n\nAd hoc patch for the test case below.\n\nBjörn\n\ndiff --git a/t/t9146-git-svn-empty-dirs.sh b/t/t9146-git-svn-empty-dirs.sh\nindex 5948544..9e22089 100755\n--- a/t/t9146-git-svn-empty-dirs.sh\n+++ b/t/t9146-git-svn-empty-dirs.sh\n@@ -82,4 +82,27 @@ test_expect_success 'git svn mkdirs -r works' '\n \t)\n '\n \n+test_expect_success 'initialize trunk' '\n+\tfor i in trunk trunk/a trunk/\"weird file name\"\n+\tdo\n+\t\tsvn_cmd mkdir -m \"mkdir $i\" \"$svnrepo\"/\"$i\"\n+\tdone\n+'\n+\n+test_expect_success 'clone trunk' 'git svn clone -s \"$svnrepo\" trunk'\n+\n+test_expect_success 'empty directories in trunk exist' '\n+\t(\n+\t\tcd cloned &&\n+\t\tfor i in trunk/a trunk/\"weird file name\"\n+\t\tdo\n+\t\t\tif ! test -d \"$i\"\n+\t\t\tthen\n+\t\t\t\techo >&2 \"$i does not exist\"\n+\t\t\t\texit 1\n+\t\t\tfi\n+\t\tdone\n+\t)\n+'\n+\n test_done\n"},{"id":"128131","messageId":"20091122232504.GA28127@dcvr.yhbt.net","threadId":"21717","inReplyTo":"20091122134638.GA12233@atjola.homenet","subject":"Re: git-svn: Fails to drop leading path from empty dir name","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-11-22T23:25:04Z","receivedAt":"2009-11-22T23:25:04Z","isPatch":false,"sender":{"key":"e@80x24.org","avatar":null},"body":"Björn Steinbrink <B.Steinbrink@gmx.de> wrote:\n> Hi Eric,\n> \n> the stuff to create empty directories fails to strip leading path\n> components, e.g. when using\n> \"git svn clone -s svn://whatever/project/trunk\".\n> \n> Instead of creating the empty directory \"foo\" in the repo root, it\n> creates \"project/trunk/foo\".\n> \n> Ad hoc patch for the test case below.\n> \n> Björn\n> \n> diff --git a/t/t9146-git-svn-empty-dirs.sh b/t/t9146-git-svn-empty-dirs.sh\n> index 5948544..9e22089 100755\n> --- a/t/t9146-git-svn-empty-dirs.sh\n> +++ b/t/t9146-git-svn-empty-dirs.sh\n> @@ -82,4 +82,27 @@ test_expect_success 'git svn mkdirs -r works' '\n>  \t)\n>  '\n>  \n> +test_expect_success 'initialize trunk' '\n> +\tfor i in trunk trunk/a trunk/\"weird file name\"\n> +\tdo\n> +\t\tsvn_cmd mkdir -m \"mkdir $i\" \"$svnrepo\"/\"$i\"\n> +\tdone\n> +'\n> +\n\nHi Björn,\n\nI'm having a bit of trouble figuring out exactly what you mean\nhere, can you double check your tests?  Annotations below, thanks\n\n> +test_expect_success 'clone trunk' 'git svn clone -s \"$svnrepo\" trunk'\n                                                    ^^            ^^^^^\n                                                           Huh?\n\n> +test_expect_success 'empty directories in trunk exist' '\n> +\t(\n> +\t\tcd cloned &&\n                   ^^^^^^ - ?\n\n> +\t\tfor i in trunk/a trunk/\"weird file name\"\n> +\t\tdo\n> +\t\t\tif ! test -d \"$i\"\n> +\t\t\tthen\n> +\t\t\t\techo >&2 \"$i does not exist\"\n> +\t\t\t\texit 1\n> +\t\t\tfi\n> +\t\tdone\n\n-- \nEric Wong\n"},{"id":"128135","messageId":"20091122235248.GA17418@atjola.homenet","threadId":"21717","inReplyTo":"20091122232504.GA28127@dcvr.yhbt.net","subject":"Re: git-svn: Fails to drop leading path from empty dir name","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2009-11-22T23:52:48Z","receivedAt":"2009-11-22T23:52:48Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"Hi Eric,\n\nOn 2009.11.22 15:25:04 -0800, Eric Wong wrote:\n> Björn Steinbrink <B.Steinbrink@gmx.de> wrote:\n\n> I'm having a bit of trouble figuring out exactly what you mean\n> here, can you double check your tests?  Annotations below, thanks\n> \n> > +test_expect_success 'clone trunk' 'git svn clone -s \"$svnrepo\" trunk'\n>                                                     ^^            ^^^^^\n>                                                            Huh?\n> \n> > +test_expect_success 'empty directories in trunk exist' '\n> > +\t(\n> > +\t\tcd cloned &&\n>                    ^^^^^^ - ?\n> \n> > +\t\tfor i in trunk/a trunk/\"weird file name\"\n\nArgh, yeah, I messed that patch up, the test only failed because I also\nmessed up this line, adding the trunk prefix there, too. Fixed patch\nbelow.\n\nSVN Repo layout:\n\n/\n|\n|---trunk\n|   |\n... |---foo/ # Empty\n    |\n    |---bar/\n        |\n        somefile\n\nwith \"git svn clone -s svn://host/path/to/repo you get:\n\n.git\nbar/\nbar/somefile\ntrunk/foo # This should be just foo/\n\ni.e. the empty directories have their path relative to the repo root,\ninstead of relative to the directory the git branch is associated with.\n\nSorry for the messed up first patch.\n\nBjörn\n\ndiff --git a/t/t9146-git-svn-empty-dirs.sh b/t/t9146-git-svn-empty-dirs.sh\nindex 5948544..70c52c1 100755\n--- a/t/t9146-git-svn-empty-dirs.sh\n+++ b/t/t9146-git-svn-empty-dirs.sh\n@@ -82,4 +82,27 @@ test_expect_success 'git svn mkdirs -r works' '\n \t)\n '\n \n+test_expect_success 'initialize trunk' '\n+\tfor i in trunk trunk/a trunk/\"weird file name\"\n+\tdo\n+\t\tsvn_cmd mkdir -m \"mkdir $i\" \"$svnrepo\"/\"$i\"\n+\tdone\n+'\n+\n+test_expect_success 'clone trunk' 'git svn clone -s \"$svnrepo\" trunk'\n+\n+test_expect_success 'empty directories in trunk exist' '\n+\t(\n+\t\tcd trunk &&\n+\t\tfor i in a \"weird file name\"\n+\t\tdo\n+\t\t\tif ! test -d \"$i\"\n+\t\t\tthen\n+\t\t\t\techo >&2 \"$i does not exist\"\n+\t\t\t\texit 1\n+\t\t\tfi\n+\t\tdone\n+\t)\n+'\n+\n test_done\n"},{"id":"128144","messageId":"20091123022136.GA1055@dcvr.yhbt.net","threadId":"21717","inReplyTo":"20091122235248.GA17418@atjola.homenet","subject":"[PATCH] git svn: strip leading path when making empty dirs","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-11-23T02:21:36Z","receivedAt":"2009-11-23T02:21:36Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Björn Steinbrink <B.Steinbrink@gmx.de> wrote:\n> Argh, yeah, I messed that patch up, the test only failed because I also\n> messed up this line, adding the trunk prefix there, too. Fixed patch\n> below.\n> \n> SVN Repo layout:\n> \n> /\n> |\n> |---trunk\n> |   |\n> ... |---foo/ # Empty\n>     |\n>     |---bar/\n>         |\n>         somefile\n> \n> with \"git svn clone -s svn://host/path/to/repo you get:\n> \n> .git\n> bar/\n> bar/somefile\n> trunk/foo # This should be just foo/\n> \n> i.e. the empty directories have their path relative to the repo root,\n> instead of relative to the directory the git branch is associated with.\n> \n> Sorry for the messed up first patch.\n\nNo worries, thanks for the bug report and test case.  My brain's been\ncompletely fried lately so I was completely confused :x\nAnyways this should fix it:\n\n     Also pushed out to git://git.bogomips.org/git-svn:\n\tEric Wong (2):\n\t      git svn: always reuse existing remotes on fetch\n\t      git svn: strip leading path when making empty dirs\n\nFrom 9be30eed61993a6f2d04a1609723e64e7632a64e Mon Sep 17 00:00:00 2001\nFrom: Eric Wong <normalperson@yhbt.net>\nDate: Sun, 22 Nov 2009 18:11:32 -0800\nSubject: [PATCH] git svn: strip leading path when making empty dirs\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n\nSince unhandled.log stores paths relative to the repository\nroot, we need to strip out leading path components if the\ndirectories we're tracking are not the repository root.\n\nReported-by: Björn Steinbrink\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n git-svn.perl                  |    3 +++\n t/t9146-git-svn-empty-dirs.sh |   23 +++++++++++++++++++++++\n 2 files changed, 26 insertions(+), 0 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 7f7a56f..957d44e 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -2752,8 +2752,11 @@ sub mkemptydirs {\n \t\t}\n \t}\n \tclose $fh;\n+\n+\tmy $strip = qr/\\A\\Q$self->{path}\\E(?:\\/|$)/;\n \tforeach my $d (sort keys %empty_dirs) {\n \t\t$d = uri_decode($d);\n+\t\t$d =~ s/$strip//;\n \t\tnext if -d $d;\n \t\tif (-e _) {\n \t\t\twarn \"$d exists but is not a directory\\n\";\ndiff --git a/t/t9146-git-svn-empty-dirs.sh b/t/t9146-git-svn-empty-dirs.sh\nindex 5948544..70c52c1 100755\n--- a/t/t9146-git-svn-empty-dirs.sh\n+++ b/t/t9146-git-svn-empty-dirs.sh\n@@ -82,4 +82,27 @@ test_expect_success 'git svn mkdirs -r works' '\n \t)\n '\n \n+test_expect_success 'initialize trunk' '\n+\tfor i in trunk trunk/a trunk/\"weird file name\"\n+\tdo\n+\t\tsvn_cmd mkdir -m \"mkdir $i\" \"$svnrepo\"/\"$i\"\n+\tdone\n+'\n+\n+test_expect_success 'clone trunk' 'git svn clone -s \"$svnrepo\" trunk'\n+\n+test_expect_success 'empty directories in trunk exist' '\n+\t(\n+\t\tcd trunk &&\n+\t\tfor i in a \"weird file name\"\n+\t\tdo\n+\t\t\tif ! test -d \"$i\"\n+\t\t\tthen\n+\t\t\t\techo >&2 \"$i does not exist\"\n+\t\t\t\texit 1\n+\t\t\tfi\n+\t\tdone\n+\t)\n+'\n+\n test_done\n-- \nEric Wong\n"}]}