Repository: pre-commit/pre-commit

Issue:
git diff enhancement to add --no-ext-diff
Hi,

Is there a way when running command

```
pre-commit run --all-files
```

To use git diff --no-ext-diff instead of git diff

Maybe using an environment variable to add this external  --no-ext-diff parameter in the script https://github.com/pre-commit/pre-commit/blob/master/pre_commit/git.py ?

My issue comes from the fact that I am using meld in my ~/.gitconfig

```
[diff]
	external = /usr/local/bin/git-diff.sh
[push]
	default = simple
[merge]
	tool = meld
	renamelimit = 10000
```

less  /usr/local/bin/git-diff.sh

```
#!/bin/bash
meld "$2" "$5" > /dev/null 2>&1
```

So every-time pre-commit run --all-files run I have a popup with meld that I must close.
It is annoying...

Feel free to help me to find the right code and I might find some time to do a pull request...

Best regards,

Alban


Discussion:
Woops! Yeah I keep tracking down these places as well :)

You can find all of them by running `git grep "'diff'"`

```
$ git grep "'diff'" -- pre_commit
pre_commit/commands/run.py:        'git', 'diff', '--name-only', '{}...{}'.format(old, new),
pre_commit/commands/run.py:    diff_before = cmd_output('git', 'diff', retcode=None, encoding=None)
pre_commit/commands/run.py:    diff_after = cmd_output('git', 'diff', retcode=None, encoding=None)
pre_commit/commands/run.py:            subprocess.call(('git', 'diff', '--quiet')) != 0
pre_commit/commands/run.py:        subprocess.call(('git', 'diff'))
pre_commit/commands/run.py:        ('git', 'diff', '--exit-code', runner.config_file_path),
pre_commit/git.py:        'git', 'diff', '-m', tree_hash, 'HEAD', 'MERGE_HEAD', '--name-only',
pre_commit/git.py:        'git', 'diff', '--staged', '--name-only',
pre_commit/staged_files_only.py:            'git', 'diff', '--ignore-submodules', '--binary', '--exit-code',
```

Resolving patch:
diff --git a/pre_commit/commands/run.py b/pre_commit/commands/run.py
--- a/pre_commit/commands/run.py
+++ b/pre_commit/commands/run.py
@@ -32,7 +32,8 @@ def _hook_msg_start(hook, verbose):
 
 def get_changed_files(new, old):
     return cmd_output(
-        'git', 'diff', '--name-only', '{}...{}'.format(old, new),
+        'git', 'diff', '--no-ext-diff', '--name-only',
+        '{}...{}'.format(old, new),
     )[1].splitlines()
 
 
@@ -85,12 +86,16 @@ def _run_single_hook(hook, repo, args, skips, cols):
     ))
     sys.stdout.flush()
 
-    diff_before = cmd_output('git', 'diff', retcode=None, encoding=None)
+    diff_before = cmd_output(
+        'git', 'diff', '--no-ext-diff', retcode=None, encoding=None,
+    )
     retcode, stdout, stderr = repo.run_hook(
         hook,
         tuple(filenames) if hook['pass_filenames'] else (),
     )
-    diff_after = cmd_output('git', 'diff', retcode=None, encoding=None)
+    diff_after = cmd_output(
+        'git', 'diff', '--no-ext-diff', retcode=None, encoding=None,
+    )
 
     file_modifications = diff_before != diff_after
 
@@ -159,10 +164,10 @@ def _run_hooks(repo_hooks, args, environ):
     if (
             retval and
             args.show_diff_on_failure and
-            subprocess.call(('git', 'diff', '--quiet')) != 0
+            subprocess.call(('git', 'diff', '--quiet', '--no-ext-diff')) != 0
     ):
         print('All changes made by hooks:')
-        subprocess.call(('git', 'diff'))
+        subprocess.call(('git', 'diff', '--no-ext-diff'))
     return retval
 
 
@@ -179,7 +184,10 @@ def _has_unmerged_paths(runner):
 
 def _has_unstaged_config(runner):
     retcode, _, _ = runner.cmd_runner.run(
-        ('git', 'diff', '--exit-code', runner.config_file_path),
+        (
+            'git', 'diff', '--no-ext-diff', '--exit-code',
+            runner.config_file_path,
+        ),
         retcode=None,
     )
     # be explicit, other git errors don't mean it has an unstaged config.
diff --git a/pre_commit/git.py b/pre_commit/git.py
--- a/pre_commit/git.py
+++ b/pre_commit/git.py
@@ -68,7 +68,8 @@ def get_conflicted_files():
     # this will also include the conflicted files
     tree_hash = cmd_output('git', 'write-tree')[1].strip()
     merge_diff_filenames = cmd_output(
-        'git', 'diff', '-m', tree_hash, 'HEAD', 'MERGE_HEAD', '--name-only',
+        'git', 'diff', '--no-ext-diff',
+        '-m', tree_hash, 'HEAD', 'MERGE_HEAD', '--name-only',
     )[1].splitlines()
     return set(merge_conflict_filenames) | set(merge_diff_filenames)
 
@@ -76,7 +77,7 @@ def get_conflicted_files():
 @memoize_by_cwd
 def get_staged_files():
     return cmd_output(
-        'git', 'diff', '--staged', '--name-only',
+        'git', 'diff', '--staged', '--name-only', '--no-ext-diff',
         # Everything except for D
         '--diff-filter=ACMRTUXB'
     )[1].splitlines()
diff --git a/pre_commit/staged_files_only.py b/pre_commit/staged_files_only.py
--- a/pre_commit/staged_files_only.py
+++ b/pre_commit/staged_files_only.py
@@ -21,10 +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',
             '--no-color', '--no-ext-diff',
-        ],
+        ),
         retcode=None,
         encoding=None,
     )


Test patch: