{"thread":{"id":"53722","subject":"[PATCH 04/14] t9100: make test work with SHA-256","startedAt":"2020-06-19T22:51:35Z","lastAt":"2020-08-05T19:24:39Z","messageCount":40,"participants":["brian m. carlson","Eric Wong","Andreas Schwab","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":14},"messages":[{"id":"400227","messageId":"20200619223947.947067-5-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200619223947.947067-1-sandals@crustytoothpaste.net","subject":"[PATCH 04/14] t9100: make test work with SHA-256","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-19T22:39:37Z","receivedAt":"2020-06-19T22:51:35Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Compute the relevant tree objects for SHA-256 and use those when\nappropriate instead of using the SHA-1 ones.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t9100-git-svn-basic.sh | 19 ++++++++++++++++---\n 1 file changed, 16 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh\nindex 2c309a57d9..9f2d19ecc4 100755\n--- a/t/t9100-git-svn-basic.sh\n+++ b/t/t9100-git-svn-basic.sh\n@@ -208,9 +208,10 @@ name='check imported tree checksums expected tree checksums'\n rm -f expected\n if test_have_prereq UTF8\n then\n-\techo tree dc68b14b733e4ec85b04ab6f712340edc5dc936e > expected\n+\techo tree dc68b14b733e4ec85b04ab6f712340edc5dc936e > expected.sha1\n+\techo tree b95b55b29d771f5eb73aa9b9d52d02fe11a2538c2feb0829f754ce20a91d98eb > expected.sha256\n fi\n-cat >> expected <<\\EOF\n+cat >> expected.sha1 <<\\EOF\n tree c3322890dcf74901f32d216f05c5044f670ce632\n tree d3ccd5035feafd17b030c5732e7808cc49122853\n tree d03e1630363d4881e68929d532746b20b0986b83\n@@ -220,8 +221,20 @@ tree 149d63cd5878155c846e8c55d7d8487de283f89e\n tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e\n tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4\n EOF\n+cat >> expected.sha256 <<\\EOF\n+tree 8d12756699d0b5b110514240a0ff141f6cbf8891fd69ab05e5594196fb437c9f\n+tree 8187168d33f7d4ccb8c1cc6e99532810aaccb47658f35d19b3803072d1128d7a\n+tree 74e535d85da8ee25eb23d7b506790c5ab3ccdb1ba0826bd57625ed44ef361650\n+tree 6fd7dd963e3cdca0cbd6368ed3cfcc8037cc154d2e7719d9d369a0952364fd95\n+tree 1fd6cec6aa95102d69266e20419bb62ec2a06372d614b9850ef23ff204103bb4\n+tree 6fd7dd963e3cdca0cbd6368ed3cfcc8037cc154d2e7719d9d369a0952364fd95\n+tree deb2b7ac79cd8ce6f52af6a5a0a08691e94ba74a2ed55966bb27dbec551730eb\n+tree 59e2e936761188476a7752034e8aa0a822b34050c8504b0dfd946407f4bc9215\n+EOF\n \n-test_expect_success POSIXPERM,SYMLINKS \"$name\" \"test_cmp expected a\"\n+test_expect_success POSIXPERM,SYMLINKS \"$name\" '\n+\ttest_cmp expected.$(test_oid algo) a\n+'\n \n test_expect_success 'exit if remote refs are ambigious' '\n         git config --add svn-remote.svn.fetch \\\n"},{"id":"400228","messageId":"20200619223947.947067-6-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200619223947.947067-1-sandals@crustytoothpaste.net","subject":"[PATCH 05/14] t9104: make hash size independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-19T22:39:38Z","receivedAt":"2020-06-19T22:51:37Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"The size of a record in the database used by git svn is four bytes plus\nthe length of the binary hash.  Instead of hard-coding 24, compute this\nvalue based on the size of the hash in use.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t9104-git-svn-follow-parent.sh | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh\nindex 5e0ad19177..67eed2fefc 100755\n--- a/t/t9104-git-svn-follow-parent.sh\n+++ b/t/t9104-git-svn-follow-parent.sh\n@@ -161,6 +161,7 @@ test_expect_success \"track initial change if it was only made to parent\" '\n \t'\n \n test_expect_success \"follow-parent is atomic\" '\n+\trecord_size=$(($(test_oid rawsz) + 4)) &&\n \t(\n \t\tcd wc &&\n \t\tsvn_cmd up &&\n@@ -186,7 +187,7 @@ test_expect_success \"follow-parent is atomic\" '\n \tmkdir -p \"$GIT_DIR\"/svn/refs/remotes/flunk@18 &&\n \trev_map=$(cd \"$GIT_DIR\"/svn/refs/remotes/stunk && ls .rev_map*) &&\n \tdd if=\"$GIT_DIR\"/svn/refs/remotes/stunk/$rev_map \\\n-\t   of=\"$GIT_DIR\"/svn/refs/remotes/flunk@18/$rev_map bs=24 count=1 &&\n+\t   of=\"$GIT_DIR\"/svn/refs/remotes/flunk@18/$rev_map bs=$record_size count=1 &&\n \trm -rf \"$GIT_DIR\"/svn/refs/remotes/stunk &&\n \tgit svn init --minimize-url -i flunk \"$svnrepo\"/flunk &&\n \tgit svn fetch -i flunk &&\n"},{"id":"400229","messageId":"20200619223947.947067-7-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200619223947.947067-1-sandals@crustytoothpaste.net","subject":"[PATCH 06/14] t9101: make hash independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-19T22:39:39Z","receivedAt":"2020-06-19T22:51:38Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Instead of hard-coding the object ID for our test .gitignore file, let's\ncompute it.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t9101-git-svn-props.sh | 12 +++++++-----\n 1 file changed, 7 insertions(+), 5 deletions(-)\n\ndiff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh\nindex c26c4b0927..8b5681dd68 100755\n--- a/t/t9101-git-svn-props.sh\n+++ b/t/t9101-git-svn-props.sh\n@@ -160,11 +160,13 @@ cat >create-ignore.expect <<\\EOF\n /no-such-file*\n EOF\n \n-cat >create-ignore-index.expect <<\\EOF\n-100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0\t.gitignore\n-100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0\tdeeply/.gitignore\n-100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0\tdeeply/nested/.gitignore\n-100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0\tdeeply/nested/directory/.gitignore\n+expectoid=$(git hash-object create-ignore.expect)\n+\n+cat >create-ignore-index.expect <<EOF\n+100644 $expectoid 0\t.gitignore\n+100644 $expectoid 0\tdeeply/.gitignore\n+100644 $expectoid 0\tdeeply/nested/.gitignore\n+100644 $expectoid 0\tdeeply/nested/directory/.gitignore\n EOF\n \n test_expect_success 'test create-ignore' \"\n"},{"id":"400230","messageId":"20200619223947.947067-10-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200619223947.947067-1-sandals@crustytoothpaste.net","subject":"[PATCH 09/14] perl: make Git::IndexInfo work with SHA-256","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-19T22:39:42Z","receivedAt":"2020-06-19T22:51:40Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Most of the Git modules, git-svn excepted, don't know anything about the\nhash algorithm and mostly work.  However, when we're printing an\nall-zero object ID in Git::IndexInfo, we need to know the hash length.\n\nSince we don't want to change the API to have that information passed\nin, let's query the config to find the hash algorithm and compute the\nright value.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n perl/Git/IndexInfo.pm | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/perl/Git/IndexInfo.pm b/perl/Git/IndexInfo.pm\nindex a43108c985..2a7b4908f3 100644\n--- a/perl/Git/IndexInfo.pm\n+++ b/perl/Git/IndexInfo.pm\n@@ -5,13 +5,15 @@ package Git::IndexInfo;\n \n sub new {\n \tmy ($class) = @_;\n+\tmy $hash_algo = Git::config('extensions.objectformat') || 'sha1';\n \tmy ($gui, $ctx) = command_input_pipe(qw/update-index -z --index-info/);\n-\tbless { gui => $gui, ctx => $ctx, nr => 0}, $class;\n+\tbless { gui => $gui, ctx => $ctx, nr => 0, hash_algo => $hash_algo}, $class;\n }\n \n sub remove {\n \tmy ($self, $path) = @_;\n-\tif (print { $self->{gui} } '0 ', 0 x 40, \"\\t\", $path, \"\\0\") {\n+\tmy $length = $self->{hash_algo} eq 'sha256' ? 64 : 40;\n+\tif (print { $self->{gui} } '0 ', 0 x $length, \"\\t\", $path, \"\\0\") {\n \t\treturn ++$self->{nr};\n \t}\n \tundef;\n"},{"id":"400231","messageId":"20200619223947.947067-8-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200619223947.947067-1-sandals@crustytoothpaste.net","subject":"[PATCH 07/14] t/lib-git-svn: make hash size independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-19T22:39:40Z","receivedAt":"2020-06-19T22:51:41Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"The record size used in the git svn storage is four bytes plus the\nlength of the binary hash.  Pass the hash length into our Perl\ninvocation and use it to compute the size of the records.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/lib-git-svn.sh | 25 +++++++++++++------------\n 1 file changed, 13 insertions(+), 12 deletions(-)\n\ndiff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh\nindex 7d248e6588..4780b45337 100644\n--- a/t/lib-git-svn.sh\n+++ b/t/lib-git-svn.sh\n@@ -78,29 +78,30 @@ maybe_start_httpd () {\n }\n \n convert_to_rev_db () {\n-\tperl -w -- - \"$@\" <<\\EOF\n-use strict;\n+\tperl -w -e \"use strict; my \\$oidlen = $(test_oid rawsz);\" -e '\n @ARGV == 2 or die \"usage: convert_to_rev_db <input> <output>\";\n-open my $wr, '+>', $ARGV[1] or die \"$!: couldn't open: $ARGV[1]\";\n-open my $rd, '<', $ARGV[0] or die \"$!: couldn't open: $ARGV[0]\";\n+my $record_size = $oidlen + 4;\n+my $hexlen = $oidlen * 2;\n+open my $wr, \"+>\", $ARGV[1] or die \"$!: couldn'\\''t open: $ARGV[1]\";\n+open my $rd, \"<\", $ARGV[0] or die \"$!: couldn'\\''t open: $ARGV[0]\";\n my $size = (stat($rd))[7];\n-($size % 24) == 0 or die \"Inconsistent size: $size\";\n-while (sysread($rd, my $buf, 24) == 24) {\n-\tmy ($r, $c) = unpack('NH40', $buf);\n-\tmy $offset = $r * 41;\n+($size % $record_size) == 0 or die \"Inconsistent size: $size\";\n+while (sysread($rd, my $buf, $record_size) == $record_size) {\n+\tmy ($r, $c) = unpack(\"NH$hexlen\", $buf);\n+\tmy $offset = $r * ($hexlen + 1);\n \tseek $wr, 0, 2 or die $!;\n \tmy $pos = tell $wr;\n \tif ($pos < $offset) {\n-\t\tfor (1 .. (($offset - $pos) / 41)) {\n-\t\t\tprint $wr (('0' x 40),\"\\n\") or die $!;\n+\t\tfor (1 .. (($offset - $pos) / ($hexlen + 1))) {\n+\t\t\tprint $wr (('0' x $hexlen),\"\\n\") or die $!;\n \t\t}\n \t}\n \tseek $wr, $offset, 0 or die $!;\n \tprint $wr $c,\"\\n\" or die $!;\n }\n close $wr or die $!;\n-close $rd or die $!;\n-EOF\n+close $rd or die $!;' \\\n+\t-- \"$@\"\n }\n \n require_svnserve () {\n"},{"id":"400232","messageId":"20200619223947.947067-14-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200619223947.947067-1-sandals@crustytoothpaste.net","subject":"[PATCH 13/14] git-cvsimport: port to SHA-256","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-19T22:39:46Z","receivedAt":"2020-06-19T22:51:42Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Instead of calling the function is_sha1, call it is_oid and update it to\nmatch either a SHA-1 or a SHA-256 hex object ID.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n git-cvsimport.perl | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex 1057f389d3..7bf3c12d67 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -637,9 +637,9 @@ ()\n \treturn $pwd;\n }\n \n-sub is_sha1 {\n+sub is_oid {\n \tmy $s = shift;\n-\treturn $s =~ /^[a-f0-9]{40}$/;\n+\treturn $s =~ /^[a-f0-9]{40}(?:[a-f0-9]{24})?$/;\n }\n \n sub get_headref ($) {\n@@ -810,7 +810,7 @@ ()\n \topen(my $fh, '-|', qw(git write-tree))\n \t\tor die \"unable to open git write-tree: $!\";\n \tchomp(my $tree = <$fh>);\n-\tis_sha1($tree)\n+\tis_oid($tree)\n \t\tor die \"Cannot get tree id ($tree): $!\";\n \tclose($fh)\n \t\tor die \"Error running git write-tree: $?\\n\";\n@@ -896,7 +896,7 @@ sub commit {\n \n \tprint \"Committed patch $patchset ($branch $commit_date)\\n\" if $opt_v;\n \tchomp(my $cid = <$commit_read>);\n-\tis_sha1($cid) or die \"Cannot get commit id ($cid): $!\\n\";\n+\tis_oid($cid) or die \"Cannot get commit id ($cid): $!\\n\";\n \tprint \"Commit ID $cid\\n\" if $opt_v;\n \tclose($commit_read);\n \n"},{"id":"400233","messageId":"20200619223947.947067-12-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200619223947.947067-1-sandals@crustytoothpaste.net","subject":"[PATCH 11/14] git-svn: set the OID length based on hash algorithm","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-19T22:39:44Z","receivedAt":"2020-06-19T22:51:43Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"When reading the configuration or when creating a new repository, load\nthe extensions.objectFormat value and set the object ID length to 64 if\nit's \"sha256\".  Note that we use the hex length in git-svn because most\nof our processing is done on hex values, not binary ones.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n git-svn.perl | 7 +++++++\n 1 file changed, 7 insertions(+)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 00276c051b..58f5a7ac8f 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -500,6 +500,7 @@ sub do_git_init_db {\n \t\tcommand_noisy('config', \"$pfx.preserve-empty-dirs\", 'true');\n \t\tcommand_noisy('config', \"$pfx.placeholder-filename\", $$fname);\n \t}\n+\tload_object_format();\n }\n \n sub init_subdir {\n@@ -1977,9 +1978,15 @@ sub read_git_config {\n \t\t\t}\n \t\t}\n \t}\n+\tload_object_format();\n \tdelete @$opts{@config_only} if @config_only;\n }\n \n+sub load_object_format {\n+\tchomp(my $hash = `git config --get extensions.objectformat`);\n+\t$::oid_length = 64 if $hash eq 'sha256';\n+}\n+\n sub extract_metadata {\n \tmy $id = shift or return (undef, undef, undef);\n \tmy ($url, $rev, $uuid) = ($id =~ /^\\s*git-svn-id:\\s+(.*)\\@(\\d+)\n"},{"id":"400234","messageId":"20200619223947.947067-15-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200619223947.947067-1-sandals@crustytoothpaste.net","subject":"[PATCH 14/14] git-cvsexportcommit: port to SHA-256","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-19T22:39:47Z","receivedAt":"2020-06-19T22:51:45Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"When we apply a binary patch, we must have the full object ID in the\nheader in order to apply it; without that, any attempt to apply it will\nfail.  If we set GIT_DIR to empty, git apply does not know about the\nhash algorithm we're using, and consequently any attempt to apply a\npatch using SHA-256 will fail, since the object ID is the wrong length.\n\nThe reason we set the GIT_DIR environment variable is because we don't\nwant to modify the index; we just want to know whether the patch\napplies.  Instead, let's just use a temporary file for the index, which\nwill be cleaned up automatically when the object goes out of scope.\n\nAdditionally, read the configuration for the repository and compute the\nlength of an object ID based on it.  Use that when matching object IDs\nwith a regex or computing the all-zeros object ID.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n git-cvsexportcommit.perl | 14 +++++++++-----\n 1 file changed, 9 insertions(+), 5 deletions(-)\n\ndiff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl\nindex fc00d5946a..6483d792d3 100755\n--- a/git-cvsexportcommit.perl\n+++ b/git-cvsexportcommit.perl\n@@ -22,6 +22,10 @@\n my $repo = Git->repository();\n $opt_w = $repo->config('cvsexportcommit.cvsdir') unless defined $opt_w;\n \n+my $tmpdir = File::Temp->newdir;\n+my $hash_algo = $repo->config('extensions.objectformat') || 'sha1';\n+my $hexsz = $hash_algo eq 'sha256' ? 64 : 40;\n+\n if ($opt_w || $opt_W) {\n \t# Remember where GIT_DIR is before changing to CVS checkout\n \tunless ($ENV{GIT_DIR}) {\n@@ -96,7 +100,7 @@\n     }\n \n     if ($stage eq 'headers') {\n-\tif ($line =~ m/^parent (\\w{40})$/) { # found a parent\n+\tif ($line =~ m/^parent ([0-9a-f]{$hexsz})$/) { # found a parent\n \t    push @parents, $1;\n \t} elsif ($line =~ m/^author (.+) \\d+ [-+]\\d+$/) {\n \t    $author = $1;\n@@ -111,7 +115,7 @@\n     }\n }\n \n-my $noparent = \"0000000000000000000000000000000000000000\";\n+my $noparent = \"0\" x $hexsz;\n if ($parent) {\n     my $found;\n     # double check that it's a valid parent\n@@ -174,7 +178,7 @@\n print \"Checking if patch will apply\\n\";\n \n my @stat;\n-open APPLY, \"GIT_DIR= git-apply $context --summary --numstat<.cvsexportcommit.diff|\" || die \"cannot patch\";\n+open APPLY, \"GIT_INDEX_FILE=$tmpdir/index git-apply $context --summary --numstat<.cvsexportcommit.diff|\" || die \"cannot patch\";\n @stat=<APPLY>;\n close APPLY || die \"Cannot patch\";\n my (@bfiles,@files,@afiles,@dfiles);\n@@ -329,7 +333,7 @@\n if ($opt_W) {\n     system(\"git checkout -q $commit^0\") && die \"cannot patch\";\n } else {\n-    `GIT_DIR= git-apply $context --summary --numstat --apply <.cvsexportcommit.diff` || die \"cannot patch\";\n+    `GIT_INDEX_FILE=$tmpdir/index git-apply $context --summary --numstat --apply <.cvsexportcommit.diff` || die \"cannot patch\";\n }\n \n print \"Patch applied successfully. Adding new files and directories to CVS\\n\";\n@@ -407,7 +411,7 @@\n \n if ($opt_W) {\n     system(\"git checkout $go_back_to\") && die \"cannot move back to $go_back_to\";\n-    if (!($go_back_to =~ /^[0-9a-fA-F]{40}$/)) {\n+    if (!($go_back_to =~ /^[0-9a-fA-F]{$hexsz}$/)) {\n \tsystem(\"git symbolic-ref HEAD $go_back_to\") &&\n \t    die \"cannot move back to $go_back_to\";\n     }\n"},{"id":"400235","messageId":"20200619223947.947067-13-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200619223947.947067-1-sandals@crustytoothpaste.net","subject":"[PATCH 12/14] git-cvsserver: port to SHA-256","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-19T22:39:45Z","receivedAt":"2020-06-19T22:51:46Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"The code of git-cvsserver currently has several hard-coded 20 and 40\nconstants that are the length of SHA-1.  When parsing the configuration\nfile, read the extensions.objectformat configuration setting as well as\nCVS-related ones and adjust the hash sizes accordingly.  Use these\ncomputed values in all the places we match object IDs.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n git-cvsserver.perl | 37 ++++++++++++++++++++-----------------\n 1 file changed, 20 insertions(+), 17 deletions(-)\n\ndiff --git a/git-cvsserver.perl b/git-cvsserver.perl\nindex ae1044273d..f6f3fc192c 100755\n--- a/git-cvsserver.perl\n+++ b/git-cvsserver.perl\n@@ -365,7 +365,7 @@ sub req_Root\n     }\n     foreach my $line ( @gitvars )\n     {\n-        next unless ( $line =~ /^(gitcvs)\\.(?:(ext|pserver)\\.)?([\\w-]+)=(.*)$/ );\n+        next unless ( $line =~ /^(gitcvs|extensions)\\.(?:(ext|pserver)\\.)?([\\w-]+)=(.*)$/ );\n         unless ($2) {\n             $cfg->{$1}{$3} = $4;\n         } else {\n@@ -392,6 +392,9 @@ sub req_Root\n         $log->nofile();\n     }\n \n+    $state->{rawsz} = ($cfg->{'extensions'}{'objectformat'} || 'sha1') eq 'sha256' ? 32 : 20;\n+    $state->{hexsz} = $state->{rawsz} * 2;\n+\n     return 1;\n }\n \n@@ -1581,7 +1584,7 @@ sub req_ci\n \n             $parenthash = safe_pipe_capture('git', 'show-ref', '-s', $branchRef);\n             chomp $parenthash;\n-            if ($parenthash !~ /^[0-9a-f]{40}$/)\n+            if ($parenthash !~ /^[0-9a-f]{$state->{hexsz}}$/)\n             {\n                 if ( defined($stickyInfo) && defined($stickyInfo->{tag}) )\n                 {\n@@ -1708,7 +1711,7 @@ sub req_ci\n     chomp($commithash);\n     $log->info(\"Commit hash : $commithash\");\n \n-    unless ( $commithash =~ /[a-zA-Z0-9]{40}/ )\n+    unless ( $commithash =~ /[a-zA-Z0-9]{$state->{hexsz}}/ )\n     {\n         $log->warn(\"Commit failed (Invalid commit hash)\");\n         print \"error 1 Commit failed (unknown reason)\\n\";\n@@ -2375,7 +2378,7 @@ sub req_annotate\n         print \"E ***************\\n\";\n         while ( <ANNOTATE> )\n         {\n-            if (m/^([a-zA-Z0-9]{40})\\t\\([^\\)]*\\)(.*)$/i)\n+            if (m/^([a-zA-Z0-9]{$state->{hexsz}})\\t\\([^\\)]*\\)(.*)$/i)\n             {\n                 my $commithash = $1;\n                 my $data = $2;\n@@ -2852,7 +2855,7 @@ sub transmitfile\n         return;\n     }\n \n-    die \"Need filehash\" unless ( defined ( $filehash ) and $filehash =~ /^[a-zA-Z0-9]{40}$/ );\n+    die \"Need filehash\" unless ( defined ( $filehash ) and $filehash =~ /^[a-zA-Z0-9]{$state->{hexsz}}$/ );\n \n     my $type = safe_pipe_capture('git', 'cat-file', '-t', $filehash);\n     chomp $type;\n@@ -3042,7 +3045,7 @@ sub ensureWorkTree\n \n     my $ver = safe_pipe_capture('git', 'show-ref', '-s', \"refs/heads/$state->{module}\");\n     chomp $ver;\n-    if ($ver !~ /^[0-9a-f]{40}$/)\n+    if ($ver !~ /^[0-9a-f]{$state->{hexsz}}$/)\n     {\n         $log->warn(\"Error from git show-ref -s refs/head$state->{module}\");\n         print \"error 1 cannot find the current HEAD of module\";\n@@ -3281,7 +3284,7 @@ sub open_blob_or_die\n     }\n     elsif( $srcType eq \"sha1\" )\n     {\n-        unless ( defined ( $name ) and $name =~ /^[a-zA-Z0-9]{40}$/ )\n+        unless ( defined ( $name ) and $name =~ /^[a-zA-Z0-9]{$state->{hexsz}}$/ )\n         {\n             $log->warn(\"Need filehash\");\n             die \"Need filehash\\n\";\n@@ -3817,7 +3820,7 @@ sub update\n     chomp $commitsha1;\n \n     my $commitinfo = ::safe_pipe_capture('git', 'cat-file', 'commit', $self->{module});\n-    unless ( $commitinfo =~ /tree\\s+[a-zA-Z0-9]{40}/ )\n+    unless ( $commitinfo =~ /tree\\s+[a-zA-Z0-9]{$state->{hexsz}}/ )\n     {\n         die(\"Invalid module '$self->{module}'\");\n     }\n@@ -3957,7 +3960,7 @@ sub update\n             while ( <FILELIST> )\n             {\n \t\tchomp;\n-                unless ( /^:\\d{6}\\s+([0-7]{6})\\s+[a-f0-9]{40}\\s+([a-f0-9]{40})\\s+(\\w)$/o )\n+                unless ( /^:\\d{6}\\s+([0-7]{6})\\s+[a-f0-9]{$state->{hexsz}}\\s+([a-f0-9]{$state->{hexsz}})\\s+(\\w)$/o )\n                 {\n                     die(\"Couldn't process git-diff-tree line : $_\");\n                 }\n@@ -4625,11 +4628,11 @@ sub getmeta\n             $db_query->execute($filename, $intRev);\n             $meta = $db_query->fetchrow_hashref;\n         }\n-        elsif ( $revision =~ /^2\\.1\\.1\\.2000(\\.[1-3][0-9][0-9]){20}$/ )\n+        elsif ( $revision =~ /^2\\.1\\.1\\.2000(\\.[1-3][0-9][0-9]){$state->{rawsz}}$/ )\n         {\n             my ($commitHash)=($revision=~/^2\\.1\\.1\\.2000(.*)$/);\n             $commitHash=~s/\\.([0-9]+)/sprintf(\"%02x\",$1-100)/eg;\n-            if($commitHash=~/^[0-9a-f]{40}$/)\n+            if($commitHash=~/^[0-9a-f]{$state->{hexsz}}$/)\n             {\n                 return $self->getMetaFromCommithash($filename,$commitHash);\n             }\n@@ -4639,7 +4642,7 @@ sub getmeta\n             $log->warning(\"failed get $revision with commithash=$commitHash\");\n             undef $revision;\n         }\n-        elsif ( $revision =~ /^[0-9a-f]{40}$/ )\n+        elsif ( $revision =~ /^[0-9a-f]{$state->{hexsz}}$/ )\n         {\n             # Try DB first.  This is mostly only useful for req_annotate(),\n             # which only calls this for stuff that should already be in\n@@ -4658,7 +4661,7 @@ sub getmeta\n             if(! $meta)\n             {\n                 my($revCommit)=$self->lookupCommitRef($revision);\n-                if($revCommit=~/^[0-9a-f]{40}$/)\n+                if($revCommit=~/^[0-9a-f]{$state->{hexsz}}$/)\n                 {\n                     return $self->getMetaFromCommithash($filename,$revCommit);\n                 }\n@@ -4672,7 +4675,7 @@ sub getmeta\n         else\n         {\n             my($revCommit)=$self->lookupCommitRef($revision);\n-            if($revCommit=~/^[0-9a-f]{40}$/)\n+            if($revCommit=~/^[0-9a-f]{$state->{hexsz}}$/)\n             {\n                 return $self->getMetaFromCommithash($filename,$revCommit);\n             }\n@@ -4767,7 +4770,7 @@ sub getMetaFromCommithash\n \n     my($fileHash) = ::safe_pipe_capture(\"git\",\"rev-parse\",\"$revCommit:$filename\");\n     chomp $fileHash;\n-    if(!($fileHash=~/^[0-9a-f]{40}$/))\n+    if(!($fileHash=~/^[0-9a-f]{$state->{hexsz}}$/))\n     {\n         die \"Invalid fileHash '$fileHash' looking up\"\n                     .\" '$revCommit:$filename'\\n\";\n@@ -4863,7 +4866,7 @@ sub lookupCommitRef\n     $commitHash = ::safe_pipe_capture(\"git\",\"rev-parse\",\"--verify\",\"--quiet\",\n \t\t\t\t      $self->unescapeRefName($ref));\n     $commitHash=~s/\\s*$//;\n-    if(!($commitHash=~/^[0-9a-f]{40}$/))\n+    if(!($commitHash=~/^[0-9a-f]{$state->{hexsz}}$/))\n     {\n         $commitHash=undef;\n     }\n@@ -4909,7 +4912,7 @@ sub commitmessage\n     my $commithash = shift;\n     my $tablename = $self->tablename(\"commitmsgs\");\n \n-    die(\"Need commithash\") unless ( defined($commithash) and $commithash =~ /^[a-zA-Z0-9]{40}$/ );\n+    die(\"Need commithash\") unless ( defined($commithash) and $commithash =~ /^[a-zA-Z0-9]{$state->{hexsz}}$/ );\n \n     my $db_query;\n     $db_query = $self->{dbh}->prepare_cached(\"SELECT value FROM $tablename WHERE key=?\",{},1);\n"},{"id":"400236","messageId":"20200619223947.947067-2-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200619223947.947067-1-sandals@crustytoothpaste.net","subject":"[PATCH 01/14] t9109: make test hash independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-19T22:39:34Z","receivedAt":"2020-06-19T22:52:04Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Instead of stripping off the first 41 characters of git log output,\nlet's just strip off the first space-separated component, which will\nwork for any size hash.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t9109-git-svn-multi-glob.sh | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t9109-git-svn-multi-glob.sh b/t/t9109-git-svn-multi-glob.sh\nindex c1e7542a37..648dcee1ea 100755\n--- a/t/t9109-git-svn-multi-glob.sh\n+++ b/t/t9109-git-svn-multi-glob.sh\n@@ -48,7 +48,7 @@ test_expect_success 'test refspec globbing' '\n \t                 \"tags/*/src/a:refs/remotes/tags/*\" &&\n \tgit svn multi-fetch &&\n \tgit log --pretty=oneline refs/remotes/tags/end >actual &&\n-\tsed -e \"s/^.\\{41\\}//\" actual >output.end &&\n+\tcut -d\" \" -f2- actual >output.end &&\n \ttest_cmp expect.end output.end &&\n \ttest \"$(git rev-parse refs/remotes/tags/end~1)\" = \\\n \t\t\"$(git rev-parse refs/remotes/branches/v1/start)\" &&\n@@ -84,7 +84,7 @@ test_expect_success 'test left-hand-side only globbing' '\n \ttest $(git rev-parse refs/remotes/two/tags/end~3) = \\\n \t     $(git rev-parse refs/remotes/two/branches/v1/start) &&\n \tgit log --pretty=oneline refs/remotes/two/tags/end >actual &&\n-\tsed -e \"s/^.\\{41\\}//\" actual >output.two &&\n+\tcut -d\" \" -f2- actual >output.two &&\n \ttest_cmp expect.two output.two\n \t'\n cat > expect.four <<EOF\n@@ -135,7 +135,7 @@ test_expect_success 'test another branch' '\n \ttest $(git rev-parse refs/remotes/four/tags/next~2) = \\\n \t     $(git rev-parse refs/remotes/four/branches/v2/start) &&\n \tgit log --pretty=oneline refs/remotes/four/tags/next >actual &&\n-\tsed -e \"s/^.\\{41\\}//\" actual >output.four &&\n+\tcut -d\" \" -f2- actual >output.four &&\n \ttest_cmp expect.four output.four\n \t'\n \n"},{"id":"400237","messageId":"20200619223947.947067-1-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":null,"subject":"[PATCH 00/14] SHA-256 CVS and SVN patches","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-19T22:39:33Z","receivedAt":"2020-06-19T22:52:04Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"I recently sent out part 2/3 of the SHA-256 work and then I realized\nthat I hadn't built with the CVS and SVN adapters.  So this is part\n2.5/3 (or, to be pedantic, 3/4).\n\nThe patches are ordered roughly with test-only fixes, then SVN, and then\nCVS.  There are no additional tests here because everything fails with\nSHA-256 before and passes afterwards.\n\nbrian m. carlson (14):\n  t9109: make test hash independent\n  t9168: make test hash independent\n  t9108: make test hash independent\n  t9100: make test work with SHA-256\n  t9104: make hash size independent\n  t9101: make hash independent\n  t/lib-git-svn: make hash size independent\n  perl: create and switch variables for hash constants\n  perl: make Git::IndexInfo work with SHA-256\n  perl: make SVN code hash independent\n  git-svn: set the OID length based on hash algorithm\n  git-cvsserver: port to SHA-256\n  git-cvsimport: port to SHA-256\n  git-cvsexportcommit: port to SHA-256\n\n git-cvsexportcommit.perl                   | 14 ++--\n git-cvsimport.perl                         |  8 +--\n git-cvsserver.perl                         | 37 +++++-----\n git-svn.perl                               | 25 ++++---\n perl/Git/IndexInfo.pm                      |  6 +-\n perl/Git/SVN.pm                            | 83 +++++++++++-----------\n perl/Git/SVN/Editor.pm                     |  8 +--\n perl/Git/SVN/Fetcher.pm                    |  6 +-\n perl/Git/SVN/Log.pm                        |  2 +-\n perl/Git/SVN/Ra.pm                         |  4 +-\n t/lib-git-svn.sh                           | 25 +++----\n t/t9100-git-svn-basic.sh                   | 19 ++++-\n t/t9101-git-svn-props.sh                   | 12 ++--\n t/t9104-git-svn-follow-parent.sh           |  3 +-\n t/t9108-git-svn-glob.sh                    |  4 +-\n t/t9109-git-svn-multi-glob.sh              |  6 +-\n t/t9168-git-svn-partially-globbed-names.sh |  8 +--\n 17 files changed, 154 insertions(+), 116 deletions(-)\n\n"},{"id":"400238","messageId":"20200619223947.947067-4-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200619223947.947067-1-sandals@crustytoothpaste.net","subject":"[PATCH 03/14] t9108: make test hash independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-19T22:39:36Z","receivedAt":"2020-06-19T22:52:06Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Instead of stripping off the first 41 characters of git log output,\nlet's just strip off the first space-separated component, which will\nwork for any size hash.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t9108-git-svn-glob.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t9108-git-svn-glob.sh b/t/t9108-git-svn-glob.sh\nindex 6990f64364..d5939d4753 100755\n--- a/t/t9108-git-svn-glob.sh\n+++ b/t/t9108-git-svn-glob.sh\n@@ -48,7 +48,7 @@ test_expect_success 'test refspec globbing' '\n \t                 \"tags/*/src/a:refs/remotes/tags/*\" &&\n \tgit svn multi-fetch &&\n \tgit log --pretty=oneline refs/remotes/tags/end >actual &&\n-\tsed -e \"s/^.\\{41\\}//\" actual >output.end &&\n+\tcut -d\" \" -f2- actual >output.end &&\n \ttest_cmp expect.end output.end &&\n \ttest \"$(git rev-parse refs/remotes/tags/end~1)\" = \\\n \t\t\"$(git rev-parse refs/remotes/branches/start)\" &&\n@@ -84,7 +84,7 @@ test_expect_success 'test left-hand-side only globbing' '\n \ttest $(git rev-parse refs/remotes/two/tags/end~3) = \\\n \t     $(git rev-parse refs/remotes/two/branches/start) &&\n \tgit log --pretty=oneline refs/remotes/two/tags/end >actual &&\n-\tsed -e \"s/^.\\{41\\}//\" actual >output.two &&\n+\tcut -d\" \" -f2- actual >output.two &&\n \ttest_cmp expect.two output.two\n \t'\n \n"},{"id":"400239","messageId":"20200619223947.947067-3-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200619223947.947067-1-sandals@crustytoothpaste.net","subject":"[PATCH 02/14] t9168: make test hash independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-19T22:39:35Z","receivedAt":"2020-06-19T22:52:07Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Instead of stripping off the first 41 characters of git log output,\nlet's just strip off the first space-separated component, which will\nwork for any size hash.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t9168-git-svn-partially-globbed-names.sh | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/t/t9168-git-svn-partially-globbed-names.sh b/t/t9168-git-svn-partially-globbed-names.sh\nindex bdf6e84999..854b3419b2 100755\n--- a/t/t9168-git-svn-partially-globbed-names.sh\n+++ b/t/t9168-git-svn-partially-globbed-names.sh\n@@ -49,7 +49,7 @@ test_expect_success 'test refspec prefixed globbing' '\n \t\t\t \"tags/t_*/src/a:refs/remotes/tags/t_*\" &&\n \tgit svn multi-fetch &&\n \tgit log --pretty=oneline refs/remotes/tags/t_end >actual &&\n-\tsed -e \"s/^.\\{41\\}//\" actual >output.end &&\n+\tcut -d\" \" -f2- actual >output.end &&\n \ttest_cmp expect.end output.end &&\n \ttest \"$(git rev-parse refs/remotes/tags/t_end~1)\" = \\\n \t\t\"$(git rev-parse refs/remotes/branches/b_start)\" &&\n@@ -87,7 +87,7 @@ test_expect_success 'test left-hand-side only prefixed globbing' '\n \ttest $(git rev-parse refs/remotes/two/tags/t_end~3) = \\\n \t     $(git rev-parse refs/remotes/two/branches/b_start) &&\n \tgit log --pretty=oneline refs/remotes/two/tags/t_end >actual &&\n-\tsed -e \"s/^.\\{41\\}//\" actual >output.two &&\n+\tcut -d\" \" -f2- actual >output.two &&\n \ttest_cmp expect.two output.two\n \t'\n \n@@ -129,7 +129,7 @@ test_expect_success 'test prefixed globs match just prefix' '\n \ttest $(git rev-parse refs/remotes/three/tags/t_~1) = \\\n \t     $(git rev-parse refs/remotes/three/branches/b_) &&\n \tgit log --pretty=oneline refs/remotes/three/tags/t_ >actual &&\n-\tsed -e \"s/^.\\{41\\}//\" actual >output.three &&\n+\tcut -d\" \" -f2- actual >output.three &&\n \ttest_cmp expect.three output.three\n \t'\n \n@@ -199,7 +199,7 @@ test_expect_success 'test globbing in the middle of the word' '\n \ttest $(git rev-parse refs/remotes/five/tags/fghij~1) = \\\n \t     $(git rev-parse refs/remotes/five/branches/abcde) &&\n \tgit log --pretty=oneline refs/remotes/five/tags/fghij >actual &&\n-\tsed -e \"s/^.\\{41\\}//\" actual >output.five &&\n+\tcut -d\" \" -f2- actual >output.five &&\n \ttest_cmp expect.five output.five\n \t'\n \n"},{"id":"400240","messageId":"20200619223947.947067-11-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200619223947.947067-1-sandals@crustytoothpaste.net","subject":"[PATCH 10/14] perl: make SVN code hash independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-19T22:39:43Z","receivedAt":"2020-06-19T22:52:11Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"There are several places throughout git-svn that use various hard-coded\nconstants.  For matching object IDs, use the $oid variable.  Compute the\nrecord size we use for our revision storage based on the object ID.\n\nWhen parsing the revision map format, use a wildcard in the pack format\nsince we know that the data we're parsing is always exactly the record\nsize.  This lets us continue to use a constant for the pack format.\n\nFinally, update several comments to reflect the fact that an object ID\nmay be of one of multiple sizes.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n git-svn.perl            |  4 +--\n perl/Git/SVN.pm         | 73 +++++++++++++++++++++--------------------\n perl/Git/SVN/Editor.pm  |  6 ++--\n perl/Git/SVN/Fetcher.pm |  6 ++--\n perl/Git/SVN/Ra.pm      |  4 +--\n 5 files changed, 48 insertions(+), 45 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 7c735cebd3..00276c051b 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -2008,10 +2008,10 @@ sub cmt_sha2rev_batch {\n \t\tprint $out $sha, \"\\n\";\n \n \t\twhile (my $line = <$in>) {\n-\t\t\tif ($first && $line =~ /^[[:xdigit:]]{40}\\smissing$/) {\n+\t\t\tif ($first && $line =~ /^$::oid\\smissing$/) {\n \t\t\t\tlast;\n \t\t\t} elsif ($first &&\n-\t\t\t       $line =~ /^[[:xdigit:]]{40}\\scommit\\s(\\d+)$/) {\n+\t\t\t       $line =~ /^$::oid\\scommit\\s(\\d+)$/) {\n \t\t\t\t$first = 0;\n \t\t\t\t$size = $1;\n \t\t\t\tnext;\ndiff --git a/perl/Git/SVN.pm b/perl/Git/SVN.pm\nindex fcf1e3bb5e..d1c352f92b 100644\n--- a/perl/Git/SVN.pm\n+++ b/perl/Git/SVN.pm\n@@ -2,7 +2,7 @@ package Git::SVN;\n use strict;\n use warnings;\n use Fcntl qw/:DEFAULT :seek/;\n-use constant rev_map_fmt => 'NH40';\n+use constant rev_map_fmt => 'NH*';\n use vars qw/$_no_metadata\n             $_repack $_repack_flags $_use_svm_props $_head\n             $_use_svnsync_props $no_reuse_existing\n@@ -2087,10 +2087,10 @@ sub rebuild_from_rev_db {\n \topen my $fh, '<', $path or croak \"open: $!\";\n \tbinmode $fh or croak \"binmode: $!\";\n \twhile (<$fh>) {\n-\t\tlength($_) == 41 or croak \"inconsistent size in ($_) != 41\";\n+\t\tlength($_) == $::oid_length + 1 or croak \"inconsistent size in ($_)\";\n \t\tchomp($_);\n \t\t++$r;\n-\t\tnext if $_ eq ('0' x 40);\n+\t\tnext if $_ eq ('0' x $::oid_length);\n \t\t$self->rev_map_set($r, $_);\n \t\tprint \"r$r = $_\\n\";\n \t}\n@@ -2196,9 +2196,9 @@ sub rebuild {\n # (mainly tags)\n #\n # The format is this:\n-#   - 24 bytes for every record,\n+#   - 24 or 36 bytes for every record,\n #     * 4 bytes for the integer representing an SVN revision number\n-#     * 20 bytes representing the sha1 of a git commit\n+#     * 20 or 32 bytes representing the oid of a git commit\n #   - No empty padding records like the old format\n #     (except the last record, which can be overwritten)\n #   - new records are written append-only since SVN revision numbers\n@@ -2207,7 +2207,7 @@ sub rebuild {\n #   - Piping the file to xxd -c24 is a good way of dumping it for\n #     viewing or editing (piped back through xxd -r), should the need\n #     ever arise.\n-#   - The last record can be padding revision with an all-zero sha1\n+#   - The last record can be padding revision with an all-zero oid\n #     This is used to optimize fetch performance when using multiple\n #     \"fetch\" directives in .git/config\n #\n@@ -2215,38 +2215,39 @@ sub rebuild {\n \n sub _rev_map_set {\n \tmy ($fh, $rev, $commit) = @_;\n+\tmy $record_size = ($::oid_length / 2) + 4;\n \n \tbinmode $fh or croak \"binmode: $!\";\n \tmy $size = (stat($fh))[7];\n-\t($size % 24) == 0 or croak \"inconsistent size: $size\";\n+\t($size % $record_size) == 0 or croak \"inconsistent size: $size\";\n \n \tmy $wr_offset = 0;\n \tif ($size > 0) {\n-\t\tsysseek($fh, -24, SEEK_END) or croak \"seek: $!\";\n-\t\tmy $read = sysread($fh, my $buf, 24) or croak \"read: $!\";\n-\t\t$read == 24 or croak \"read only $read bytes (!= 24)\";\n+\t\tsysseek($fh, -$record_size, SEEK_END) or croak \"seek: $!\";\n+\t\tmy $read = sysread($fh, my $buf, $record_size) or croak \"read: $!\";\n+\t\t$read == $record_size or croak \"read only $read bytes (!= $record_size)\";\n \t\tmy ($last_rev, $last_commit) = unpack(rev_map_fmt, $buf);\n-\t\tif ($last_commit eq ('0' x40)) {\n-\t\t\tif ($size >= 48) {\n-\t\t\t\tsysseek($fh, -48, SEEK_END) or croak \"seek: $!\";\n-\t\t\t\t$read = sysread($fh, $buf, 24) or\n+\t\tif ($last_commit eq ('0' x $::oid_length)) {\n+\t\t\tif ($size >= ($record_size * 2)) {\n+\t\t\t\tsysseek($fh, -($record_size * 2), SEEK_END) or croak \"seek: $!\";\n+\t\t\t\t$read = sysread($fh, $buf, $record_size) or\n \t\t\t\t    croak \"read: $!\";\n-\t\t\t\t$read == 24 or\n-\t\t\t\t    croak \"read only $read bytes (!= 24)\";\n+\t\t\t\t$read == $record_size or\n+\t\t\t\t    croak \"read only $read bytes (!= $record_size)\";\n \t\t\t\t($last_rev, $last_commit) =\n \t\t\t\t    unpack(rev_map_fmt, $buf);\n-\t\t\t\tif ($last_commit eq ('0' x40)) {\n+\t\t\t\tif ($last_commit eq ('0' x $::oid_length)) {\n \t\t\t\t\tcroak \"inconsistent .rev_map\\n\";\n \t\t\t\t}\n \t\t\t}\n \t\t\tif ($last_rev >= $rev) {\n \t\t\t\tcroak \"last_rev is higher!: $last_rev >= $rev\";\n \t\t\t}\n-\t\t\t$wr_offset = -24;\n+\t\t\t$wr_offset = -$record_size;\n \t\t}\n \t}\n \tsysseek($fh, $wr_offset, SEEK_END) or croak \"seek: $!\";\n-\tsyswrite($fh, pack(rev_map_fmt, $rev, $commit), 24) == 24 or\n+\tsyswrite($fh, pack(rev_map_fmt, $rev, $commit), $record_size) == $record_size or\n \t  croak \"write: $!\";\n }\n \n@@ -2271,7 +2272,7 @@ sub mkfile {\n sub rev_map_set {\n \tmy ($self, $rev, $commit, $update_ref, $uuid) = @_;\n \tdefined $commit or die \"missing arg3\\n\";\n-\tlength $commit == 40 or die \"arg3 must be a full SHA1 hexsum\\n\";\n+\t$commit =~ /^$::oid$/ or die \"arg3 must be a full hex object ID\\n\";\n \tmy $db = $self->map_path($uuid);\n \tmy $db_lock = \"$db.lock\";\n \tmy $sigmask;\n@@ -2344,29 +2345,30 @@ sub rev_map_max {\n \n sub rev_map_max_norebuild {\n \tmy ($self, $want_commit) = @_;\n+\tmy $record_size = ($::oid_length / 2) + 4;\n \tmy $map_path = $self->map_path;\n \tstat $map_path or return $want_commit ? (0, undef) : 0;\n \tsysopen(my $fh, $map_path, O_RDONLY) or croak \"open: $!\";\n \tbinmode $fh or croak \"binmode: $!\";\n \tmy $size = (stat($fh))[7];\n-\t($size % 24) == 0 or croak \"inconsistent size: $size\";\n+\t($size % $record_size) == 0 or croak \"inconsistent size: $size\";\n \n \tif ($size == 0) {\n \t\tclose $fh or croak \"close: $!\";\n \t\treturn $want_commit ? (0, undef) : 0;\n \t}\n \n-\tsysseek($fh, -24, SEEK_END) or croak \"seek: $!\";\n-\tsysread($fh, my $buf, 24) == 24 or croak \"read: $!\";\n+\tsysseek($fh, -$record_size, SEEK_END) or croak \"seek: $!\";\n+\tsysread($fh, my $buf, $record_size) == $record_size or croak \"read: $!\";\n \tmy ($r, $c) = unpack(rev_map_fmt, $buf);\n-\tif ($want_commit && $c eq ('0' x40)) {\n-\t\tif ($size < 48) {\n+\tif ($want_commit && $c eq ('0' x $::oid_length)) {\n+\t\tif ($size < $record_size * 2) {\n \t\t\treturn $want_commit ? (0, undef) : 0;\n \t\t}\n-\t\tsysseek($fh, -48, SEEK_END) or croak \"seek: $!\";\n-\t\tsysread($fh, $buf, 24) == 24 or croak \"read: $!\";\n+\t\tsysseek($fh, -($record_size * 2), SEEK_END) or croak \"seek: $!\";\n+\t\tsysread($fh, $buf, $record_size) == $record_size or croak \"read: $!\";\n \t\t($r, $c) = unpack(rev_map_fmt, $buf);\n-\t\tif ($c eq ('0'x40)) {\n+\t\tif ($c eq ('0' x $::oid_length)) {\n \t\t\tcroak \"Penultimate record is all-zeroes in $map_path\";\n \t\t}\n \t}\n@@ -2387,30 +2389,31 @@ sub rev_map_get {\n \n sub _rev_map_get {\n \tmy ($fh, $rev) = @_;\n+\tmy $record_size = ($::oid_length / 2) + 4;\n \n \tbinmode $fh or croak \"binmode: $!\";\n \tmy $size = (stat($fh))[7];\n-\t($size % 24) == 0 or croak \"inconsistent size: $size\";\n+\t($size % $record_size) == 0 or croak \"inconsistent size: $size\";\n \n \tif ($size == 0) {\n \t\treturn undef;\n \t}\n \n-\tmy ($l, $u) = (0, $size - 24);\n+\tmy ($l, $u) = (0, $size - $record_size);\n \tmy ($r, $c, $buf);\n \n \twhile ($l <= $u) {\n-\t\tmy $i = int(($l/24 + $u/24) / 2) * 24;\n+\t\tmy $i = int(($l/$record_size + $u/$record_size) / 2) * $record_size;\n \t\tsysseek($fh, $i, SEEK_SET) or croak \"seek: $!\";\n-\t\tsysread($fh, my $buf, 24) == 24 or croak \"read: $!\";\n+\t\tsysread($fh, my $buf, $record_size) == $record_size or croak \"read: $!\";\n \t\tmy ($r, $c) = unpack(rev_map_fmt, $buf);\n \n \t\tif ($r < $rev) {\n-\t\t\t$l = $i + 24;\n+\t\t\t$l = $i + $record_size;\n \t\t} elsif ($r > $rev) {\n-\t\t\t$u = $i - 24;\n+\t\t\t$u = $i - $record_size;\n \t\t} else { # $r == $rev\n-\t\t\treturn $c eq ('0' x 40) ? undef : $c;\n+\t\t\treturn $c eq ('0' x $::oid_length) ? undef : $c;\n \t\t}\n \t}\n \tundef;\ndiff --git a/perl/Git/SVN/Editor.pm b/perl/Git/SVN/Editor.pm\nindex 70b6d78cd9..c961444d4c 100644\n--- a/perl/Git/SVN/Editor.pm\n+++ b/perl/Git/SVN/Editor.pm\n@@ -400,12 +400,12 @@ sub T {\n \t    ($m->{mode_b} !~ /^120/ && $m->{mode_a} =~ /^120/)) {\n \t\t$self->D({\n \t\t\tmode_a => $m->{mode_a}, mode_b => '000000',\n-\t\t\tsha1_a => $m->{sha1_a}, sha1_b => '0' x 40,\n+\t\t\tsha1_a => $m->{sha1_a}, sha1_b => '0' x $::oid_length,\n \t\t\tchg => 'D', file_b => $m->{file_b}\n \t\t}, $deletions);\n \t\t$self->A({\n \t\t\tmode_a => '000000', mode_b => $m->{mode_b},\n-\t\t\tsha1_a => '0' x 40, sha1_b => $m->{sha1_b},\n+\t\t\tsha1_a => '0' x $::oid_length, sha1_b => $m->{sha1_b},\n \t\t\tchg => 'A', file_b => $m->{file_b}\n \t\t}, $deletions);\n \t\treturn;\n@@ -434,7 +434,7 @@ ($$$$)\n \t\t$self->change_file_prop($fbat,'svn:special',undef);\n \t}\n \tmy $blob = $m->{\"sha1_$which\"};\n-\treturn ($fh,) if ($blob =~ /^0{40}$/);\n+\treturn ($fh,) if ($blob =~ /^0+$/);\n \tmy $size = $::_repository->cat_blob($blob, $fh);\n \tcroak \"Failed to read object $blob\" if ($size < 0);\n \t$fh->flush == 0 or croak $!;\ndiff --git a/perl/Git/SVN/Fetcher.pm b/perl/Git/SVN/Fetcher.pm\nindex 64e900a0e9..729e5337df 100644\n--- a/perl/Git/SVN/Fetcher.pm\n+++ b/perl/Git/SVN/Fetcher.pm\n@@ -173,7 +173,7 @@ sub delete_entry {\n \n \t# remove entire directories.\n \tmy ($tree) = (command('ls-tree', '-z', $self->{c}, \"./$gpath\")\n-\t                 =~ /\\A040000 tree ([a-f\\d]{40})\\t\\Q$gpath\\E\\0/);\n+\t                 =~ /\\A040000 tree ($::oid)\\t\\Q$gpath\\E\\0/);\n \tif ($tree) {\n \t\tmy ($ls, $ctx) = command_output_pipe(qw/ls-tree\n \t\t                                     -r --name-only -z/,\n@@ -203,7 +203,7 @@ sub open_file {\n \n \tmy $gpath = $self->git_path($path);\n \t($mode, $blob) = (command('ls-tree', '-z', $self->{c}, \"./$gpath\")\n-\t                     =~ /\\A(\\d{6}) blob ([a-f\\d]{40})\\t\\Q$gpath\\E\\0/);\n+\t                     =~ /\\A(\\d{6}) blob ($::oid)\\t\\Q$gpath\\E\\0/);\n \tunless (defined $mode && defined $blob) {\n \t\tdie \"$path was not found in commit $self->{c} (r$rev)\\n\";\n \t}\n@@ -413,7 +413,7 @@ sub close_file {\n \n \t\t$hash = $::_repository->hash_and_insert_object(\n \t\t\t\tGit::temp_path($fh));\n-\t\t$hash =~ /^[a-f\\d]{40}$/ or die \"not a sha1: $hash\\n\";\n+\t\t$hash =~ /^$::oid$/ or die \"not an object ID: $hash\\n\";\n \n \t\tGit::temp_release($fb->{base}, 1);\n \t\tGit::temp_release($fh, 1);\ndiff --git a/perl/Git/SVN/Ra.pm b/perl/Git/SVN/Ra.pm\nindex 56ad9870bc..2cfe055a9a 100644\n--- a/perl/Git/SVN/Ra.pm\n+++ b/perl/Git/SVN/Ra.pm\n@@ -486,11 +486,11 @@ sub gs_fetch_loop_common {\n \t\t\t$reload_ra->() if $ra_invalid;\n \t\t}\n \t\t# pre-fill the .rev_db since it'll eventually get filled in\n-\t\t# with '0' x40 if something new gets committed\n+\t\t# with '0' x $oid_length if something new gets committed\n \t\tforeach my $gs (@$gsv) {\n \t\t\tnext if $gs->rev_map_max >= $max;\n \t\t\tnext if defined $gs->rev_map_get($max);\n-\t\t\t$gs->rev_map_set($max, 0 x40);\n+\t\t\t$gs->rev_map_set($max, 0 x $::oid_length);\n \t\t}\n \t\tforeach my $g (@$globs) {\n \t\t\tmy $k = \"svn-remote.$g->{remote}.$g->{t}-maxRev\";\n"},{"id":"400241","messageId":"20200619223947.947067-9-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200619223947.947067-1-sandals@crustytoothpaste.net","subject":"[PATCH 08/14] perl: create and switch variables for hash constants","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-19T22:39:41Z","receivedAt":"2020-06-19T22:52:12Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"git-svn has several variables for SHA-1 constants, including short hash\nvalues and full length hash values.  Since these are no longer SHA-1\nspecific, let's start them with \"oid\" instead of \"sha1\".  Add a\nconstant, oid_length, which is the length of the hash algorithm in use\nin hex.  We use the hex version because overwhelmingly that's what's\nused by git-svn.\n\nWe don't currently set oid_length based on the repository algorithm, but\nwe will in a future commit.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n git-svn.perl           | 14 ++++++++------\n perl/Git/SVN.pm        | 10 +++++-----\n perl/Git/SVN/Editor.pm |  2 +-\n perl/Git/SVN/Log.pm    |  2 +-\n 4 files changed, 15 insertions(+), 13 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 4aa208ff5f..7c735cebd3 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -5,7 +5,8 @@\n use warnings;\n use strict;\n use vars qw/\t$AUTHOR $VERSION\n-\t\t$sha1 $sha1_short $_revision $_repository\n+\t\t$oid $oid_short $oid_length\n+\t\t$_revision $_repository\n \t\t$_q $_authors $_authors_prog %users/;\n $AUTHOR = 'Eric Wong <normalperson@yhbt.net>';\n $VERSION = '@@GIT_VERSION@@';\n@@ -103,8 +104,9 @@ sub _req_svn {\n \t}\n }\n \n-$sha1 = qr/[a-f\\d]{40}/;\n-$sha1_short = qr/[a-f\\d]{4,40}/;\n+$oid = qr/(?:[a-f\\d]{40}(?:[a-f\\d]{24})?)/;\n+$oid_short = qr/[a-f\\d]{4,64}/;\n+$oid_length = 40;\n my ($_stdin, $_help, $_edit,\n \t$_message, $_file, $_branch_dest,\n \t$_template, $_shared,\n@@ -582,7 +584,7 @@ sub cmd_set_tree {\n \t\tprint \"Reading from stdin...\\n\";\n \t\t@commits = ();\n \t\twhile (<STDIN>) {\n-\t\t\tif (/\\b($sha1_short)\\b/o) {\n+\t\t\tif (/\\b($oid_short)\\b/o) {\n \t\t\t\tunshift @commits, $1;\n \t\t\t}\n \t\t}\n@@ -1831,7 +1833,7 @@ sub get_tree_from_treeish {\n \tif ($type eq 'commit') {\n \t\t$expected = (grep /^tree /, command(qw/cat-file commit/,\n \t\t                                    $treeish))[0];\n-\t\t($expected) = ($expected =~ /^tree ($sha1)$/o);\n+\t\t($expected) = ($expected =~ /^tree ($oid)$/o);\n \t\tdie \"Unable to get tree from $treeish\\n\" unless $expected;\n \t} elsif ($type eq 'tree') {\n \t\t$expected = $treeish;\n@@ -2036,7 +2038,7 @@ sub working_head_info {\n \tmy $hash;\n \tmy %max;\n \twhile (<$fh>) {\n-\t\tif ( m{^commit ($::sha1)$} ) {\n+\t\tif ( m{^commit ($::oid)$} ) {\n \t\t\tunshift @$refs, $hash if $hash and $refs;\n \t\t\t$hash = $1;\n \t\t\tnext;\ndiff --git a/perl/Git/SVN.pm b/perl/Git/SVN.pm\nindex 4b28b87784..fcf1e3bb5e 100644\n--- a/perl/Git/SVN.pm\n+++ b/perl/Git/SVN.pm\n@@ -874,7 +874,7 @@ sub assert_index_clean {\n \t\tcommand_noisy('read-tree', $treeish) unless -e $self->{index};\n \t\tmy $x = command_oneline('write-tree');\n \t\tmy ($y) = (command(qw/cat-file commit/, $treeish) =~\n-\t\t           /^tree ($::sha1)/mo);\n+\t\t           /^tree ($::oid)/mo);\n \t\treturn if $y eq $x;\n \n \t\twarn \"Index mismatch: $y != $x\\nrereading $treeish\\n\";\n@@ -1020,7 +1020,7 @@ sub do_git_commit {\n \t\t$tree = $self->tmp_index_do(sub {\n \t\t                            command_oneline('write-tree') });\n \t}\n-\tdie \"Tree is not a valid sha1: $tree\\n\" if $tree !~ /^$::sha1$/o;\n+\tdie \"Tree is not a valid oid $tree\\n\" if $tree !~ /^$::oid$/o;\n \n \tmy @exec = ('git', 'commit-tree', $tree);\n \tforeach ($self->get_commit_parents($log_entry)) {\n@@ -1048,8 +1048,8 @@ sub do_git_commit {\n \tclose $out_fh or croak $!;\n \twaitpid $pid, 0;\n \tcroak $? if $?;\n-\tif ($commit !~ /^$::sha1$/o) {\n-\t\tdie \"Failed to commit, invalid sha1: $commit\\n\";\n+\tif ($commit !~ /^$::oid$/o) {\n+\t\tdie \"Failed to commit, invalid oid: $commit\\n\";\n \t}\n \n \t$self->rev_map_set($log_entry->{revision}, $commit, 1);\n@@ -2150,7 +2150,7 @@ sub rebuild {\n \tmy $svn_uuid = $self->rewrite_uuid || $self->ra_uuid;\n \tmy $c;\n \twhile (<$log>) {\n-\t\tif ( m{^commit ($::sha1)$} ) {\n+\t\tif ( m{^commit ($::oid)$} ) {\n \t\t\t$c = $1;\n \t\t\tnext;\n \t\t}\ndiff --git a/perl/Git/SVN/Editor.pm b/perl/Git/SVN/Editor.pm\nindex 0df16ed726..70b6d78cd9 100644\n--- a/perl/Git/SVN/Editor.pm\n+++ b/perl/Git/SVN/Editor.pm\n@@ -63,7 +63,7 @@ sub generate_diff {\n \tmy @mods;\n \twhile (defined($_ = get_record($diff_fh, \"\\0\"))) {\n \t\tif ($state eq 'meta' && /^:(\\d{6})\\s(\\d{6})\\s\n-\t\t\t\t\t($::sha1)\\s($::sha1)\\s\n+\t\t\t\t\t($::oid)\\s($::oid)\\s\n \t\t\t\t\t([MTCRAD])\\d*$/xo) {\n \t\t\tpush @mods, {\tmode_a => $1, mode_b => $2,\n \t\t\t\t\tsha1_a => $3, sha1_b => $4,\ndiff --git a/perl/Git/SVN/Log.pm b/perl/Git/SVN/Log.pm\nindex 664105357c..3858fcf27d 100644\n--- a/perl/Git/SVN/Log.pm\n+++ b/perl/Git/SVN/Log.pm\n@@ -285,7 +285,7 @@ sub cmd_show_log {\n \tmy (@k, $c, $d, $stat);\n \tmy $esc_color = qr/(?:\\033\\[(?:(?:\\d+;)*\\d*)?m)*/;\n \twhile (<$log>) {\n-\t\tif (/^${esc_color}commit (?:- )?($::sha1_short)/o) {\n+\t\tif (/^${esc_color}commit (?:- )?($::oid_short)/o) {\n \t\t\tmy $cmt = $1;\n \t\t\tif ($c && cmt_showable($c) && $c->{r} != $r_last) {\n \t\t\t\t$r_last = $c->{r};\n"},{"id":"400247","messageId":"20200620002111.GA30254@dcvr","threadId":"53722","inReplyTo":"20200619223947.947067-1-sandals@crustytoothpaste.net","subject":"Re: [PATCH 00/14] SHA-256 CVS and SVN patches","fromName":"Eric Wong","fromEmail":"e@80x24.org","sentAt":"2020-06-20T00:21:11Z","receivedAt":"2020-06-20T00:21:12Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"\"brian m. carlson\" <sandals@crustytoothpaste.net> wrote:\n> The patches are ordered roughly with test-only fixes, then SVN, and then\n> CVS.  There are no additional tests here because everything fails with\n> SHA-256 before and passes afterwards.\n\nThanks brian.  I took a quick look at this series (including the\nCVS stuff) and nothing objectionable jumped out(*).\n\nConsider this series Acked-by: me\n\n(*) except perhaps some of my original code :x\n    which I hope to fix at some point this year\n"},{"id":"400250","messageId":"87lfkinp02.fsf@linux-m68k.org","threadId":"53722","inReplyTo":"20200619223947.947067-8-sandals@crustytoothpaste.net","subject":"Re: [PATCH 07/14] t/lib-git-svn: make hash size independent","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2020-06-20T08:02:53Z","receivedAt":"2020-06-20T08:03:03Z","isPatch":true,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"On Jun 19 2020, brian m. carlson wrote:\n\n> diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh\n> index 7d248e6588..4780b45337 100644\n> --- a/t/lib-git-svn.sh\n> +++ b/t/lib-git-svn.sh\n> @@ -78,29 +78,30 @@ maybe_start_httpd () {\n>  }\n>  \n>  convert_to_rev_db () {\n> -\tperl -w -- - \"$@\" <<\\EOF\n> -use strict;\n> +\tperl -w -e \"use strict; my \\$oidlen = $(test_oid rawsz);\" -e '\n\n$(test_oid rawsz) could be passed as an additional argument.\n\nperl -w -- - \"$(test_oid rawsz)\" \"$@\" <<\\EOF\nuse strict;\nmy $oidlen = shift;\n...\nEOF\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1\n\"And now for something completely different.\"\n"},{"id":"400252","messageId":"20200620131846.GL6531@camp.crustytoothpaste.net","threadId":"53722","inReplyTo":"87lfkinp02.fsf@linux-m68k.org","subject":"Re: [PATCH 07/14] t/lib-git-svn: make hash size independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-20T13:18:46Z","receivedAt":"2020-06-20T13:19:27Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2020-06-20 at 08:02:53, Andreas Schwab wrote:\n> On Jun 19 2020, brian m. carlson wrote:\n> \n> > diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh\n> > index 7d248e6588..4780b45337 100644\n> > --- a/t/lib-git-svn.sh\n> > +++ b/t/lib-git-svn.sh\n> > @@ -78,29 +78,30 @@ maybe_start_httpd () {\n> >  }\n> >  \n> >  convert_to_rev_db () {\n> > -\tperl -w -- - \"$@\" <<\\EOF\n> > -use strict;\n> > +\tperl -w -e \"use strict; my \\$oidlen = $(test_oid rawsz);\" -e '\n> \n> $(test_oid rawsz) could be passed as an additional argument.\n> \n> perl -w -- - \"$(test_oid rawsz)\" \"$@\" <<\\EOF\n> use strict;\n> my $oidlen = shift;\n> ...\n> EOF\n\nSure, I could do that.  I originally tried to pass it through the\nenvironment, but that didn't appear to work as I expected.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"400287","messageId":"xmqqbllbdoym.fsf@gitster.c.googlers.com","threadId":"53722","inReplyTo":"20200619223947.947067-1-sandals@crustytoothpaste.net","subject":"Re: [PATCH 00/14] SHA-256 CVS and SVN patches","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-06-22T16:50:41Z","receivedAt":"2020-06-22T16:50:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n\n> I recently sent out part 2/3 of the SHA-256 work and then I realized\n> that I hadn't built with the CVS and SVN adapters.  So this is part\n> 2.5/3 (or, to be pedantic, 3/4).\n\nOK.  It seems that at least the early test-only parts depends only\non what is already in 'master' (there are uses of \"test_oid algo\"\nand \"test_oid rawsz\"), but let's queue it on top of 3716d50d\n(remote-testgit: adapt for object-format, 2020-06-19), and merge the\npart 2 to 'next' soonish.\n\nThanks.\n"},{"id":"400289","messageId":"20200622174611.GM6531@camp.crustytoothpaste.net","threadId":"53722","inReplyTo":"xmqqbllbdoym.fsf@gitster.c.googlers.com","subject":"Re: [PATCH 00/14] SHA-256 CVS and SVN patches","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-22T17:46:11Z","receivedAt":"2020-06-22T17:46:48Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2020-06-22 at 16:50:41, Junio C Hamano wrote:\n> \"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n> \n> > I recently sent out part 2/3 of the SHA-256 work and then I realized\n> > that I hadn't built with the CVS and SVN adapters.  So this is part\n> > 2.5/3 (or, to be pedantic, 3/4).\n> \n> OK.  It seems that at least the early test-only parts depends only\n> on what is already in 'master' (there are uses of \"test_oid algo\"\n> and \"test_oid rawsz\"), but let's queue it on top of 3716d50d\n> (remote-testgit: adapt for object-format, 2020-06-19), and merge the\n> part 2 to 'next' soonish.\n\nSounds fine.  I'm about to send out a v2 with Andreas's suggestion (and\ntherefore a slightly smaller diff), but it should be a straightforward\nreplacement.\n\nAnd yes, that it was based off master was intentional.  There are no\nmore test structure changes before the final series.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"400290","messageId":"20200622180418.2418483-1-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200619223947.947067-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 00/14] SHA-256 CVS and SVN patches","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-22T18:04:04Z","receivedAt":"2020-06-22T18:04:27Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"I recently sent out part 2/3 of the SHA-256 work and then I realized\nthat I hadn't built with the CVS and SVN adapters.  So this is part\n2.5/3 (or, to be pedantic, 3/4).\n\nThe patches are ordered roughly with test-only fixes, then SVN, and then\nCVS.  There are no additional tests here because everything fails with\nSHA-256 before and passes afterwards.\n\nChanges from v1:\n* Adopt Andreas's suggestion to preserve more of the structure of the\n  original function.\n\nRange-diff below.\n\nbrian m. carlson (14):\n  t9109: make test hash independent\n  t9168: make test hash independent\n  t9108: make test hash independent\n  t9100: make test work with SHA-256\n  t9104: make hash size independent\n  t9101: make hash independent\n  t/lib-git-svn: make hash size independent\n  perl: create and switch variables for hash constants\n  perl: make Git::IndexInfo work with SHA-256\n  perl: make SVN code hash independent\n  git-svn: set the OID length based on hash algorithm\n  git-cvsserver: port to SHA-256\n  git-cvsimport: port to SHA-256\n  git-cvsexportcommit: port to SHA-256\n\n git-cvsexportcommit.perl                   | 14 ++--\n git-cvsimport.perl                         |  8 +--\n git-cvsserver.perl                         | 37 +++++-----\n git-svn.perl                               | 25 ++++---\n perl/Git/IndexInfo.pm                      |  6 +-\n perl/Git/SVN.pm                            | 83 +++++++++++-----------\n perl/Git/SVN/Editor.pm                     |  8 +--\n perl/Git/SVN/Fetcher.pm                    |  6 +-\n perl/Git/SVN/Log.pm                        |  2 +-\n perl/Git/SVN/Ra.pm                         |  4 +-\n t/lib-git-svn.sh                           | 17 +++--\n t/t9100-git-svn-basic.sh                   | 19 ++++-\n t/t9101-git-svn-props.sh                   | 12 ++--\n t/t9104-git-svn-follow-parent.sh           |  3 +-\n t/t9108-git-svn-glob.sh                    |  4 +-\n t/t9109-git-svn-multi-glob.sh              |  6 +-\n t/t9168-git-svn-partially-globbed-names.sh |  8 +--\n 17 files changed, 151 insertions(+), 111 deletions(-)\n\nRange-diff against v1:\n 1:  cc8a204394 =  1:  cc8a204394 t9109: make test hash independent\n 2:  814c3423ef =  2:  814c3423ef t9168: make test hash independent\n 3:  81b1f48671 =  3:  81b1f48671 t9108: make test hash independent\n 4:  8571f65b17 =  4:  8571f65b17 t9100: make test work with SHA-256\n 5:  d93ded4e74 =  5:  d93ded4e74 t9104: make hash size independent\n 6:  3e401f3e48 =  6:  3e401f3e48 t9101: make hash independent\n 7:  02cb87e4be !  7:  17cc278f1d t/lib-git-svn: make hash size independent\n    @@ t/lib-git-svn.sh: maybe_start_httpd () {\n      \n      convert_to_rev_db () {\n     -\tperl -w -- - \"$@\" <<\\EOF\n    --use strict;\n    -+\tperl -w -e \"use strict; my \\$oidlen = $(test_oid rawsz);\" -e '\n    ++\tperl -w -- - \"$(test_oid rawsz)\" \"$@\" <<\\EOF\n    + use strict;\n    ++my $oidlen = shift;\n      @ARGV == 2 or die \"usage: convert_to_rev_db <input> <output>\";\n    --open my $wr, '+>', $ARGV[1] or die \"$!: couldn't open: $ARGV[1]\";\n    --open my $rd, '<', $ARGV[0] or die \"$!: couldn't open: $ARGV[0]\";\n     +my $record_size = $oidlen + 4;\n     +my $hexlen = $oidlen * 2;\n    -+open my $wr, \"+>\", $ARGV[1] or die \"$!: couldn'\\''t open: $ARGV[1]\";\n    -+open my $rd, \"<\", $ARGV[0] or die \"$!: couldn'\\''t open: $ARGV[0]\";\n    + open my $wr, '+>', $ARGV[1] or die \"$!: couldn't open: $ARGV[1]\";\n    + open my $rd, '<', $ARGV[0] or die \"$!: couldn't open: $ARGV[0]\";\n      my $size = (stat($rd))[7];\n     -($size % 24) == 0 or die \"Inconsistent size: $size\";\n     -while (sysread($rd, my $buf, 24) == 24) {\n    @@ t/lib-git-svn.sh: maybe_start_httpd () {\n      \t\t}\n      \t}\n      \tseek $wr, $offset, 0 or die $!;\n    - \tprint $wr $c,\"\\n\" or die $!;\n    - }\n    - close $wr or die $!;\n    --close $rd or die $!;\n    --EOF\n    -+close $rd or die $!;' \\\n    -+\t-- \"$@\"\n    - }\n    - \n    - require_svnserve () {\n 8:  d59b8ac38e =  8:  a59dbf9637 perl: create and switch variables for hash constants\n 9:  d3c991fb52 =  9:  c2ff48efa4 perl: make Git::IndexInfo work with SHA-256\n10:  7f87880cb2 = 10:  2b5d83ad2f perl: make SVN code hash independent\n11:  9100fbd4cf = 11:  66a46baf27 git-svn: set the OID length based on hash algorithm\n12:  9655d1f0ea = 12:  b2309179f6 git-cvsserver: port to SHA-256\n13:  618abf0af1 = 13:  0d5680f2e6 git-cvsimport: port to SHA-256\n14:  290f0ec11f = 14:  fecbc1fbf9 git-cvsexportcommit: port to SHA-256\n"},{"id":"400291","messageId":"20200622180418.2418483-2-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200622180418.2418483-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 01/14] t9109: make test hash independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-22T18:04:05Z","receivedAt":"2020-06-22T18:04:29Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Instead of stripping off the first 41 characters of git log output,\nlet's just strip off the first space-separated component, which will\nwork for any size hash.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t9109-git-svn-multi-glob.sh | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t9109-git-svn-multi-glob.sh b/t/t9109-git-svn-multi-glob.sh\nindex c1e7542a37..648dcee1ea 100755\n--- a/t/t9109-git-svn-multi-glob.sh\n+++ b/t/t9109-git-svn-multi-glob.sh\n@@ -48,7 +48,7 @@ test_expect_success 'test refspec globbing' '\n \t                 \"tags/*/src/a:refs/remotes/tags/*\" &&\n \tgit svn multi-fetch &&\n \tgit log --pretty=oneline refs/remotes/tags/end >actual &&\n-\tsed -e \"s/^.\\{41\\}//\" actual >output.end &&\n+\tcut -d\" \" -f2- actual >output.end &&\n \ttest_cmp expect.end output.end &&\n \ttest \"$(git rev-parse refs/remotes/tags/end~1)\" = \\\n \t\t\"$(git rev-parse refs/remotes/branches/v1/start)\" &&\n@@ -84,7 +84,7 @@ test_expect_success 'test left-hand-side only globbing' '\n \ttest $(git rev-parse refs/remotes/two/tags/end~3) = \\\n \t     $(git rev-parse refs/remotes/two/branches/v1/start) &&\n \tgit log --pretty=oneline refs/remotes/two/tags/end >actual &&\n-\tsed -e \"s/^.\\{41\\}//\" actual >output.two &&\n+\tcut -d\" \" -f2- actual >output.two &&\n \ttest_cmp expect.two output.two\n \t'\n cat > expect.four <<EOF\n@@ -135,7 +135,7 @@ test_expect_success 'test another branch' '\n \ttest $(git rev-parse refs/remotes/four/tags/next~2) = \\\n \t     $(git rev-parse refs/remotes/four/branches/v2/start) &&\n \tgit log --pretty=oneline refs/remotes/four/tags/next >actual &&\n-\tsed -e \"s/^.\\{41\\}//\" actual >output.four &&\n+\tcut -d\" \" -f2- actual >output.four &&\n \ttest_cmp expect.four output.four\n \t'\n \n"},{"id":"400292","messageId":"20200622180418.2418483-3-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200622180418.2418483-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 02/14] t9168: make test hash independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-22T18:04:06Z","receivedAt":"2020-06-22T18:04:29Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Instead of stripping off the first 41 characters of git log output,\nlet's just strip off the first space-separated component, which will\nwork for any size hash.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t9168-git-svn-partially-globbed-names.sh | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/t/t9168-git-svn-partially-globbed-names.sh b/t/t9168-git-svn-partially-globbed-names.sh\nindex bdf6e84999..854b3419b2 100755\n--- a/t/t9168-git-svn-partially-globbed-names.sh\n+++ b/t/t9168-git-svn-partially-globbed-names.sh\n@@ -49,7 +49,7 @@ test_expect_success 'test refspec prefixed globbing' '\n \t\t\t \"tags/t_*/src/a:refs/remotes/tags/t_*\" &&\n \tgit svn multi-fetch &&\n \tgit log --pretty=oneline refs/remotes/tags/t_end >actual &&\n-\tsed -e \"s/^.\\{41\\}//\" actual >output.end &&\n+\tcut -d\" \" -f2- actual >output.end &&\n \ttest_cmp expect.end output.end &&\n \ttest \"$(git rev-parse refs/remotes/tags/t_end~1)\" = \\\n \t\t\"$(git rev-parse refs/remotes/branches/b_start)\" &&\n@@ -87,7 +87,7 @@ test_expect_success 'test left-hand-side only prefixed globbing' '\n \ttest $(git rev-parse refs/remotes/two/tags/t_end~3) = \\\n \t     $(git rev-parse refs/remotes/two/branches/b_start) &&\n \tgit log --pretty=oneline refs/remotes/two/tags/t_end >actual &&\n-\tsed -e \"s/^.\\{41\\}//\" actual >output.two &&\n+\tcut -d\" \" -f2- actual >output.two &&\n \ttest_cmp expect.two output.two\n \t'\n \n@@ -129,7 +129,7 @@ test_expect_success 'test prefixed globs match just prefix' '\n \ttest $(git rev-parse refs/remotes/three/tags/t_~1) = \\\n \t     $(git rev-parse refs/remotes/three/branches/b_) &&\n \tgit log --pretty=oneline refs/remotes/three/tags/t_ >actual &&\n-\tsed -e \"s/^.\\{41\\}//\" actual >output.three &&\n+\tcut -d\" \" -f2- actual >output.three &&\n \ttest_cmp expect.three output.three\n \t'\n \n@@ -199,7 +199,7 @@ test_expect_success 'test globbing in the middle of the word' '\n \ttest $(git rev-parse refs/remotes/five/tags/fghij~1) = \\\n \t     $(git rev-parse refs/remotes/five/branches/abcde) &&\n \tgit log --pretty=oneline refs/remotes/five/tags/fghij >actual &&\n-\tsed -e \"s/^.\\{41\\}//\" actual >output.five &&\n+\tcut -d\" \" -f2- actual >output.five &&\n \ttest_cmp expect.five output.five\n \t'\n \n"},{"id":"400293","messageId":"20200622180418.2418483-9-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200622180418.2418483-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 08/14] perl: create and switch variables for hash constants","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-22T18:04:12Z","receivedAt":"2020-06-22T18:04:32Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"git-svn has several variables for SHA-1 constants, including short hash\nvalues and full length hash values.  Since these are no longer SHA-1\nspecific, let's start them with \"oid\" instead of \"sha1\".  Add a\nconstant, oid_length, which is the length of the hash algorithm in use\nin hex.  We use the hex version because overwhelmingly that's what's\nused by git-svn.\n\nWe don't currently set oid_length based on the repository algorithm, but\nwe will in a future commit.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n git-svn.perl           | 14 ++++++++------\n perl/Git/SVN.pm        | 10 +++++-----\n perl/Git/SVN/Editor.pm |  2 +-\n perl/Git/SVN/Log.pm    |  2 +-\n 4 files changed, 15 insertions(+), 13 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 4aa208ff5f..7c735cebd3 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -5,7 +5,8 @@\n use warnings;\n use strict;\n use vars qw/\t$AUTHOR $VERSION\n-\t\t$sha1 $sha1_short $_revision $_repository\n+\t\t$oid $oid_short $oid_length\n+\t\t$_revision $_repository\n \t\t$_q $_authors $_authors_prog %users/;\n $AUTHOR = 'Eric Wong <normalperson@yhbt.net>';\n $VERSION = '@@GIT_VERSION@@';\n@@ -103,8 +104,9 @@ sub _req_svn {\n \t}\n }\n \n-$sha1 = qr/[a-f\\d]{40}/;\n-$sha1_short = qr/[a-f\\d]{4,40}/;\n+$oid = qr/(?:[a-f\\d]{40}(?:[a-f\\d]{24})?)/;\n+$oid_short = qr/[a-f\\d]{4,64}/;\n+$oid_length = 40;\n my ($_stdin, $_help, $_edit,\n \t$_message, $_file, $_branch_dest,\n \t$_template, $_shared,\n@@ -582,7 +584,7 @@ sub cmd_set_tree {\n \t\tprint \"Reading from stdin...\\n\";\n \t\t@commits = ();\n \t\twhile (<STDIN>) {\n-\t\t\tif (/\\b($sha1_short)\\b/o) {\n+\t\t\tif (/\\b($oid_short)\\b/o) {\n \t\t\t\tunshift @commits, $1;\n \t\t\t}\n \t\t}\n@@ -1831,7 +1833,7 @@ sub get_tree_from_treeish {\n \tif ($type eq 'commit') {\n \t\t$expected = (grep /^tree /, command(qw/cat-file commit/,\n \t\t                                    $treeish))[0];\n-\t\t($expected) = ($expected =~ /^tree ($sha1)$/o);\n+\t\t($expected) = ($expected =~ /^tree ($oid)$/o);\n \t\tdie \"Unable to get tree from $treeish\\n\" unless $expected;\n \t} elsif ($type eq 'tree') {\n \t\t$expected = $treeish;\n@@ -2036,7 +2038,7 @@ sub working_head_info {\n \tmy $hash;\n \tmy %max;\n \twhile (<$fh>) {\n-\t\tif ( m{^commit ($::sha1)$} ) {\n+\t\tif ( m{^commit ($::oid)$} ) {\n \t\t\tunshift @$refs, $hash if $hash and $refs;\n \t\t\t$hash = $1;\n \t\t\tnext;\ndiff --git a/perl/Git/SVN.pm b/perl/Git/SVN.pm\nindex 4b28b87784..fcf1e3bb5e 100644\n--- a/perl/Git/SVN.pm\n+++ b/perl/Git/SVN.pm\n@@ -874,7 +874,7 @@ sub assert_index_clean {\n \t\tcommand_noisy('read-tree', $treeish) unless -e $self->{index};\n \t\tmy $x = command_oneline('write-tree');\n \t\tmy ($y) = (command(qw/cat-file commit/, $treeish) =~\n-\t\t           /^tree ($::sha1)/mo);\n+\t\t           /^tree ($::oid)/mo);\n \t\treturn if $y eq $x;\n \n \t\twarn \"Index mismatch: $y != $x\\nrereading $treeish\\n\";\n@@ -1020,7 +1020,7 @@ sub do_git_commit {\n \t\t$tree = $self->tmp_index_do(sub {\n \t\t                            command_oneline('write-tree') });\n \t}\n-\tdie \"Tree is not a valid sha1: $tree\\n\" if $tree !~ /^$::sha1$/o;\n+\tdie \"Tree is not a valid oid $tree\\n\" if $tree !~ /^$::oid$/o;\n \n \tmy @exec = ('git', 'commit-tree', $tree);\n \tforeach ($self->get_commit_parents($log_entry)) {\n@@ -1048,8 +1048,8 @@ sub do_git_commit {\n \tclose $out_fh or croak $!;\n \twaitpid $pid, 0;\n \tcroak $? if $?;\n-\tif ($commit !~ /^$::sha1$/o) {\n-\t\tdie \"Failed to commit, invalid sha1: $commit\\n\";\n+\tif ($commit !~ /^$::oid$/o) {\n+\t\tdie \"Failed to commit, invalid oid: $commit\\n\";\n \t}\n \n \t$self->rev_map_set($log_entry->{revision}, $commit, 1);\n@@ -2150,7 +2150,7 @@ sub rebuild {\n \tmy $svn_uuid = $self->rewrite_uuid || $self->ra_uuid;\n \tmy $c;\n \twhile (<$log>) {\n-\t\tif ( m{^commit ($::sha1)$} ) {\n+\t\tif ( m{^commit ($::oid)$} ) {\n \t\t\t$c = $1;\n \t\t\tnext;\n \t\t}\ndiff --git a/perl/Git/SVN/Editor.pm b/perl/Git/SVN/Editor.pm\nindex 0df16ed726..70b6d78cd9 100644\n--- a/perl/Git/SVN/Editor.pm\n+++ b/perl/Git/SVN/Editor.pm\n@@ -63,7 +63,7 @@ sub generate_diff {\n \tmy @mods;\n \twhile (defined($_ = get_record($diff_fh, \"\\0\"))) {\n \t\tif ($state eq 'meta' && /^:(\\d{6})\\s(\\d{6})\\s\n-\t\t\t\t\t($::sha1)\\s($::sha1)\\s\n+\t\t\t\t\t($::oid)\\s($::oid)\\s\n \t\t\t\t\t([MTCRAD])\\d*$/xo) {\n \t\t\tpush @mods, {\tmode_a => $1, mode_b => $2,\n \t\t\t\t\tsha1_a => $3, sha1_b => $4,\ndiff --git a/perl/Git/SVN/Log.pm b/perl/Git/SVN/Log.pm\nindex 664105357c..3858fcf27d 100644\n--- a/perl/Git/SVN/Log.pm\n+++ b/perl/Git/SVN/Log.pm\n@@ -285,7 +285,7 @@ sub cmd_show_log {\n \tmy (@k, $c, $d, $stat);\n \tmy $esc_color = qr/(?:\\033\\[(?:(?:\\d+;)*\\d*)?m)*/;\n \twhile (<$log>) {\n-\t\tif (/^${esc_color}commit (?:- )?($::sha1_short)/o) {\n+\t\tif (/^${esc_color}commit (?:- )?($::oid_short)/o) {\n \t\t\tmy $cmt = $1;\n \t\t\tif ($c && cmt_showable($c) && $c->{r} != $r_last) {\n \t\t\t\t$r_last = $c->{r};\n"},{"id":"400294","messageId":"20200622180418.2418483-4-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200622180418.2418483-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 03/14] t9108: make test hash independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-22T18:04:07Z","receivedAt":"2020-06-22T18:04:33Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Instead of stripping off the first 41 characters of git log output,\nlet's just strip off the first space-separated component, which will\nwork for any size hash.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t9108-git-svn-glob.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t9108-git-svn-glob.sh b/t/t9108-git-svn-glob.sh\nindex 6990f64364..d5939d4753 100755\n--- a/t/t9108-git-svn-glob.sh\n+++ b/t/t9108-git-svn-glob.sh\n@@ -48,7 +48,7 @@ test_expect_success 'test refspec globbing' '\n \t                 \"tags/*/src/a:refs/remotes/tags/*\" &&\n \tgit svn multi-fetch &&\n \tgit log --pretty=oneline refs/remotes/tags/end >actual &&\n-\tsed -e \"s/^.\\{41\\}//\" actual >output.end &&\n+\tcut -d\" \" -f2- actual >output.end &&\n \ttest_cmp expect.end output.end &&\n \ttest \"$(git rev-parse refs/remotes/tags/end~1)\" = \\\n \t\t\"$(git rev-parse refs/remotes/branches/start)\" &&\n@@ -84,7 +84,7 @@ test_expect_success 'test left-hand-side only globbing' '\n \ttest $(git rev-parse refs/remotes/two/tags/end~3) = \\\n \t     $(git rev-parse refs/remotes/two/branches/start) &&\n \tgit log --pretty=oneline refs/remotes/two/tags/end >actual &&\n-\tsed -e \"s/^.\\{41\\}//\" actual >output.two &&\n+\tcut -d\" \" -f2- actual >output.two &&\n \ttest_cmp expect.two output.two\n \t'\n \n"},{"id":"400295","messageId":"20200622180418.2418483-5-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200622180418.2418483-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 04/14] t9100: make test work with SHA-256","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-22T18:04:08Z","receivedAt":"2020-06-22T18:04:34Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Compute the relevant tree objects for SHA-256 and use those when\nappropriate instead of using the SHA-1 ones.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t9100-git-svn-basic.sh | 19 ++++++++++++++++---\n 1 file changed, 16 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh\nindex 2c309a57d9..9f2d19ecc4 100755\n--- a/t/t9100-git-svn-basic.sh\n+++ b/t/t9100-git-svn-basic.sh\n@@ -208,9 +208,10 @@ name='check imported tree checksums expected tree checksums'\n rm -f expected\n if test_have_prereq UTF8\n then\n-\techo tree dc68b14b733e4ec85b04ab6f712340edc5dc936e > expected\n+\techo tree dc68b14b733e4ec85b04ab6f712340edc5dc936e > expected.sha1\n+\techo tree b95b55b29d771f5eb73aa9b9d52d02fe11a2538c2feb0829f754ce20a91d98eb > expected.sha256\n fi\n-cat >> expected <<\\EOF\n+cat >> expected.sha1 <<\\EOF\n tree c3322890dcf74901f32d216f05c5044f670ce632\n tree d3ccd5035feafd17b030c5732e7808cc49122853\n tree d03e1630363d4881e68929d532746b20b0986b83\n@@ -220,8 +221,20 @@ tree 149d63cd5878155c846e8c55d7d8487de283f89e\n tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e\n tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4\n EOF\n+cat >> expected.sha256 <<\\EOF\n+tree 8d12756699d0b5b110514240a0ff141f6cbf8891fd69ab05e5594196fb437c9f\n+tree 8187168d33f7d4ccb8c1cc6e99532810aaccb47658f35d19b3803072d1128d7a\n+tree 74e535d85da8ee25eb23d7b506790c5ab3ccdb1ba0826bd57625ed44ef361650\n+tree 6fd7dd963e3cdca0cbd6368ed3cfcc8037cc154d2e7719d9d369a0952364fd95\n+tree 1fd6cec6aa95102d69266e20419bb62ec2a06372d614b9850ef23ff204103bb4\n+tree 6fd7dd963e3cdca0cbd6368ed3cfcc8037cc154d2e7719d9d369a0952364fd95\n+tree deb2b7ac79cd8ce6f52af6a5a0a08691e94ba74a2ed55966bb27dbec551730eb\n+tree 59e2e936761188476a7752034e8aa0a822b34050c8504b0dfd946407f4bc9215\n+EOF\n \n-test_expect_success POSIXPERM,SYMLINKS \"$name\" \"test_cmp expected a\"\n+test_expect_success POSIXPERM,SYMLINKS \"$name\" '\n+\ttest_cmp expected.$(test_oid algo) a\n+'\n \n test_expect_success 'exit if remote refs are ambigious' '\n         git config --add svn-remote.svn.fetch \\\n"},{"id":"400296","messageId":"20200622180418.2418483-10-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200622180418.2418483-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 09/14] perl: make Git::IndexInfo work with SHA-256","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-22T18:04:13Z","receivedAt":"2020-06-22T18:04:35Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Most of the Git modules, git-svn excepted, don't know anything about the\nhash algorithm and mostly work.  However, when we're printing an\nall-zero object ID in Git::IndexInfo, we need to know the hash length.\n\nSince we don't want to change the API to have that information passed\nin, let's query the config to find the hash algorithm and compute the\nright value.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n perl/Git/IndexInfo.pm | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/perl/Git/IndexInfo.pm b/perl/Git/IndexInfo.pm\nindex a43108c985..2a7b4908f3 100644\n--- a/perl/Git/IndexInfo.pm\n+++ b/perl/Git/IndexInfo.pm\n@@ -5,13 +5,15 @@ package Git::IndexInfo;\n \n sub new {\n \tmy ($class) = @_;\n+\tmy $hash_algo = Git::config('extensions.objectformat') || 'sha1';\n \tmy ($gui, $ctx) = command_input_pipe(qw/update-index -z --index-info/);\n-\tbless { gui => $gui, ctx => $ctx, nr => 0}, $class;\n+\tbless { gui => $gui, ctx => $ctx, nr => 0, hash_algo => $hash_algo}, $class;\n }\n \n sub remove {\n \tmy ($self, $path) = @_;\n-\tif (print { $self->{gui} } '0 ', 0 x 40, \"\\t\", $path, \"\\0\") {\n+\tmy $length = $self->{hash_algo} eq 'sha256' ? 64 : 40;\n+\tif (print { $self->{gui} } '0 ', 0 x $length, \"\\t\", $path, \"\\0\") {\n \t\treturn ++$self->{nr};\n \t}\n \tundef;\n"},{"id":"400297","messageId":"20200622180418.2418483-8-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200622180418.2418483-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 07/14] t/lib-git-svn: make hash size independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-22T18:04:11Z","receivedAt":"2020-06-22T18:04:36Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"The record size used in the git svn storage is four bytes plus the\nlength of the binary hash.  Pass the hash length into our Perl\ninvocation and use it to compute the size of the records.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/lib-git-svn.sh | 17 ++++++++++-------\n 1 file changed, 10 insertions(+), 7 deletions(-)\n\ndiff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh\nindex 7d248e6588..547eb3c31a 100644\n--- a/t/lib-git-svn.sh\n+++ b/t/lib-git-svn.sh\n@@ -78,21 +78,24 @@ maybe_start_httpd () {\n }\n \n convert_to_rev_db () {\n-\tperl -w -- - \"$@\" <<\\EOF\n+\tperl -w -- - \"$(test_oid rawsz)\" \"$@\" <<\\EOF\n use strict;\n+my $oidlen = shift;\n @ARGV == 2 or die \"usage: convert_to_rev_db <input> <output>\";\n+my $record_size = $oidlen + 4;\n+my $hexlen = $oidlen * 2;\n open my $wr, '+>', $ARGV[1] or die \"$!: couldn't open: $ARGV[1]\";\n open my $rd, '<', $ARGV[0] or die \"$!: couldn't open: $ARGV[0]\";\n my $size = (stat($rd))[7];\n-($size % 24) == 0 or die \"Inconsistent size: $size\";\n-while (sysread($rd, my $buf, 24) == 24) {\n-\tmy ($r, $c) = unpack('NH40', $buf);\n-\tmy $offset = $r * 41;\n+($size % $record_size) == 0 or die \"Inconsistent size: $size\";\n+while (sysread($rd, my $buf, $record_size) == $record_size) {\n+\tmy ($r, $c) = unpack(\"NH$hexlen\", $buf);\n+\tmy $offset = $r * ($hexlen + 1);\n \tseek $wr, 0, 2 or die $!;\n \tmy $pos = tell $wr;\n \tif ($pos < $offset) {\n-\t\tfor (1 .. (($offset - $pos) / 41)) {\n-\t\t\tprint $wr (('0' x 40),\"\\n\") or die $!;\n+\t\tfor (1 .. (($offset - $pos) / ($hexlen + 1))) {\n+\t\t\tprint $wr (('0' x $hexlen),\"\\n\") or die $!;\n \t\t}\n \t}\n \tseek $wr, $offset, 0 or die $!;\n"},{"id":"400298","messageId":"20200622180418.2418483-15-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200622180418.2418483-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 14/14] git-cvsexportcommit: port to SHA-256","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-22T18:04:18Z","receivedAt":"2020-06-22T18:04:38Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"When we apply a binary patch, we must have the full object ID in the\nheader in order to apply it; without that, any attempt to apply it will\nfail.  If we set GIT_DIR to empty, git apply does not know about the\nhash algorithm we're using, and consequently any attempt to apply a\npatch using SHA-256 will fail, since the object ID is the wrong length.\n\nThe reason we set the GIT_DIR environment variable is because we don't\nwant to modify the index; we just want to know whether the patch\napplies.  Instead, let's just use a temporary file for the index, which\nwill be cleaned up automatically when the object goes out of scope.\n\nAdditionally, read the configuration for the repository and compute the\nlength of an object ID based on it.  Use that when matching object IDs\nwith a regex or computing the all-zeros object ID.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n git-cvsexportcommit.perl | 14 +++++++++-----\n 1 file changed, 9 insertions(+), 5 deletions(-)\n\ndiff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl\nindex fc00d5946a..6483d792d3 100755\n--- a/git-cvsexportcommit.perl\n+++ b/git-cvsexportcommit.perl\n@@ -22,6 +22,10 @@\n my $repo = Git->repository();\n $opt_w = $repo->config('cvsexportcommit.cvsdir') unless defined $opt_w;\n \n+my $tmpdir = File::Temp->newdir;\n+my $hash_algo = $repo->config('extensions.objectformat') || 'sha1';\n+my $hexsz = $hash_algo eq 'sha256' ? 64 : 40;\n+\n if ($opt_w || $opt_W) {\n \t# Remember where GIT_DIR is before changing to CVS checkout\n \tunless ($ENV{GIT_DIR}) {\n@@ -96,7 +100,7 @@\n     }\n \n     if ($stage eq 'headers') {\n-\tif ($line =~ m/^parent (\\w{40})$/) { # found a parent\n+\tif ($line =~ m/^parent ([0-9a-f]{$hexsz})$/) { # found a parent\n \t    push @parents, $1;\n \t} elsif ($line =~ m/^author (.+) \\d+ [-+]\\d+$/) {\n \t    $author = $1;\n@@ -111,7 +115,7 @@\n     }\n }\n \n-my $noparent = \"0000000000000000000000000000000000000000\";\n+my $noparent = \"0\" x $hexsz;\n if ($parent) {\n     my $found;\n     # double check that it's a valid parent\n@@ -174,7 +178,7 @@\n print \"Checking if patch will apply\\n\";\n \n my @stat;\n-open APPLY, \"GIT_DIR= git-apply $context --summary --numstat<.cvsexportcommit.diff|\" || die \"cannot patch\";\n+open APPLY, \"GIT_INDEX_FILE=$tmpdir/index git-apply $context --summary --numstat<.cvsexportcommit.diff|\" || die \"cannot patch\";\n @stat=<APPLY>;\n close APPLY || die \"Cannot patch\";\n my (@bfiles,@files,@afiles,@dfiles);\n@@ -329,7 +333,7 @@\n if ($opt_W) {\n     system(\"git checkout -q $commit^0\") && die \"cannot patch\";\n } else {\n-    `GIT_DIR= git-apply $context --summary --numstat --apply <.cvsexportcommit.diff` || die \"cannot patch\";\n+    `GIT_INDEX_FILE=$tmpdir/index git-apply $context --summary --numstat --apply <.cvsexportcommit.diff` || die \"cannot patch\";\n }\n \n print \"Patch applied successfully. Adding new files and directories to CVS\\n\";\n@@ -407,7 +411,7 @@\n \n if ($opt_W) {\n     system(\"git checkout $go_back_to\") && die \"cannot move back to $go_back_to\";\n-    if (!($go_back_to =~ /^[0-9a-fA-F]{40}$/)) {\n+    if (!($go_back_to =~ /^[0-9a-fA-F]{$hexsz}$/)) {\n \tsystem(\"git symbolic-ref HEAD $go_back_to\") &&\n \t    die \"cannot move back to $go_back_to\";\n     }\n"},{"id":"400299","messageId":"20200622180418.2418483-12-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200622180418.2418483-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 11/14] git-svn: set the OID length based on hash algorithm","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-22T18:04:15Z","receivedAt":"2020-06-22T18:04:39Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"When reading the configuration or when creating a new repository, load\nthe extensions.objectFormat value and set the object ID length to 64 if\nit's \"sha256\".  Note that we use the hex length in git-svn because most\nof our processing is done on hex values, not binary ones.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n git-svn.perl | 7 +++++++\n 1 file changed, 7 insertions(+)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 00276c051b..58f5a7ac8f 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -500,6 +500,7 @@ sub do_git_init_db {\n \t\tcommand_noisy('config', \"$pfx.preserve-empty-dirs\", 'true');\n \t\tcommand_noisy('config', \"$pfx.placeholder-filename\", $$fname);\n \t}\n+\tload_object_format();\n }\n \n sub init_subdir {\n@@ -1977,9 +1978,15 @@ sub read_git_config {\n \t\t\t}\n \t\t}\n \t}\n+\tload_object_format();\n \tdelete @$opts{@config_only} if @config_only;\n }\n \n+sub load_object_format {\n+\tchomp(my $hash = `git config --get extensions.objectformat`);\n+\t$::oid_length = 64 if $hash eq 'sha256';\n+}\n+\n sub extract_metadata {\n \tmy $id = shift or return (undef, undef, undef);\n \tmy ($url, $rev, $uuid) = ($id =~ /^\\s*git-svn-id:\\s+(.*)\\@(\\d+)\n"},{"id":"400300","messageId":"20200622180418.2418483-14-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200622180418.2418483-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 13/14] git-cvsimport: port to SHA-256","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-22T18:04:17Z","receivedAt":"2020-06-22T18:04:42Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Instead of calling the function is_sha1, call it is_oid and update it to\nmatch either a SHA-1 or a SHA-256 hex object ID.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n git-cvsimport.perl | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex 1057f389d3..7bf3c12d67 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -637,9 +637,9 @@ ()\n \treturn $pwd;\n }\n \n-sub is_sha1 {\n+sub is_oid {\n \tmy $s = shift;\n-\treturn $s =~ /^[a-f0-9]{40}$/;\n+\treturn $s =~ /^[a-f0-9]{40}(?:[a-f0-9]{24})?$/;\n }\n \n sub get_headref ($) {\n@@ -810,7 +810,7 @@ ()\n \topen(my $fh, '-|', qw(git write-tree))\n \t\tor die \"unable to open git write-tree: $!\";\n \tchomp(my $tree = <$fh>);\n-\tis_sha1($tree)\n+\tis_oid($tree)\n \t\tor die \"Cannot get tree id ($tree): $!\";\n \tclose($fh)\n \t\tor die \"Error running git write-tree: $?\\n\";\n@@ -896,7 +896,7 @@ sub commit {\n \n \tprint \"Committed patch $patchset ($branch $commit_date)\\n\" if $opt_v;\n \tchomp(my $cid = <$commit_read>);\n-\tis_sha1($cid) or die \"Cannot get commit id ($cid): $!\\n\";\n+\tis_oid($cid) or die \"Cannot get commit id ($cid): $!\\n\";\n \tprint \"Commit ID $cid\\n\" if $opt_v;\n \tclose($commit_read);\n \n"},{"id":"400301","messageId":"20200622180418.2418483-6-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200622180418.2418483-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 05/14] t9104: make hash size independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-22T18:04:09Z","receivedAt":"2020-06-22T18:04:43Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"The size of a record in the database used by git svn is four bytes plus\nthe length of the binary hash.  Instead of hard-coding 24, compute this\nvalue based on the size of the hash in use.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t9104-git-svn-follow-parent.sh | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh\nindex 5e0ad19177..67eed2fefc 100755\n--- a/t/t9104-git-svn-follow-parent.sh\n+++ b/t/t9104-git-svn-follow-parent.sh\n@@ -161,6 +161,7 @@ test_expect_success \"track initial change if it was only made to parent\" '\n \t'\n \n test_expect_success \"follow-parent is atomic\" '\n+\trecord_size=$(($(test_oid rawsz) + 4)) &&\n \t(\n \t\tcd wc &&\n \t\tsvn_cmd up &&\n@@ -186,7 +187,7 @@ test_expect_success \"follow-parent is atomic\" '\n \tmkdir -p \"$GIT_DIR\"/svn/refs/remotes/flunk@18 &&\n \trev_map=$(cd \"$GIT_DIR\"/svn/refs/remotes/stunk && ls .rev_map*) &&\n \tdd if=\"$GIT_DIR\"/svn/refs/remotes/stunk/$rev_map \\\n-\t   of=\"$GIT_DIR\"/svn/refs/remotes/flunk@18/$rev_map bs=24 count=1 &&\n+\t   of=\"$GIT_DIR\"/svn/refs/remotes/flunk@18/$rev_map bs=$record_size count=1 &&\n \trm -rf \"$GIT_DIR\"/svn/refs/remotes/stunk &&\n \tgit svn init --minimize-url -i flunk \"$svnrepo\"/flunk &&\n \tgit svn fetch -i flunk &&\n"},{"id":"400302","messageId":"20200622180418.2418483-13-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200622180418.2418483-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 12/14] git-cvsserver: port to SHA-256","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-22T18:04:16Z","receivedAt":"2020-06-22T18:04:44Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"The code of git-cvsserver currently has several hard-coded 20 and 40\nconstants that are the length of SHA-1.  When parsing the configuration\nfile, read the extensions.objectformat configuration setting as well as\nCVS-related ones and adjust the hash sizes accordingly.  Use these\ncomputed values in all the places we match object IDs.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n git-cvsserver.perl | 37 ++++++++++++++++++++-----------------\n 1 file changed, 20 insertions(+), 17 deletions(-)\n\ndiff --git a/git-cvsserver.perl b/git-cvsserver.perl\nindex ae1044273d..f6f3fc192c 100755\n--- a/git-cvsserver.perl\n+++ b/git-cvsserver.perl\n@@ -365,7 +365,7 @@ sub req_Root\n     }\n     foreach my $line ( @gitvars )\n     {\n-        next unless ( $line =~ /^(gitcvs)\\.(?:(ext|pserver)\\.)?([\\w-]+)=(.*)$/ );\n+        next unless ( $line =~ /^(gitcvs|extensions)\\.(?:(ext|pserver)\\.)?([\\w-]+)=(.*)$/ );\n         unless ($2) {\n             $cfg->{$1}{$3} = $4;\n         } else {\n@@ -392,6 +392,9 @@ sub req_Root\n         $log->nofile();\n     }\n \n+    $state->{rawsz} = ($cfg->{'extensions'}{'objectformat'} || 'sha1') eq 'sha256' ? 32 : 20;\n+    $state->{hexsz} = $state->{rawsz} * 2;\n+\n     return 1;\n }\n \n@@ -1581,7 +1584,7 @@ sub req_ci\n \n             $parenthash = safe_pipe_capture('git', 'show-ref', '-s', $branchRef);\n             chomp $parenthash;\n-            if ($parenthash !~ /^[0-9a-f]{40}$/)\n+            if ($parenthash !~ /^[0-9a-f]{$state->{hexsz}}$/)\n             {\n                 if ( defined($stickyInfo) && defined($stickyInfo->{tag}) )\n                 {\n@@ -1708,7 +1711,7 @@ sub req_ci\n     chomp($commithash);\n     $log->info(\"Commit hash : $commithash\");\n \n-    unless ( $commithash =~ /[a-zA-Z0-9]{40}/ )\n+    unless ( $commithash =~ /[a-zA-Z0-9]{$state->{hexsz}}/ )\n     {\n         $log->warn(\"Commit failed (Invalid commit hash)\");\n         print \"error 1 Commit failed (unknown reason)\\n\";\n@@ -2375,7 +2378,7 @@ sub req_annotate\n         print \"E ***************\\n\";\n         while ( <ANNOTATE> )\n         {\n-            if (m/^([a-zA-Z0-9]{40})\\t\\([^\\)]*\\)(.*)$/i)\n+            if (m/^([a-zA-Z0-9]{$state->{hexsz}})\\t\\([^\\)]*\\)(.*)$/i)\n             {\n                 my $commithash = $1;\n                 my $data = $2;\n@@ -2852,7 +2855,7 @@ sub transmitfile\n         return;\n     }\n \n-    die \"Need filehash\" unless ( defined ( $filehash ) and $filehash =~ /^[a-zA-Z0-9]{40}$/ );\n+    die \"Need filehash\" unless ( defined ( $filehash ) and $filehash =~ /^[a-zA-Z0-9]{$state->{hexsz}}$/ );\n \n     my $type = safe_pipe_capture('git', 'cat-file', '-t', $filehash);\n     chomp $type;\n@@ -3042,7 +3045,7 @@ sub ensureWorkTree\n \n     my $ver = safe_pipe_capture('git', 'show-ref', '-s', \"refs/heads/$state->{module}\");\n     chomp $ver;\n-    if ($ver !~ /^[0-9a-f]{40}$/)\n+    if ($ver !~ /^[0-9a-f]{$state->{hexsz}}$/)\n     {\n         $log->warn(\"Error from git show-ref -s refs/head$state->{module}\");\n         print \"error 1 cannot find the current HEAD of module\";\n@@ -3281,7 +3284,7 @@ sub open_blob_or_die\n     }\n     elsif( $srcType eq \"sha1\" )\n     {\n-        unless ( defined ( $name ) and $name =~ /^[a-zA-Z0-9]{40}$/ )\n+        unless ( defined ( $name ) and $name =~ /^[a-zA-Z0-9]{$state->{hexsz}}$/ )\n         {\n             $log->warn(\"Need filehash\");\n             die \"Need filehash\\n\";\n@@ -3817,7 +3820,7 @@ sub update\n     chomp $commitsha1;\n \n     my $commitinfo = ::safe_pipe_capture('git', 'cat-file', 'commit', $self->{module});\n-    unless ( $commitinfo =~ /tree\\s+[a-zA-Z0-9]{40}/ )\n+    unless ( $commitinfo =~ /tree\\s+[a-zA-Z0-9]{$state->{hexsz}}/ )\n     {\n         die(\"Invalid module '$self->{module}'\");\n     }\n@@ -3957,7 +3960,7 @@ sub update\n             while ( <FILELIST> )\n             {\n \t\tchomp;\n-                unless ( /^:\\d{6}\\s+([0-7]{6})\\s+[a-f0-9]{40}\\s+([a-f0-9]{40})\\s+(\\w)$/o )\n+                unless ( /^:\\d{6}\\s+([0-7]{6})\\s+[a-f0-9]{$state->{hexsz}}\\s+([a-f0-9]{$state->{hexsz}})\\s+(\\w)$/o )\n                 {\n                     die(\"Couldn't process git-diff-tree line : $_\");\n                 }\n@@ -4625,11 +4628,11 @@ sub getmeta\n             $db_query->execute($filename, $intRev);\n             $meta = $db_query->fetchrow_hashref;\n         }\n-        elsif ( $revision =~ /^2\\.1\\.1\\.2000(\\.[1-3][0-9][0-9]){20}$/ )\n+        elsif ( $revision =~ /^2\\.1\\.1\\.2000(\\.[1-3][0-9][0-9]){$state->{rawsz}}$/ )\n         {\n             my ($commitHash)=($revision=~/^2\\.1\\.1\\.2000(.*)$/);\n             $commitHash=~s/\\.([0-9]+)/sprintf(\"%02x\",$1-100)/eg;\n-            if($commitHash=~/^[0-9a-f]{40}$/)\n+            if($commitHash=~/^[0-9a-f]{$state->{hexsz}}$/)\n             {\n                 return $self->getMetaFromCommithash($filename,$commitHash);\n             }\n@@ -4639,7 +4642,7 @@ sub getmeta\n             $log->warning(\"failed get $revision with commithash=$commitHash\");\n             undef $revision;\n         }\n-        elsif ( $revision =~ /^[0-9a-f]{40}$/ )\n+        elsif ( $revision =~ /^[0-9a-f]{$state->{hexsz}}$/ )\n         {\n             # Try DB first.  This is mostly only useful for req_annotate(),\n             # which only calls this for stuff that should already be in\n@@ -4658,7 +4661,7 @@ sub getmeta\n             if(! $meta)\n             {\n                 my($revCommit)=$self->lookupCommitRef($revision);\n-                if($revCommit=~/^[0-9a-f]{40}$/)\n+                if($revCommit=~/^[0-9a-f]{$state->{hexsz}}$/)\n                 {\n                     return $self->getMetaFromCommithash($filename,$revCommit);\n                 }\n@@ -4672,7 +4675,7 @@ sub getmeta\n         else\n         {\n             my($revCommit)=$self->lookupCommitRef($revision);\n-            if($revCommit=~/^[0-9a-f]{40}$/)\n+            if($revCommit=~/^[0-9a-f]{$state->{hexsz}}$/)\n             {\n                 return $self->getMetaFromCommithash($filename,$revCommit);\n             }\n@@ -4767,7 +4770,7 @@ sub getMetaFromCommithash\n \n     my($fileHash) = ::safe_pipe_capture(\"git\",\"rev-parse\",\"$revCommit:$filename\");\n     chomp $fileHash;\n-    if(!($fileHash=~/^[0-9a-f]{40}$/))\n+    if(!($fileHash=~/^[0-9a-f]{$state->{hexsz}}$/))\n     {\n         die \"Invalid fileHash '$fileHash' looking up\"\n                     .\" '$revCommit:$filename'\\n\";\n@@ -4863,7 +4866,7 @@ sub lookupCommitRef\n     $commitHash = ::safe_pipe_capture(\"git\",\"rev-parse\",\"--verify\",\"--quiet\",\n \t\t\t\t      $self->unescapeRefName($ref));\n     $commitHash=~s/\\s*$//;\n-    if(!($commitHash=~/^[0-9a-f]{40}$/))\n+    if(!($commitHash=~/^[0-9a-f]{$state->{hexsz}}$/))\n     {\n         $commitHash=undef;\n     }\n@@ -4909,7 +4912,7 @@ sub commitmessage\n     my $commithash = shift;\n     my $tablename = $self->tablename(\"commitmsgs\");\n \n-    die(\"Need commithash\") unless ( defined($commithash) and $commithash =~ /^[a-zA-Z0-9]{40}$/ );\n+    die(\"Need commithash\") unless ( defined($commithash) and $commithash =~ /^[a-zA-Z0-9]{$state->{hexsz}}$/ );\n \n     my $db_query;\n     $db_query = $self->{dbh}->prepare_cached(\"SELECT value FROM $tablename WHERE key=?\",{},1);\n"},{"id":"400303","messageId":"20200622180418.2418483-7-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200622180418.2418483-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 06/14] t9101: make hash independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-22T18:04:10Z","receivedAt":"2020-06-22T18:05:00Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Instead of hard-coding the object ID for our test .gitignore file, let's\ncompute it.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t9101-git-svn-props.sh | 12 +++++++-----\n 1 file changed, 7 insertions(+), 5 deletions(-)\n\ndiff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh\nindex c26c4b0927..8b5681dd68 100755\n--- a/t/t9101-git-svn-props.sh\n+++ b/t/t9101-git-svn-props.sh\n@@ -160,11 +160,13 @@ cat >create-ignore.expect <<\\EOF\n /no-such-file*\n EOF\n \n-cat >create-ignore-index.expect <<\\EOF\n-100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0\t.gitignore\n-100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0\tdeeply/.gitignore\n-100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0\tdeeply/nested/.gitignore\n-100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0\tdeeply/nested/directory/.gitignore\n+expectoid=$(git hash-object create-ignore.expect)\n+\n+cat >create-ignore-index.expect <<EOF\n+100644 $expectoid 0\t.gitignore\n+100644 $expectoid 0\tdeeply/.gitignore\n+100644 $expectoid 0\tdeeply/nested/.gitignore\n+100644 $expectoid 0\tdeeply/nested/directory/.gitignore\n EOF\n \n test_expect_success 'test create-ignore' \"\n"},{"id":"400304","messageId":"20200622180418.2418483-11-sandals@crustytoothpaste.net","threadId":"53722","inReplyTo":"20200622180418.2418483-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 10/14] perl: make SVN code hash independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-06-22T18:04:14Z","receivedAt":"2020-06-22T18:05:03Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"There are several places throughout git-svn that use various hard-coded\nconstants.  For matching object IDs, use the $oid variable.  Compute the\nrecord size we use for our revision storage based on the object ID.\n\nWhen parsing the revision map format, use a wildcard in the pack format\nsince we know that the data we're parsing is always exactly the record\nsize.  This lets us continue to use a constant for the pack format.\n\nFinally, update several comments to reflect the fact that an object ID\nmay be of one of multiple sizes.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n git-svn.perl            |  4 +--\n perl/Git/SVN.pm         | 73 +++++++++++++++++++++--------------------\n perl/Git/SVN/Editor.pm  |  6 ++--\n perl/Git/SVN/Fetcher.pm |  6 ++--\n perl/Git/SVN/Ra.pm      |  4 +--\n 5 files changed, 48 insertions(+), 45 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 7c735cebd3..00276c051b 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -2008,10 +2008,10 @@ sub cmt_sha2rev_batch {\n \t\tprint $out $sha, \"\\n\";\n \n \t\twhile (my $line = <$in>) {\n-\t\t\tif ($first && $line =~ /^[[:xdigit:]]{40}\\smissing$/) {\n+\t\t\tif ($first && $line =~ /^$::oid\\smissing$/) {\n \t\t\t\tlast;\n \t\t\t} elsif ($first &&\n-\t\t\t       $line =~ /^[[:xdigit:]]{40}\\scommit\\s(\\d+)$/) {\n+\t\t\t       $line =~ /^$::oid\\scommit\\s(\\d+)$/) {\n \t\t\t\t$first = 0;\n \t\t\t\t$size = $1;\n \t\t\t\tnext;\ndiff --git a/perl/Git/SVN.pm b/perl/Git/SVN.pm\nindex fcf1e3bb5e..d1c352f92b 100644\n--- a/perl/Git/SVN.pm\n+++ b/perl/Git/SVN.pm\n@@ -2,7 +2,7 @@ package Git::SVN;\n use strict;\n use warnings;\n use Fcntl qw/:DEFAULT :seek/;\n-use constant rev_map_fmt => 'NH40';\n+use constant rev_map_fmt => 'NH*';\n use vars qw/$_no_metadata\n             $_repack $_repack_flags $_use_svm_props $_head\n             $_use_svnsync_props $no_reuse_existing\n@@ -2087,10 +2087,10 @@ sub rebuild_from_rev_db {\n \topen my $fh, '<', $path or croak \"open: $!\";\n \tbinmode $fh or croak \"binmode: $!\";\n \twhile (<$fh>) {\n-\t\tlength($_) == 41 or croak \"inconsistent size in ($_) != 41\";\n+\t\tlength($_) == $::oid_length + 1 or croak \"inconsistent size in ($_)\";\n \t\tchomp($_);\n \t\t++$r;\n-\t\tnext if $_ eq ('0' x 40);\n+\t\tnext if $_ eq ('0' x $::oid_length);\n \t\t$self->rev_map_set($r, $_);\n \t\tprint \"r$r = $_\\n\";\n \t}\n@@ -2196,9 +2196,9 @@ sub rebuild {\n # (mainly tags)\n #\n # The format is this:\n-#   - 24 bytes for every record,\n+#   - 24 or 36 bytes for every record,\n #     * 4 bytes for the integer representing an SVN revision number\n-#     * 20 bytes representing the sha1 of a git commit\n+#     * 20 or 32 bytes representing the oid of a git commit\n #   - No empty padding records like the old format\n #     (except the last record, which can be overwritten)\n #   - new records are written append-only since SVN revision numbers\n@@ -2207,7 +2207,7 @@ sub rebuild {\n #   - Piping the file to xxd -c24 is a good way of dumping it for\n #     viewing or editing (piped back through xxd -r), should the need\n #     ever arise.\n-#   - The last record can be padding revision with an all-zero sha1\n+#   - The last record can be padding revision with an all-zero oid\n #     This is used to optimize fetch performance when using multiple\n #     \"fetch\" directives in .git/config\n #\n@@ -2215,38 +2215,39 @@ sub rebuild {\n \n sub _rev_map_set {\n \tmy ($fh, $rev, $commit) = @_;\n+\tmy $record_size = ($::oid_length / 2) + 4;\n \n \tbinmode $fh or croak \"binmode: $!\";\n \tmy $size = (stat($fh))[7];\n-\t($size % 24) == 0 or croak \"inconsistent size: $size\";\n+\t($size % $record_size) == 0 or croak \"inconsistent size: $size\";\n \n \tmy $wr_offset = 0;\n \tif ($size > 0) {\n-\t\tsysseek($fh, -24, SEEK_END) or croak \"seek: $!\";\n-\t\tmy $read = sysread($fh, my $buf, 24) or croak \"read: $!\";\n-\t\t$read == 24 or croak \"read only $read bytes (!= 24)\";\n+\t\tsysseek($fh, -$record_size, SEEK_END) or croak \"seek: $!\";\n+\t\tmy $read = sysread($fh, my $buf, $record_size) or croak \"read: $!\";\n+\t\t$read == $record_size or croak \"read only $read bytes (!= $record_size)\";\n \t\tmy ($last_rev, $last_commit) = unpack(rev_map_fmt, $buf);\n-\t\tif ($last_commit eq ('0' x40)) {\n-\t\t\tif ($size >= 48) {\n-\t\t\t\tsysseek($fh, -48, SEEK_END) or croak \"seek: $!\";\n-\t\t\t\t$read = sysread($fh, $buf, 24) or\n+\t\tif ($last_commit eq ('0' x $::oid_length)) {\n+\t\t\tif ($size >= ($record_size * 2)) {\n+\t\t\t\tsysseek($fh, -($record_size * 2), SEEK_END) or croak \"seek: $!\";\n+\t\t\t\t$read = sysread($fh, $buf, $record_size) or\n \t\t\t\t    croak \"read: $!\";\n-\t\t\t\t$read == 24 or\n-\t\t\t\t    croak \"read only $read bytes (!= 24)\";\n+\t\t\t\t$read == $record_size or\n+\t\t\t\t    croak \"read only $read bytes (!= $record_size)\";\n \t\t\t\t($last_rev, $last_commit) =\n \t\t\t\t    unpack(rev_map_fmt, $buf);\n-\t\t\t\tif ($last_commit eq ('0' x40)) {\n+\t\t\t\tif ($last_commit eq ('0' x $::oid_length)) {\n \t\t\t\t\tcroak \"inconsistent .rev_map\\n\";\n \t\t\t\t}\n \t\t\t}\n \t\t\tif ($last_rev >= $rev) {\n \t\t\t\tcroak \"last_rev is higher!: $last_rev >= $rev\";\n \t\t\t}\n-\t\t\t$wr_offset = -24;\n+\t\t\t$wr_offset = -$record_size;\n \t\t}\n \t}\n \tsysseek($fh, $wr_offset, SEEK_END) or croak \"seek: $!\";\n-\tsyswrite($fh, pack(rev_map_fmt, $rev, $commit), 24) == 24 or\n+\tsyswrite($fh, pack(rev_map_fmt, $rev, $commit), $record_size) == $record_size or\n \t  croak \"write: $!\";\n }\n \n@@ -2271,7 +2272,7 @@ sub mkfile {\n sub rev_map_set {\n \tmy ($self, $rev, $commit, $update_ref, $uuid) = @_;\n \tdefined $commit or die \"missing arg3\\n\";\n-\tlength $commit == 40 or die \"arg3 must be a full SHA1 hexsum\\n\";\n+\t$commit =~ /^$::oid$/ or die \"arg3 must be a full hex object ID\\n\";\n \tmy $db = $self->map_path($uuid);\n \tmy $db_lock = \"$db.lock\";\n \tmy $sigmask;\n@@ -2344,29 +2345,30 @@ sub rev_map_max {\n \n sub rev_map_max_norebuild {\n \tmy ($self, $want_commit) = @_;\n+\tmy $record_size = ($::oid_length / 2) + 4;\n \tmy $map_path = $self->map_path;\n \tstat $map_path or return $want_commit ? (0, undef) : 0;\n \tsysopen(my $fh, $map_path, O_RDONLY) or croak \"open: $!\";\n \tbinmode $fh or croak \"binmode: $!\";\n \tmy $size = (stat($fh))[7];\n-\t($size % 24) == 0 or croak \"inconsistent size: $size\";\n+\t($size % $record_size) == 0 or croak \"inconsistent size: $size\";\n \n \tif ($size == 0) {\n \t\tclose $fh or croak \"close: $!\";\n \t\treturn $want_commit ? (0, undef) : 0;\n \t}\n \n-\tsysseek($fh, -24, SEEK_END) or croak \"seek: $!\";\n-\tsysread($fh, my $buf, 24) == 24 or croak \"read: $!\";\n+\tsysseek($fh, -$record_size, SEEK_END) or croak \"seek: $!\";\n+\tsysread($fh, my $buf, $record_size) == $record_size or croak \"read: $!\";\n \tmy ($r, $c) = unpack(rev_map_fmt, $buf);\n-\tif ($want_commit && $c eq ('0' x40)) {\n-\t\tif ($size < 48) {\n+\tif ($want_commit && $c eq ('0' x $::oid_length)) {\n+\t\tif ($size < $record_size * 2) {\n \t\t\treturn $want_commit ? (0, undef) : 0;\n \t\t}\n-\t\tsysseek($fh, -48, SEEK_END) or croak \"seek: $!\";\n-\t\tsysread($fh, $buf, 24) == 24 or croak \"read: $!\";\n+\t\tsysseek($fh, -($record_size * 2), SEEK_END) or croak \"seek: $!\";\n+\t\tsysread($fh, $buf, $record_size) == $record_size or croak \"read: $!\";\n \t\t($r, $c) = unpack(rev_map_fmt, $buf);\n-\t\tif ($c eq ('0'x40)) {\n+\t\tif ($c eq ('0' x $::oid_length)) {\n \t\t\tcroak \"Penultimate record is all-zeroes in $map_path\";\n \t\t}\n \t}\n@@ -2387,30 +2389,31 @@ sub rev_map_get {\n \n sub _rev_map_get {\n \tmy ($fh, $rev) = @_;\n+\tmy $record_size = ($::oid_length / 2) + 4;\n \n \tbinmode $fh or croak \"binmode: $!\";\n \tmy $size = (stat($fh))[7];\n-\t($size % 24) == 0 or croak \"inconsistent size: $size\";\n+\t($size % $record_size) == 0 or croak \"inconsistent size: $size\";\n \n \tif ($size == 0) {\n \t\treturn undef;\n \t}\n \n-\tmy ($l, $u) = (0, $size - 24);\n+\tmy ($l, $u) = (0, $size - $record_size);\n \tmy ($r, $c, $buf);\n \n \twhile ($l <= $u) {\n-\t\tmy $i = int(($l/24 + $u/24) / 2) * 24;\n+\t\tmy $i = int(($l/$record_size + $u/$record_size) / 2) * $record_size;\n \t\tsysseek($fh, $i, SEEK_SET) or croak \"seek: $!\";\n-\t\tsysread($fh, my $buf, 24) == 24 or croak \"read: $!\";\n+\t\tsysread($fh, my $buf, $record_size) == $record_size or croak \"read: $!\";\n \t\tmy ($r, $c) = unpack(rev_map_fmt, $buf);\n \n \t\tif ($r < $rev) {\n-\t\t\t$l = $i + 24;\n+\t\t\t$l = $i + $record_size;\n \t\t} elsif ($r > $rev) {\n-\t\t\t$u = $i - 24;\n+\t\t\t$u = $i - $record_size;\n \t\t} else { # $r == $rev\n-\t\t\treturn $c eq ('0' x 40) ? undef : $c;\n+\t\t\treturn $c eq ('0' x $::oid_length) ? undef : $c;\n \t\t}\n \t}\n \tundef;\ndiff --git a/perl/Git/SVN/Editor.pm b/perl/Git/SVN/Editor.pm\nindex 70b6d78cd9..c961444d4c 100644\n--- a/perl/Git/SVN/Editor.pm\n+++ b/perl/Git/SVN/Editor.pm\n@@ -400,12 +400,12 @@ sub T {\n \t    ($m->{mode_b} !~ /^120/ && $m->{mode_a} =~ /^120/)) {\n \t\t$self->D({\n \t\t\tmode_a => $m->{mode_a}, mode_b => '000000',\n-\t\t\tsha1_a => $m->{sha1_a}, sha1_b => '0' x 40,\n+\t\t\tsha1_a => $m->{sha1_a}, sha1_b => '0' x $::oid_length,\n \t\t\tchg => 'D', file_b => $m->{file_b}\n \t\t}, $deletions);\n \t\t$self->A({\n \t\t\tmode_a => '000000', mode_b => $m->{mode_b},\n-\t\t\tsha1_a => '0' x 40, sha1_b => $m->{sha1_b},\n+\t\t\tsha1_a => '0' x $::oid_length, sha1_b => $m->{sha1_b},\n \t\t\tchg => 'A', file_b => $m->{file_b}\n \t\t}, $deletions);\n \t\treturn;\n@@ -434,7 +434,7 @@ ($$$$)\n \t\t$self->change_file_prop($fbat,'svn:special',undef);\n \t}\n \tmy $blob = $m->{\"sha1_$which\"};\n-\treturn ($fh,) if ($blob =~ /^0{40}$/);\n+\treturn ($fh,) if ($blob =~ /^0+$/);\n \tmy $size = $::_repository->cat_blob($blob, $fh);\n \tcroak \"Failed to read object $blob\" if ($size < 0);\n \t$fh->flush == 0 or croak $!;\ndiff --git a/perl/Git/SVN/Fetcher.pm b/perl/Git/SVN/Fetcher.pm\nindex 64e900a0e9..729e5337df 100644\n--- a/perl/Git/SVN/Fetcher.pm\n+++ b/perl/Git/SVN/Fetcher.pm\n@@ -173,7 +173,7 @@ sub delete_entry {\n \n \t# remove entire directories.\n \tmy ($tree) = (command('ls-tree', '-z', $self->{c}, \"./$gpath\")\n-\t                 =~ /\\A040000 tree ([a-f\\d]{40})\\t\\Q$gpath\\E\\0/);\n+\t                 =~ /\\A040000 tree ($::oid)\\t\\Q$gpath\\E\\0/);\n \tif ($tree) {\n \t\tmy ($ls, $ctx) = command_output_pipe(qw/ls-tree\n \t\t                                     -r --name-only -z/,\n@@ -203,7 +203,7 @@ sub open_file {\n \n \tmy $gpath = $self->git_path($path);\n \t($mode, $blob) = (command('ls-tree', '-z', $self->{c}, \"./$gpath\")\n-\t                     =~ /\\A(\\d{6}) blob ([a-f\\d]{40})\\t\\Q$gpath\\E\\0/);\n+\t                     =~ /\\A(\\d{6}) blob ($::oid)\\t\\Q$gpath\\E\\0/);\n \tunless (defined $mode && defined $blob) {\n \t\tdie \"$path was not found in commit $self->{c} (r$rev)\\n\";\n \t}\n@@ -413,7 +413,7 @@ sub close_file {\n \n \t\t$hash = $::_repository->hash_and_insert_object(\n \t\t\t\tGit::temp_path($fh));\n-\t\t$hash =~ /^[a-f\\d]{40}$/ or die \"not a sha1: $hash\\n\";\n+\t\t$hash =~ /^$::oid$/ or die \"not an object ID: $hash\\n\";\n \n \t\tGit::temp_release($fb->{base}, 1);\n \t\tGit::temp_release($fh, 1);\ndiff --git a/perl/Git/SVN/Ra.pm b/perl/Git/SVN/Ra.pm\nindex 56ad9870bc..2cfe055a9a 100644\n--- a/perl/Git/SVN/Ra.pm\n+++ b/perl/Git/SVN/Ra.pm\n@@ -486,11 +486,11 @@ sub gs_fetch_loop_common {\n \t\t\t$reload_ra->() if $ra_invalid;\n \t\t}\n \t\t# pre-fill the .rev_db since it'll eventually get filled in\n-\t\t# with '0' x40 if something new gets committed\n+\t\t# with '0' x $oid_length if something new gets committed\n \t\tforeach my $gs (@$gsv) {\n \t\t\tnext if $gs->rev_map_max >= $max;\n \t\t\tnext if defined $gs->rev_map_get($max);\n-\t\t\t$gs->rev_map_set($max, 0 x40);\n+\t\t\t$gs->rev_map_set($max, 0 x $::oid_length);\n \t\t}\n \t\tforeach my $g (@$globs) {\n \t\t\tmy $k = \"svn-remote.$g->{remote}.$g->{t}-maxRev\";\n"},{"id":"402718","messageId":"87zh7bo9so.fsf@igel.home","threadId":"53722","inReplyTo":"20200622180418.2418483-15-sandals@crustytoothpaste.net","subject":"Re: [PATCH v2 14/14] git-cvsexportcommit: port to SHA-256","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2020-08-03T18:37:27Z","receivedAt":"2020-08-03T18:37:33Z","isPatch":true,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"On Jun 22 2020, brian m. carlson wrote:\n\n> diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl\n> index fc00d5946a..6483d792d3 100755\n> --- a/git-cvsexportcommit.perl\n> +++ b/git-cvsexportcommit.perl\n> @@ -22,6 +22,10 @@\n>  my $repo = Git->repository();\n>  $opt_w = $repo->config('cvsexportcommit.cvsdir') unless defined $opt_w;\n>  \n> +my $tmpdir = File::Temp->newdir;\n\nFile::Temp in perl 5.10 doesn't have the newdir method.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1\n\"And now for something completely different.\"\n"},{"id":"402767","messageId":"20200803235007.GN6540@camp.crustytoothpaste.net","threadId":"53722","inReplyTo":"87zh7bo9so.fsf@igel.home","subject":"Re: [PATCH v2 14/14] git-cvsexportcommit: port to SHA-256","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-08-03T23:50:07Z","receivedAt":"2020-08-03T23:50:47Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2020-08-03 at 18:37:27, Andreas Schwab wrote:\n> On Jun 22 2020, brian m. carlson wrote:\n> \n> > diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl\n> > index fc00d5946a..6483d792d3 100755\n> > --- a/git-cvsexportcommit.perl\n> > +++ b/git-cvsexportcommit.perl\n> > @@ -22,6 +22,10 @@\n> >  my $repo = Git->repository();\n> >  $opt_w = $repo->config('cvsexportcommit.cvsdir') unless defined $opt_w;\n> >  \n> > +my $tmpdir = File::Temp->newdir;\n> \n> File::Temp in perl 5.10 doesn't have the newdir method.\n\nThat method was added in File::Temp 0.19, which was added in 2007.  Does\n\n  my $tmpdir = File::Temp::tempdir(CLEANUP => 1);\n\ndo the right thing on your Perl 5.10?  I no longer use CentOS 6 at work\nand it won't run in Docker on modern Debian, so I can't test.  If so,\nI'll send a patch.\n\nFor the record, I plan to propose that we drop support for Perl versions\nearlier than 5.14 on December 2, since CentOS 6 will be dead at that\npoint.  I think a ten-year lifespan for an OS is quite generous and\nwe're still considering Perl 5.8.8, which nobody is publicly supporting\nanymore.\n-- \nbrian m. carlson: Houston, Texas, US\n"},{"id":"402771","messageId":"20200804001315.GA4899@dcvr","threadId":"53722","inReplyTo":"20200803235007.GN6540@camp.crustytoothpaste.net","subject":"Re: [PATCH v2 14/14] git-cvsexportcommit: port to SHA-256","fromName":"Eric Wong","fromEmail":"e@80x24.org","sentAt":"2020-08-04T00:13:26Z","receivedAt":"2020-08-04T00:13:29Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"\"brian m. carlson\" <sandals@crustytoothpaste.net> wrote:\n> On 2020-08-03 at 18:37:27, Andreas Schwab wrote:\n> > On Jun 22 2020, brian m. carlson wrote:\n> > \n> > > diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl\n> > > index fc00d5946a..6483d792d3 100755\n> > > --- a/git-cvsexportcommit.perl\n> > > +++ b/git-cvsexportcommit.perl\n> > > @@ -22,6 +22,10 @@\n> > >  my $repo = Git->repository();\n> > >  $opt_w = $repo->config('cvsexportcommit.cvsdir') unless defined $opt_w;\n> > >  \n> > > +my $tmpdir = File::Temp->newdir;\n> > \n> > File::Temp in perl 5.10 doesn't have the newdir method.\n> \n> That method was added in File::Temp 0.19, which was added in 2007.  Does\n\n5.10.0 doesn't have ->newdir, but 5.10.1 does.  I figure nobody\nused 5.10.0 anymore since 5.10.1 exists and (IIRC) fixed many\nthings wrong in 5.10.0.\n\n>   my $tmpdir = File::Temp::tempdir(CLEANUP => 1);\n> \n> do the right thing on your Perl 5.10?  I no longer use CentOS 6 at work\n> and it won't run in Docker on modern Debian, so I can't test.  If so,\n> I'll send a patch.\n\nI haven't touched CentOS 6 in several years, either.  I've been\ntesting public-inbox against 5.10.1 built using patches from\nDevel::PatchPerl (libdevel-patchperl-perl in Debian)\n\n> For the record, I plan to propose that we drop support for Perl versions\n> earlier than 5.14 on December 2, since CentOS 6 will be dead at that\n> point.  I think a ten-year lifespan for an OS is quite generous and\n> we're still considering Perl 5.8.8, which nobody is publicly supporting\n> anymore.\n\nThat's probably fine.  I haven't looked at 5.12 and 5.14 changes\nenough to comment, but just moving rom 5.8 to 5.10.1 last year\nmade my life considerably better (e.g. `//', `//=')\n\nIn any case, it's probably a good idea to put use \"v5.$SOMETHING\"\nwith Perl 7 on the way (and Perl 8 will probably break v5 code :<)\n"},{"id":"402781","messageId":"20200804004423.GO6540@camp.crustytoothpaste.net","threadId":"53722","inReplyTo":"20200804001315.GA4899@dcvr","subject":"Re: [PATCH v2 14/14] git-cvsexportcommit: port to SHA-256","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-08-04T00:44:23Z","receivedAt":"2020-08-04T00:44:31Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2020-08-04 at 00:13:26, Eric Wong wrote:\n> \"brian m. carlson\" <sandals@crustytoothpaste.net> wrote:\n> > On 2020-08-03 at 18:37:27, Andreas Schwab wrote:\n> > > On Jun 22 2020, brian m. carlson wrote:\n> > > \n> > > > diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl\n> > > > index fc00d5946a..6483d792d3 100755\n> > > > --- a/git-cvsexportcommit.perl\n> > > > +++ b/git-cvsexportcommit.perl\n> > > > @@ -22,6 +22,10 @@\n> > > >  my $repo = Git->repository();\n> > > >  $opt_w = $repo->config('cvsexportcommit.cvsdir') unless defined $opt_w;\n> > > >  \n> > > > +my $tmpdir = File::Temp->newdir;\n> > > \n> > > File::Temp in perl 5.10 doesn't have the newdir method.\n> > \n> > That method was added in File::Temp 0.19, which was added in 2007.  Does\n> \n> 5.10.0 doesn't have ->newdir, but 5.10.1 does.  I figure nobody\n> used 5.10.0 anymore since 5.10.1 exists and (IIRC) fixed many\n> things wrong in 5.10.0.\n\nTechnically we support 5.8.8, I believe, which means this probably does\nneed to be fixed.  I'll let Andreas verify the proposed solution works\nfor him, and then send a patch.\n\n> > For the record, I plan to propose that we drop support for Perl versions\n> > earlier than 5.14 on December 2, since CentOS 6 will be dead at that\n> > point.  I think a ten-year lifespan for an OS is quite generous and\n> > we're still considering Perl 5.8.8, which nobody is publicly supporting\n> > anymore.\n> \n> That's probably fine.  I haven't looked at 5.12 and 5.14 changes\n> enough to comment, but just moving rom 5.8 to 5.10.1 last year\n> made my life considerably better (e.g. `//', `//=')\n\n5.14 has nice things like s///r:\n\n   # 5.12\n   # We have to make a copy since s/// modifies its left side.\n   my $foo = $ARGV[0];\n   $foo =~ s/a/b/;\n\n   # 5.14\n   # Now we have non-destructive substitution.\n   my $foo = $ARGV[0] =~ s/a/b/r;\n-- \nbrian m. carlson: Houston, Texas, US\n"},{"id":"402939","messageId":"878setj922.fsf@igel.home","threadId":"53722","inReplyTo":"20200803235007.GN6540@camp.crustytoothpaste.net","subject":"Re: [PATCH v2 14/14] git-cvsexportcommit: port to SHA-256","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2020-08-05T17:29:09Z","receivedAt":"2020-08-05T19:24:39Z","isPatch":true,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"On Aug 03 2020, brian m. carlson wrote:\n\n> On 2020-08-03 at 18:37:27, Andreas Schwab wrote:\n>> On Jun 22 2020, brian m. carlson wrote:\n>> \n>> > diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl\n>> > index fc00d5946a..6483d792d3 100755\n>> > --- a/git-cvsexportcommit.perl\n>> > +++ b/git-cvsexportcommit.perl\n>> > @@ -22,6 +22,10 @@\n>> >  my $repo = Git->repository();\n>> >  $opt_w = $repo->config('cvsexportcommit.cvsdir') unless defined $opt_w;\n>> >  \n>> > +my $tmpdir = File::Temp->newdir;\n>> \n>> File::Temp in perl 5.10 doesn't have the newdir method.\n>\n> That method was added in File::Temp 0.19, which was added in 2007.  Does\n>\n>   my $tmpdir = File::Temp::tempdir(CLEANUP => 1);\n>\n> do the right thing on your Perl 5.10?\n\nWith that change, the testsuite runs sucessfully.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1\n\"And now for something completely different.\"\n"}]}