{"thread":{"id":"4572","subject":"git-svn: don't use the --rmdir feature with SVN libs","startedAt":"2006-06-19T23:34:25Z","lastAt":"2006-06-20T05:53:33Z","messageCount":6,"participants":["Eric Wong","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"22081","messageId":"20060619233424.GD3929@localdomain","threadId":"4572","inReplyTo":null,"subject":"git-svn: don't use the --rmdir feature with SVN libs","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-06-19T23:34:25Z","receivedAt":"2006-06-19T23:34:25Z","isPatch":false,"sender":{"key":"e@80x24.org","avatar":null},"body":"It's very broken when committing.  It's off by default, and somehow my\ntests didn't catch it.  I'll fix it ASAP tonight.\n\nSorry if anybody else hit it before I did.\n\n-- \nEric Wong\n"},{"id":"22091","messageId":"11507645052855-git-send-email-normalperson@yhbt.net","threadId":"4572","inReplyTo":"20060619233424.GD3929@localdomain","subject":"Re: git-svn: don't use the --rmdir feature with SVN libs","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-06-20T00:48:24Z","receivedAt":"2006-06-20T00:48:24Z","isPatch":false,"sender":{"key":"e@80x24.org","avatar":null},"body":"Fortunately, the fix is pretty simple.  But yes, this is the\nscariest bug in git-svn that's ever happened :x\n"},{"id":"22092","messageId":"1150764508339-git-send-email-normalperson@yhbt.net","threadId":"4572","inReplyTo":"11507645052855-git-send-email-normalperson@yhbt.net","subject":"[PATCH] git-svn: fix --rmdir when using SVN:: libraries","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-06-20T00:48:25Z","receivedAt":"2006-06-20T00:48:25Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"When tracking directories with nearly all of its files at\nthe most nested levels, --rmdir would accidentally go too\nfar when deleting.\n\nOf course, we'll add a test for this condition, too.\n\nMakefile: automatically run new tests as they appear in t/\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n contrib/git-svn/git-svn.perl          |   15 +++++++++++----\n contrib/git-svn/t/t0002-deep-rmdir.sh |   29 +++++++++++++++++++++++++++++\n 2 files changed, 40 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl\nindex da0ff9a..7e7f2f0 100755\n--- a/contrib/git-svn/git-svn.perl\n+++ b/contrib/git-svn/git-svn.perl\n@@ -2841,13 +2841,20 @@ sub rmdirs {\n \t\texec qw/git-ls-tree --name-only -r -z/, $self->{c} or croak $!;\n \t}\n \tlocal $/ = \"\\0\";\n+\tmy @svn_path = split m#/#, $self->{svn_path};\n \twhile (<$fh>) {\n \t\tchomp;\n-\t\t$_ = $self->{svn_path} . '/' . $_;\n-\t\tmy ($dn) = ($_ =~ m#^(.*?)/?(?:[^/]+)$#);\n-\t\tdelete $rm->{$dn};\n-\t\tlast unless %$rm;\n+\t\tmy @dn = (@svn_path, (split m#/#, $_));\n+\t\twhile (pop @dn) {\n+\t\t\tdelete $rm->{join '/', @dn};\n+\t\t}\n+\t\tunless (%$rm) {\n+\t\t\tclose $fh;\n+\t\t\treturn;\n+\t\t}\n \t}\n+\tclose $fh;\n+\n \tmy ($r, $p, $bat) = ($self->{r}, $self->{pool}, $self->{bat});\n \tforeach my $d (sort { $b =~ tr#/#/# <=> $a =~ tr#/#/# } keys %$rm) {\n \t\t$self->close_directory($bat->{$d}, $p);\ndiff --git a/contrib/git-svn/t/t0002-deep-rmdir.sh b/contrib/git-svn/t/t0002-deep-rmdir.sh\nnew file mode 100755\nindex 0000000..d693d18\n--- /dev/null\n+++ b/contrib/git-svn/t/t0002-deep-rmdir.sh\n@@ -0,0 +1,29 @@\n+test_description='git-svn rmdir'\n+. ./lib-git-svn.sh\n+\n+test_expect_success 'initialize repo' \"\n+\tmkdir import &&\n+\tcd import &&\n+\tmkdir -p deeply/nested/directory/number/1 &&\n+\tmkdir -p deeply/nested/directory/number/2 &&\n+\techo foo > deeply/nested/directory/number/1/file &&\n+\techo foo > deeply/nested/directory/number/2/another &&\n+\tsvn import -m 'import for git-svn' . $svnrepo &&\n+\tcd ..\n+\t\"\n+\n+test_expect_success 'mirror via git-svn' \"\n+\tgit-svn init $svnrepo &&\n+\tgit-svn fetch &&\n+\tgit checkout -f -b test-rmdir remotes/git-svn\n+\t\"\n+\n+test_expect_success 'Try a commit on rmdir' \"\n+\tgit rm -f deeply/nested/directory/number/2/another &&\n+\tgit commit -a -m 'remove another' &&\n+\tgit-svn commit --rmdir HEAD &&\n+\tsvn ls -R $svnrepo | grep ^deeply/nested/directory/number/1\n+\t\"\n+\n+\n+test_done\n-- \n1.4.GIT\n"},{"id":"22093","messageId":"11507651751452-git-send-email-normalperson@yhbt.net","threadId":"4572","inReplyTo":"11507645052855-git-send-email-normalperson@yhbt.net","subject":"[PATCH (fixed)] git-svn: fix --rmdir when using SVN:: libraries","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-06-20T00:59:35Z","receivedAt":"2006-06-20T00:59:35Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"When tracking directories with nearly all of its files at\nthe most nested levels, --rmdir would accidentally go too\nfar when deleting.\n\nOf course, we'll add a test for this condition, too.\n\nMakefile: automatically run new tests as they appear in t/\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n\nOops, I left out the Makefile change in the other patch, had the new\ntest file as +x\n\n contrib/git-svn/Makefile              |    3 +--\n contrib/git-svn/git-svn.perl          |   15 +++++++++++----\n contrib/git-svn/t/t0002-deep-rmdir.sh |   29 +++++++++++++++++++++++++++++\n 3 files changed, 41 insertions(+), 6 deletions(-)\n\ndiff --git a/contrib/git-svn/Makefile b/contrib/git-svn/Makefile\nindex 6aedb10..7c20946 100644\n--- a/contrib/git-svn/Makefile\n+++ b/contrib/git-svn/Makefile\n@@ -29,8 +29,7 @@ git-svn.html : git-svn.txt\n \tasciidoc -b xhtml11 -d manpage \\\n \t\t-f ../../Documentation/asciidoc.conf $<\n test: git-svn\n-\tcd t && $(SHELL) ./t0000-contrib-git-svn.sh $(TEST_FLAGS)\n-\tcd t && $(SHELL) ./t0001-contrib-git-svn-props.sh $(TEST_FLAGS)\n+\tcd t && for i in t????-*.sh; do $(SHELL) ./$$i $(TEST_FLAGS); done\n \n # we can test NO_OPTIMIZE_COMMITS independently of LC_ALL\n full-test:\ndiff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl\nindex da0ff9a..7e7f2f0 100755\n--- a/contrib/git-svn/git-svn.perl\n+++ b/contrib/git-svn/git-svn.perl\n@@ -2841,13 +2841,20 @@ sub rmdirs {\n \t\texec qw/git-ls-tree --name-only -r -z/, $self->{c} or croak $!;\n \t}\n \tlocal $/ = \"\\0\";\n+\tmy @svn_path = split m#/#, $self->{svn_path};\n \twhile (<$fh>) {\n \t\tchomp;\n-\t\t$_ = $self->{svn_path} . '/' . $_;\n-\t\tmy ($dn) = ($_ =~ m#^(.*?)/?(?:[^/]+)$#);\n-\t\tdelete $rm->{$dn};\n-\t\tlast unless %$rm;\n+\t\tmy @dn = (@svn_path, (split m#/#, $_));\n+\t\twhile (pop @dn) {\n+\t\t\tdelete $rm->{join '/', @dn};\n+\t\t}\n+\t\tunless (%$rm) {\n+\t\t\tclose $fh;\n+\t\t\treturn;\n+\t\t}\n \t}\n+\tclose $fh;\n+\n \tmy ($r, $p, $bat) = ($self->{r}, $self->{pool}, $self->{bat});\n \tforeach my $d (sort { $b =~ tr#/#/# <=> $a =~ tr#/#/# } keys %$rm) {\n \t\t$self->close_directory($bat->{$d}, $p);\ndiff --git a/contrib/git-svn/t/t0002-deep-rmdir.sh b/contrib/git-svn/t/t0002-deep-rmdir.sh\nnew file mode 100644\nindex 0000000..d693d18\n--- /dev/null\n+++ b/contrib/git-svn/t/t0002-deep-rmdir.sh\n@@ -0,0 +1,29 @@\n+test_description='git-svn rmdir'\n+. ./lib-git-svn.sh\n+\n+test_expect_success 'initialize repo' \"\n+\tmkdir import &&\n+\tcd import &&\n+\tmkdir -p deeply/nested/directory/number/1 &&\n+\tmkdir -p deeply/nested/directory/number/2 &&\n+\techo foo > deeply/nested/directory/number/1/file &&\n+\techo foo > deeply/nested/directory/number/2/another &&\n+\tsvn import -m 'import for git-svn' . $svnrepo &&\n+\tcd ..\n+\t\"\n+\n+test_expect_success 'mirror via git-svn' \"\n+\tgit-svn init $svnrepo &&\n+\tgit-svn fetch &&\n+\tgit checkout -f -b test-rmdir remotes/git-svn\n+\t\"\n+\n+test_expect_success 'Try a commit on rmdir' \"\n+\tgit rm -f deeply/nested/directory/number/2/another &&\n+\tgit commit -a -m 'remove another' &&\n+\tgit-svn commit --rmdir HEAD &&\n+\tsvn ls -R $svnrepo | grep ^deeply/nested/directory/number/1\n+\t\"\n+\n+\n+test_done\n-- \n1.4.GIT\n"},{"id":"22094","messageId":"7vbqso7him.fsf@assigned-by-dhcp.cox.net","threadId":"4572","inReplyTo":"11507651751452-git-send-email-normalperson@yhbt.net","subject":"Re: [PATCH (fixed)] git-svn: fix --rmdir when using SVN:: libraries","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-06-20T01:17:05Z","receivedAt":"2006-06-20T01:17:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Wong <normalperson@yhbt.net> writes:\n\n> Makefile: automatically run new tests as they appear in t/\n>\n> Signed-off-by: Eric Wong <normalperson@yhbt.net>\n> ---\n>\n> Oops, I left out the Makefile change in the other patch,...\n\nYeah, I was wondering about that.\n\n> ... had the new\n> test file as +x\n\nShouldn't they be executable?  It is not a big deal, because you\nrun them via $(SHELL), though...\n"},{"id":"22103","messageId":"20060620055333.GA17674@hand.yhbt.net","threadId":"4572","inReplyTo":"7vbqso7him.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH (fixed)] git-svn: fix --rmdir when using SVN:: libraries","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-06-20T05:53:33Z","receivedAt":"2006-06-20T05:53:33Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> Eric Wong <normalperson@yhbt.net> writes:\n> \n> > Makefile: automatically run new tests as they appear in t/\n> >\n> > Signed-off-by: Eric Wong <normalperson@yhbt.net>\n> > ---\n> >\n> > Oops, I left out the Makefile change in the other patch,...\n> \n> Yeah, I was wondering about that.\n> \n> > ... had the new\n> > test file as +x\n> \n> Shouldn't they be executable?  It is not a big deal, because you\n> run them via $(SHELL), though...\n\nYes, I prefer to use $(SHELL) instead.  Makes it easier to test with\ndifferent shells without mucking /bin/sh\n\n-- \nEric Wong\n"}]}