THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Browse Source

Git.pm: make hash size independent

The cat_blob function was matching on exactly 40 hex characters.  This
won't work with SHA-256, which uses 64-character hex object IDs.  While
it should be fine to simply match any number of hex characters since the
output is space delimited, be extra safe by matching either exactly 40
or exactly 64 hex characters.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
tags/v2.22.0-rc0
brian m. carlson Junio C Hamano 8 months ago
parent
commit
bcbb44ba05
1 changed files with 1 additions and 1 deletions
  1. +1
    -1
      perl/Git.pm

+ 1
- 1
perl/Git.pm View File

@@ -980,7 +980,7 @@ sub cat_blob {
return -1;
}

if ($description !~ /^[0-9a-fA-F]{40} \S+ (\d+)$/) {
if ($description !~ /^[0-9a-fA-F]{40}(?:[0-9a-fA-F]{24})? \S+ (\d+)$/) {
carp "Unexpected result returned from git cat-file";
return -1;
}

Loading…
Cancel
Save