Fix staged-files-only with a non-utf8-trailing-whitespace diff. Resolves #397

This commit is contained in:
Anthony Sottile 2016-08-18 07:25:55 -07:00
parent f11338ccfa
commit b05cc4077e
2 changed files with 27 additions and 2 deletions

View file

@ -45,7 +45,7 @@ def staged_files_only(cmd_runner):
finally:
# Try to apply the patch we saved
try:
cmd_runner.run(['git', 'apply', patch_filename])
cmd_runner.run(('git', 'apply', patch_filename), encoding=None)
except CalledProcessError:
logger.warning(
'Stashed changes conflicted with hook auto-fixes... '
@ -55,7 +55,7 @@ def staged_files_only(cmd_runner):
# by hooks.
# Roll back the changes made by hooks.
cmd_runner.run(['git', 'checkout', '--', '.'])
cmd_runner.run(['git', 'apply', patch_filename])
cmd_runner.run(('git', 'apply', patch_filename), encoding=None)
logger.info('Restored changes from {0}.'.format(patch_filename))
else:
# There weren't any staged files so we don't need to do anything