Page MenuHomePhabricator
Paste P1799

Force source code to show diffs in Diffusion instead of binary
ActivePublic

Authored by matelich on Jun 5 2015, 9:38 PM.
diff --git a/src/parser/ArcanistDiffParser.php b/src/parser/ArcanistDiffParser.php
index 0e9627b..54da690 100644
--- a/src/parser/ArcanistDiffParser.php
+++ b/src/parser/ArcanistDiffParser.php
@@ -1020,6 +1020,16 @@ final class ArcanistDiffParser {
}
+ //For files we think are binary, double-check they're not using extensions defined as code
+ //backwards is slightly faster and way more fun
+ if($is_binary) {
+ $back_path = substr(strrev($change->getCurrentPath()), 0, 5); //5 == max of non_binary strlens
+ $reversed_non_binary_file_extensions = array("pph.","h.","php.","ppc.","lni.","sc.","lmax.","iu.");
+ foreach ($reversed_non_binary_file_extensions as $rev_ext) {
+ if(stripos($back_path, $rev_ext) === 0){
+ $is_binary = false;
+ break;
+ }
+ }
+ }
if ($is_binary) {
// SVN happily treats binary files which aren't marked with the right
// mime type as text files. Detect that junk here and mark the file

Event Timeline

matelich changed the title of this paste from untitled to Force source code to show diffs in Diffusion instead of binary.
matelich updated the paste's language from autodetect to php.