summaryrefslogtreecommitdiff
path: root/perl/Git/SVN
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2020-06-22 18:04:14 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-06-22 18:21:07 (GMT)
commit94b2ee1aeeb2dbec8383118db74d5c5c0a95476f (patch)
treefb77cd9fd725cef67f1f81ceb11c069ff9a5ee25 /perl/Git/SVN
parentff508e227c881acf6016c88ddde8158664ee18e3 (diff)
downloadgit-94b2ee1aeeb2dbec8383118db74d5c5c0a95476f.zip
git-94b2ee1aeeb2dbec8383118db74d5c5c0a95476f.tar.gz
git-94b2ee1aeeb2dbec8383118db74d5c5c0a95476f.tar.bz2
perl: make SVN code hash independent
There are several places throughout git-svn that use various hard-coded constants. For matching object IDs, use the $oid variable. Compute the record size we use for our revision storage based on the object ID. When parsing the revision map format, use a wildcard in the pack format since we know that the data we're parsing is always exactly the record size. This lets us continue to use a constant for the pack format. Finally, update several comments to reflect the fact that an object ID may be of one of multiple sizes. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Acked-by: Eric Wong <e@80x24.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'perl/Git/SVN')
-rw-r--r--perl/Git/SVN/Editor.pm6
-rw-r--r--perl/Git/SVN/Fetcher.pm6
-rw-r--r--perl/Git/SVN/Ra.pm4
3 files changed, 8 insertions, 8 deletions
diff --git a/perl/Git/SVN/Editor.pm b/perl/Git/SVN/Editor.pm
index 70b6d78..c961444 100644
--- a/perl/Git/SVN/Editor.pm
+++ b/perl/Git/SVN/Editor.pm
@@ -400,12 +400,12 @@ sub T {
($m->{mode_b} !~ /^120/ && $m->{mode_a} =~ /^120/)) {
$self->D({
mode_a => $m->{mode_a}, mode_b => '000000',
- sha1_a => $m->{sha1_a}, sha1_b => '0' x 40,
+ sha1_a => $m->{sha1_a}, sha1_b => '0' x $::oid_length,
chg => 'D', file_b => $m->{file_b}
}, $deletions);
$self->A({
mode_a => '000000', mode_b => $m->{mode_b},
- sha1_a => '0' x 40, sha1_b => $m->{sha1_b},
+ sha1_a => '0' x $::oid_length, sha1_b => $m->{sha1_b},
chg => 'A', file_b => $m->{file_b}
}, $deletions);
return;
@@ -434,7 +434,7 @@ sub _chg_file_get_blob ($$$$) {
$self->change_file_prop($fbat,'svn:special',undef);
}
my $blob = $m->{"sha1_$which"};
- return ($fh,) if ($blob =~ /^0{40}$/);
+ return ($fh,) if ($blob =~ /^0+$/);
my $size = $::_repository->cat_blob($blob, $fh);
croak "Failed to read object $blob" if ($size < 0);
$fh->flush == 0 or croak $!;
diff --git a/perl/Git/SVN/Fetcher.pm b/perl/Git/SVN/Fetcher.pm
index 64e900a..729e533 100644
--- a/perl/Git/SVN/Fetcher.pm
+++ b/perl/Git/SVN/Fetcher.pm
@@ -173,7 +173,7 @@ sub delete_entry {
# remove entire directories.
my ($tree) = (command('ls-tree', '-z', $self->{c}, "./$gpath")
- =~ /\A040000 tree ([a-f\d]{40})\t\Q$gpath\E\0/);
+ =~ /\A040000 tree ($::oid)\t\Q$gpath\E\0/);
if ($tree) {
my ($ls, $ctx) = command_output_pipe(qw/ls-tree
-r --name-only -z/,
@@ -203,7 +203,7 @@ sub open_file {
my $gpath = $self->git_path($path);
($mode, $blob) = (command('ls-tree', '-z', $self->{c}, "./$gpath")
- =~ /\A(\d{6}) blob ([a-f\d]{40})\t\Q$gpath\E\0/);
+ =~ /\A(\d{6}) blob ($::oid)\t\Q$gpath\E\0/);
unless (defined $mode && defined $blob) {
die "$path was not found in commit $self->{c} (r$rev)\n";
}
@@ -413,7 +413,7 @@ sub close_file {
$hash = $::_repository->hash_and_insert_object(
Git::temp_path($fh));
- $hash =~ /^[a-f\d]{40}$/ or die "not a sha1: $hash\n";
+ $hash =~ /^$::oid$/ or die "not an object ID: $hash\n";
Git::temp_release($fb->{base}, 1);
Git::temp_release($fh, 1);
diff --git a/perl/Git/SVN/Ra.pm b/perl/Git/SVN/Ra.pm
index 56ad987..2cfe055 100644
--- a/perl/Git/SVN/Ra.pm
+++ b/perl/Git/SVN/Ra.pm
@@ -486,11 +486,11 @@ sub gs_fetch_loop_common {
$reload_ra->() if $ra_invalid;
}
# pre-fill the .rev_db since it'll eventually get filled in
- # with '0' x40 if something new gets committed
+ # with '0' x $oid_length if something new gets committed
foreach my $gs (@$gsv) {
next if $gs->rev_map_max >= $max;
next if defined $gs->rev_map_get($max);
- $gs->rev_map_set($max, 0 x40);
+ $gs->rev_map_set($max, 0 x $::oid_length);
}
foreach my $g (@$globs) {
my $k = "svn-remote.$g->{remote}.$g->{t}-maxRev";