]> scripts.mit.edu Git - wizard.git/commitdiff
Check if file is binary.
authorEdward Z. Yang <ezyang@mit.edu>
Wed, 23 Dec 2009 04:34:45 +0000 (23:34 -0500)
committerEdward Z. Yang <ezyang@mit.edu>
Wed, 23 Dec 2009 04:34:45 +0000 (23:34 -0500)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
wizard/app/__init__.py

index 1b4365e7fecd910076487457f38f6644ee9d6a41..de127369060dfa413deea9bccf1e68c211edbb22 100644 (file)
@@ -243,7 +243,8 @@ class Application(object):
             files.add(status.split()[-1])
         for file in files:
             # check for newline mismatch
-            if util.mixed_newlines(file):
+            # HACK: using git diff to tell if files are binary or not
+            if not len(sh.eval("git", "diff", file).splitlines()) == 1 and util.mixed_newlines(file):
                 # this code only works on Unix
                 def get_newline(filename):
                     f = open(filename, "U")
@@ -252,7 +253,7 @@ class Application(object):
                     if s != "" and f.newlines is None:
                         f.readline()
                     if not isinstance(f.newlines, str):
-                        raise Exception("Assert: expected newlines to be string, instead was %s" % repr(f.newlines))
+                        raise Exception("Assert: expected newlines to be string, instead was %s in %s" % (repr(f.newlines), file))
                     return f.newlines
                 def create_reference(id):
                     f = tempfile.NamedTemporaryFile(prefix="wizardResolve", delete=False)