]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Git.pm: make hash size independent
authorbrian m. carlson <sandals@crustytoothpaste.net>
Tue, 19 Feb 2019 00:05:25 +0000 (00:05 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 1 Apr 2019 02:57:39 +0000 (11:57 +0900)
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>
perl/Git.pm

index d856930b2e5f31bb7b1e7aef46e8e056068bb431..62c472e0ce41d507e88df86f6a022d1a08fbc4a6 100644 (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;
        }