contrib: avoid applying --replace-text to binary files in bfg-ish

Signed-off-by: Elijah Newren <newren@gmail.com>
This commit is contained in:
Elijah Newren 2020-06-08 19:51:21 -07:00
parent 86569ee7ac
commit b8ebda97dd

View File

@ -248,6 +248,7 @@ class BFG_ish:
# FIXME: This next line assumes the file fits in memory; though the way
# fr.Blob works we kind of have that assumption baked in elsewhere too...
contents = self.cat_file_proc.stdout.read(int(objsize))
if not any(x == b"0" for x in contents[0:8192]): # not binaries
for literal, replacement in self.replacement_rules['literals']:
contents = contents.replace(literal, replacement)
for regex, replacement in self.replacement_rules['regexes']: