{"thread":{"id":"8290","subject":"[PATCH] Fix git-svn to handle svn not reporting the md5sum of a file, and test.","startedAt":"2007-05-24T04:37:06Z","lastAt":"2007-05-27T23:04:02Z","messageCount":6,"participants":["James Y Knight","Eric Wong","A Large Angry SCM"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"43095","messageId":"1179981426176-git-send-email-foom@fuhm.net","threadId":"8290","inReplyTo":null,"subject":"[PATCH] Fix git-svn to handle svn not reporting the md5sum of a file, and test.","fromName":"James Y Knight","fromEmail":"foom@fuhm.net","sentAt":"2007-05-24T04:37:06Z","receivedAt":"2007-05-24T04:37:06Z","isPatch":true,"sender":{"key":"jknight@itasoftware.com","avatar":null},"body":"---\n git-svn.perl                    |    2 +-\n t/t9112-git-svn-md5less-file.sh |   45 +++++++++++++++++++++++++++++++++++++++\n 2 files changed, 46 insertions(+), 1 deletions(-)\n create mode 100755 t/t9112-git-svn-md5less-file.sh\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 3c4f490..b2773dc 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -2471,7 +2471,7 @@ sub close_file {\n \t\t$md5->addfile($fh);\n \t\tmy $got = $md5->hexdigest;\n \t\tdie \"Checksum mismatch: $path\\n\",\n-\t\t    \"expected: $exp\\n    got: $got\\n\" if ($got ne $exp);\n+\t\t    \"expected: $exp\\n    got: $got\\n\" if (defined $exp && $got ne $exp);\n \t\tsysseek($fh, 0, 0) or croak $!;\n \t\tif ($fb->{mode_b} == 120000) {\n \t\t\tsysread($fh, my $buf, 5) == 5 or croak $!;\ndiff --git a/t/t9112-git-svn-md5less-file.sh b/t/t9112-git-svn-md5less-file.sh\nnew file mode 100755\nindex 0000000..08313bb\n--- /dev/null\n+++ b/t/t9112-git-svn-md5less-file.sh\n@@ -0,0 +1,45 @@\n+test_description='test that git handles an svn repository with missing md5sums'\n+\n+. ./lib-git-svn.sh\n+\n+# Loading a node from a svn dumpfile without a Text-Content-Length\n+# field causes svn to neglect to store or report an md5sum.  (it will\n+# calculate one if you had put Text-Content-Length: 0).  This showed\n+# up in a repository creted with cvs2svn.\n+\n+cat > dumpfile.svn <<EOF\n+SVN-fs-dump-format-version: 1\n+\n+Revision-number: 1\n+Prop-content-length: 98\n+Content-length: 98\n+\n+K 7\n+svn:log\n+V 0\n+\n+K 10\n+svn:author\n+V 4\n+test\n+K 8\n+svn:date\n+V 27\n+2007-05-06T12:37:01.153339Z\n+PROPS-END\n+\n+Node-path: md5less-file\n+Node-kind: file\n+Node-action: add\n+Prop-content-length: 10\n+Content-length: 10\n+\n+PROPS-END\n+\n+EOF\n+\n+test_expect_success 'load svn dumpfile' \"svnadmin load $rawsvnrepo < dumpfile.svn\"\n+\n+test_expect_success 'initialize git-svn' \"git-svn init $svnrepo\"\n+test_expect_success 'fetch revisions from svn' 'git-svn fetch'\n+test_done\n-- \n1.5.2.rc2.1.g7f0b\n"},{"id":"43112","messageId":"20070524091655.GA29070@muzzle","threadId":"8290","inReplyTo":"1179981426176-git-send-email-foom@fuhm.net","subject":"Re: [PATCH] Fix git-svn to handle svn not reporting the md5sum of a file, and test.","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2007-05-24T09:16:56Z","receivedAt":"2007-05-24T09:16:56Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"James Y Knight <foom@fuhm.net> wrote:\n\nThanks.\n\nAcked-by: Eric Wong <normalperson@yhbt.net>\n\n> ---\n>  git-svn.perl                    |    2 +-\n>  t/t9112-git-svn-md5less-file.sh |   45 +++++++++++++++++++++++++++++++++++++++\n>  2 files changed, 46 insertions(+), 1 deletions(-)\n>  create mode 100755 t/t9112-git-svn-md5less-file.sh\n> \n> diff --git a/git-svn.perl b/git-svn.perl\n> index 3c4f490..b2773dc 100755\n> --- a/git-svn.perl\n> +++ b/git-svn.perl\n> @@ -2471,7 +2471,7 @@ sub close_file {\n>  \t\t$md5->addfile($fh);\n>  \t\tmy $got = $md5->hexdigest;\n>  \t\tdie \"Checksum mismatch: $path\\n\",\n> -\t\t    \"expected: $exp\\n    got: $got\\n\" if ($got ne $exp);\n> +\t\t    \"expected: $exp\\n    got: $got\\n\" if (defined $exp && $got ne $exp);\n>  \t\tsysseek($fh, 0, 0) or croak $!;\n>  \t\tif ($fb->{mode_b} == 120000) {\n>  \t\t\tsysread($fh, my $buf, 5) == 5 or croak $!;\n> diff --git a/t/t9112-git-svn-md5less-file.sh b/t/t9112-git-svn-md5less-file.sh\n> new file mode 100755\n> index 0000000..08313bb\n> --- /dev/null\n> +++ b/t/t9112-git-svn-md5less-file.sh\n> @@ -0,0 +1,45 @@\n> +test_description='test that git handles an svn repository with missing md5sums'\n> +\n> +. ./lib-git-svn.sh\n> +\n> +# Loading a node from a svn dumpfile without a Text-Content-Length\n> +# field causes svn to neglect to store or report an md5sum.  (it will\n> +# calculate one if you had put Text-Content-Length: 0).  This showed\n> +# up in a repository creted with cvs2svn.\n> +\n> +cat > dumpfile.svn <<EOF\n> +SVN-fs-dump-format-version: 1\n> +\n> +Revision-number: 1\n> +Prop-content-length: 98\n> +Content-length: 98\n> +\n> +K 7\n> +svn:log\n> +V 0\n> +\n> +K 10\n> +svn:author\n> +V 4\n> +test\n> +K 8\n> +svn:date\n> +V 27\n> +2007-05-06T12:37:01.153339Z\n> +PROPS-END\n> +\n> +Node-path: md5less-file\n> +Node-kind: file\n> +Node-action: add\n> +Prop-content-length: 10\n> +Content-length: 10\n> +\n> +PROPS-END\n> +\n> +EOF\n> +\n> +test_expect_success 'load svn dumpfile' \"svnadmin load $rawsvnrepo < dumpfile.svn\"\n> +\n> +test_expect_success 'initialize git-svn' \"git-svn init $svnrepo\"\n> +test_expect_success 'fetch revisions from svn' 'git-svn fetch'\n> +test_done\n> -- \n> 1.5.2.rc2.1.g7f0b\n> \n\n-- \nEric Wong\n"},{"id":"43407","messageId":"4659703B.8070101@gmail.com","threadId":"8290","inReplyTo":"1179981426176-git-send-email-foom@fuhm.net","subject":"Re: [PATCH] Fix git-svn to handle svn not reporting the md5sum of a file, and test.","fromName":"A Large Angry SCM","fromEmail":"gitzilla@gmail.com","sentAt":"2007-05-27T11:49:15Z","receivedAt":"2007-05-27T11:49:15Z","isPatch":true,"sender":{"key":"gitzilla@gmail.com","avatar":"https://gravatar.com/avatar/354625c442439908ff3dd99757dee330e29e9df7847472384faf7a00add247fb?d=mp&s=160"},"body":"James Y Knight wrote:\n> ---\n>  git-svn.perl                    |    2 +-\n>  t/t9112-git-svn-md5less-file.sh |   45 +++++++++++++++++++++++++++++++++++++++\n>  2 files changed, 46 insertions(+), 1 deletions(-)\n>  create mode 100755 t/t9112-git-svn-md5less-file.sh\n[...]\n\nThe new test fails here (Suse 9.3 fully patched) w/ the following:\n\n*** t9112-git-svn-md5less-file.sh ***\n*   ok 1: load svn dumpfile\n*   ok 2: initialize git-svn\n* FAIL 3: fetch revisions from svn\n         git-svn fetch\n* failed 1 among 3 test(s)\nmake[1]: *** [t9112-git-svn-md5less-file.sh] Error 1\n"},{"id":"43444","messageId":"20070527172351.GA27309@muzzle","threadId":"8290","inReplyTo":"4659703B.8070101@gmail.com","subject":"Re: [PATCH] Fix git-svn to handle svn not reporting the md5sum of a file, and test.","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2007-05-27T17:23:51Z","receivedAt":"2007-05-27T17:23:51Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"A Large Angry SCM <gitzilla@gmail.com> wrote:\n> James Y Knight wrote:\n> >---\n> > git-svn.perl                    |    2 +-\n> > t/t9112-git-svn-md5less-file.sh |   45 \n> > +++++++++++++++++++++++++++++++++++++++\n> > 2 files changed, 46 insertions(+), 1 deletions(-)\n> > create mode 100755 t/t9112-git-svn-md5less-file.sh\n> [...]\n> \n> The new test fails here (Suse 9.3 fully patched) w/ the following:\n> \n> *** t9112-git-svn-md5less-file.sh ***\n> *   ok 1: load svn dumpfile\n> *   ok 2: initialize git-svn\n> * FAIL 3: fetch revisions from svn\n>         git-svn fetch\n> * failed 1 among 3 test(s)\n> make[1]: *** [t9112-git-svn-md5less-file.sh] Error 1\n\nI can't reproduce it here (on Debian Etch, SVN 1.4.2).  Can you run with\nthe test with the -v switch?  Thanks.\n\n-- \nEric Wong\n"},{"id":"43447","messageId":"4659DBC8.2000105@gmail.com","threadId":"8290","inReplyTo":"20070527172351.GA27309@muzzle","subject":"Re: [PATCH] Fix git-svn to handle svn not reporting the md5sum of a file, and test.","fromName":"A Large Angry SCM","fromEmail":"gitzilla@gmail.com","sentAt":"2007-05-27T19:28:08Z","receivedAt":"2007-05-27T19:28:08Z","isPatch":true,"sender":{"key":"gitzilla@gmail.com","avatar":"https://gravatar.com/avatar/354625c442439908ff3dd99757dee330e29e9df7847472384faf7a00add247fb?d=mp&s=160"},"body":"Eric Wong wrote:\n > A Large Angry SCM <gitzilla@gmail.com> wrote:\n >> James Y Knight wrote:\n >>> ---\n >>> git-svn.perl                    |    2 +-\n >>> t/t9112-git-svn-md5less-file.sh |   45\n >>> +++++++++++++++++++++++++++++++++++++++\n >>> 2 files changed, 46 insertions(+), 1 deletions(-)\n >>> create mode 100755 t/t9112-git-svn-md5less-file.sh\n >> [...]\n >>\n >> The new test fails here (Suse 9.3 fully patched) w/ the following:\n >>\n >> *** t9112-git-svn-md5less-file.sh ***\n >> *   ok 1: load svn dumpfile\n >> *   ok 2: initialize git-svn\n >> * FAIL 3: fetch revisions from svn\n >>         git-svn fetch\n >> * failed 1 among 3 test(s)\n >> make[1]: *** [t9112-git-svn-md5less-file.sh] Error 1\n >\n > I can't reproduce it here (on Debian Etch, SVN 1.4.2).  Can you run with\n > the test with the -v switch?  Thanks.\n >\n\n\n~/GIT/git/t> sh ./t9112-git-svn-md5less-file.sh -v\n* expecting success: svnadmin load /home/test/GIT/git/t/trash/svnrepo < \ndumpfile.svn\n<<< Started new transaction, based on original revision 1\n      * adding path : md5less-file ... done.\n\n------- Committed revision 1 >>>\n\n*   ok 1: load svn dumpfile\n\n* expecting success: git-svn init file:///home/test/GIT/git/t/trash/svnrepo\n*   ok 2: initialize git-svn\n\n* expecting success: git-svn fetch\n./test-lib.sh: line 141:  8163 Segmentation fault      git-svn fetch\n* FAIL 3: fetch revisions from svn\n         git-svn fetch\n\n* failed 1 among 3 test(s)\n~/GIT/git/t>\n\n\nAnd here is the failing part of the test using sh -x:\n\n+ test_expect_success 'fetch revisions from svn' 'git-svn fetch'\n+ test 2 = 2\n+ test_skip 'fetch revisions from svn' 'git-svn fetch'\n++ expr ././t9112-git-svn-md5less-file.sh : '.*/\\(t[0-9]*\\)-[^/]*$'\n+ this_test=t9112\n++ expr 2 + 1\n+ this_test=t9112.3\n+ to_skip=\n+ case \"$to_skip\" in\n+ false\n+ say 'expecting success: git-svn fetch'\n+ echo '* expecting success: git-svn fetch'\n* expecting success: git-svn fetch\n+ test_run_ 'git-svn fetch'\n+ eval 'git-svn fetch'\n++ git-svn fetch\n./test-lib.sh: line 141:  8276 Segmentation fault      git-svn fetch\n+ eval_ret=139\n+ return 0\n+ '[' 0 = 0 -a 139 = 0 ']'\n+ test_failure_ 'fetch revisions from svn' 'git-svn fetch'\n++ expr 2 + 1\n+ test_count=3\n++ expr 0 + 1\n+ test_failure=1\n+ say 'FAIL 3: fetch revisions from svn'\n+ echo '* FAIL 3: fetch revisions from svn'\n* FAIL 3: fetch revisions from svn\n+ shift\n+ echo 'git-svn fetch'\n+ sed -e 's/^/  /'\n         git-svn fetch\n+ test '' = ''\n+ echo ''\n\nThis began after the 18bece4..99b5a79 update to master. Prior to that \nthe svn tests were passing.\n"},{"id":"43466","messageId":"20070527230402.GB27309@muzzle","threadId":"8290","inReplyTo":"4659DBC8.2000105@gmail.com","subject":"Re: [PATCH] Fix git-svn to handle svn not reporting the md5sum of a file, and test.","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2007-05-27T23:04:02Z","receivedAt":"2007-05-27T23:04:02Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"A Large Angry SCM <gitzilla@gmail.com> wrote:\n> Eric Wong wrote:\n> > A Large Angry SCM <gitzilla@gmail.com> wrote:\n> >> James Y Knight wrote:\n> >>> ---\n> >>> git-svn.perl                    |    2 +-\n> >>> t/t9112-git-svn-md5less-file.sh |   45\n> >>> +++++++++++++++++++++++++++++++++++++++\n> >>> 2 files changed, 46 insertions(+), 1 deletions(-)\n> >>> create mode 100755 t/t9112-git-svn-md5less-file.sh\n> >> [...]\n> >>\n> >> The new test fails here (Suse 9.3 fully patched) w/ the following:\n> >>\n> >> *** t9112-git-svn-md5less-file.sh ***\n> >> *   ok 1: load svn dumpfile\n> >> *   ok 2: initialize git-svn\n> >> * FAIL 3: fetch revisions from svn\n> >>         git-svn fetch\n> >> * failed 1 among 3 test(s)\n> >> make[1]: *** [t9112-git-svn-md5less-file.sh] Error 1\n> >\n> > I can't reproduce it here (on Debian Etch, SVN 1.4.2).  Can you run with\n> > the test with the -v switch?  Thanks.\n> >\n> \n> \n> ~/GIT/git/t> sh ./t9112-git-svn-md5less-file.sh -v\n> * expecting success: svnadmin load /home/test/GIT/git/t/trash/svnrepo < \n> dumpfile.svn\n> <<< Started new transaction, based on original revision 1\n>      * adding path : md5less-file ... done.\n> \n> ------- Committed revision 1 >>>\n> \n> *   ok 1: load svn dumpfile\n> \n> * expecting success: git-svn init file:///home/test/GIT/git/t/trash/svnrepo\n> *   ok 2: initialize git-svn\n> \n> * expecting success: git-svn fetch\n> ./test-lib.sh: line 141:  8163 Segmentation fault      git-svn fetch\n> * FAIL 3: fetch revisions from svn\n>         git-svn fetch\n> \n> * failed 1 among 3 test(s)\n> ~/GIT/git/t>\n> \n> \n> And here is the failing part of the test using sh -x:\n> \n> + test_expect_success 'fetch revisions from svn' 'git-svn fetch'\n> + test 2 = 2\n> + test_skip 'fetch revisions from svn' 'git-svn fetch'\n> ++ expr ././t9112-git-svn-md5less-file.sh : '.*/\\(t[0-9]*\\)-[^/]*$'\n> + this_test=t9112\n> ++ expr 2 + 1\n> + this_test=t9112.3\n> + to_skip=\n> + case \"$to_skip\" in\n> + false\n> + say 'expecting success: git-svn fetch'\n> + echo '* expecting success: git-svn fetch'\n> * expecting success: git-svn fetch\n> + test_run_ 'git-svn fetch'\n> + eval 'git-svn fetch'\n> ++ git-svn fetch\n> ./test-lib.sh: line 141:  8276 Segmentation fault      git-svn fetch\n> + eval_ret=139\n> + return 0\n> + '[' 0 = 0 -a 139 = 0 ']'\n> + test_failure_ 'fetch revisions from svn' 'git-svn fetch'\n> ++ expr 2 + 1\n> + test_count=3\n> ++ expr 0 + 1\n> + test_failure=1\n> + say 'FAIL 3: fetch revisions from svn'\n> + echo '* FAIL 3: fetch revisions from svn'\n> * FAIL 3: fetch revisions from svn\n> + shift\n> + echo 'git-svn fetch'\n> + sed -e 's/^/  /'\n>         git-svn fetch\n> + test '' = ''\n> + echo ''\n> \n> This began after the 18bece4..99b5a79 update to master. Prior to that \n> the svn tests were passing.\n\nThanks.\n\nI'm definitely not able to reproduce this here, and I'm sure Junio\nwouldn't have pushed out if he could, either...  Which versions of SVN\nand Perl (MD5) do you have?\n\nA backtrace with debugging symbols could be helpful if the below\nstab in the dark doesn't work out:\n\nMaybe there's an off chance that the MD5 implementation you're using\ncan't handle zero-sized files?\n\nJunio: can you apply the following patch regardless of whether or not it\nfixes this issue?  It just makes more sense, thanks.\n\n>From 3229470be27589a0428994475b0a597cc549cf78 Mon Sep 17 00:00:00 2001\nFrom: Eric Wong <normalperson@yhbt.net>\nDate: Sun, 27 May 2007 15:59:01 -0700\nSubject: [PATCH] git-svn: avoid md5 calculation entirely if SVN doesn't provide one\n\nThere's no point in calculating an MD5 if we're not going to use\nit.  We'll also avoid the possibility of there being a bug in the\nPerl MD5 library not being able to handle zero-sized files.\n\nThis is a followup to 20b3d206acbbb042c7ad5f42d36ff8d036a538c5,\nwhich allows us to track repositories that do not provide MD5\nchecksums.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n git-svn.perl |   16 ++++++++++------\n 1 files changed, 10 insertions(+), 6 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex eeaeb2d..58f7dd0 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -2472,12 +2472,16 @@ sub close_file {\n \tmy $hash;\n \tmy $path = $self->git_path($fb->{path});\n \tif (my $fh = $fb->{fh}) {\n-\t\tseek($fh, 0, 0) or croak $!;\n-\t\tmy $md5 = Digest::MD5->new;\n-\t\t$md5->addfile($fh);\n-\t\tmy $got = $md5->hexdigest;\n-\t\tdie \"Checksum mismatch: $path\\n\",\n-\t\t    \"expected: $exp\\n    got: $got\\n\" if (defined $exp && $got ne $exp);\n+\t\tif (defined $exp) {\n+\t\t\tseek($fh, 0, 0) or croak $!;\n+\t\t\tmy $md5 = Digest::MD5->new;\n+\t\t\t$md5->addfile($fh);\n+\t\t\tmy $got = $md5->hexdigest;\n+\t\t\tif ($got ne $exp) {\n+\t\t\t\tdie \"Checksum mismatch: $path\\n\",\n+\t\t\t\t    \"expected: $exp\\n    got: $got\\n\";\n+\t\t\t}\n+\t\t}\n \t\tsysseek($fh, 0, 0) or croak $!;\n \t\tif ($fb->{mode_b} == 120000) {\n \t\t\tsysread($fh, my $buf, 5) == 5 or croak $!;\n-- \nEric Wong\n"}]}