Skip to content

Commit bcbb44b

Browse files
bk2204gitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 575fa8a commit bcbb44b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

perl/Git.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ sub cat_blob {
980980
return -1;
981981
}
982982

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

0 commit comments

Comments
 (0)