diff --git a/pre_commit/staged_files_only.py b/pre_commit/staged_files_only.py index 9ede8032..a2978b99 100644 --- a/pre_commit/staged_files_only.py +++ b/pre_commit/staged_files_only.py @@ -21,7 +21,10 @@ def staged_files_only(cmd_runner): """ # Determine if there are unstaged files retcode, diff_stdout_binary, _ = cmd_runner.run( - ['git', 'diff', '--ignore-submodules', '--binary', '--exit-code'], + [ + 'git', 'diff', '--ignore-submodules', '--binary', '--exit-code', + '--no-color', + ], retcode=None, encoding=None, ) diff --git a/tests/staged_files_only_test.py b/tests/staged_files_only_test.py index 620d7d92..65a47120 100644 --- a/tests/staged_files_only_test.py +++ b/tests/staged_files_only_test.py @@ -70,6 +70,11 @@ def test_foo_something_unstaged(foo_staged, cmd_runner): _test_foo_state(foo_staged, 'herp\nderp\n', 'AM') +def test_foo_something_unstaged_diff_color_always(foo_staged, cmd_runner): + cmd_output('git', 'config', '--local', 'color.diff', 'always') + test_foo_something_unstaged(foo_staged, cmd_runner) + + def test_foo_both_modify_non_conflicting(foo_staged, cmd_runner): with io.open(foo_staged.foo_filename, 'w') as foo_file: foo_file.write(FOO_CONTENTS + '9\n')