Skip to content

Commit bb4b3ab

Browse files
committed
Add --no-ext-diff to git diff commands
An external tool configured in git's diff.external setting can break eslint-plugin-diff. For example difft seems to always take over regular git diff output, even in non interactive sessions. This results in eslint-plugin-diff not being able to parse the diff output and exiting with no errors. This change adds --no-ext-diff to the git diff commands, which overrides the diff.external setting.
1 parent 0983ec5 commit bb4b3ab

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/git.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe("getDiffForFile", () => {
5656

5757
const expectedCommand = "git";
5858
const expectedArgs =
59-
'diff --diff-algorithm=histogram --diff-filter=ACM -M100% --relative --staged --unified=0 1234567';
59+
'diff --no-ext-diff --diff-algorithm=histogram --diff-filter=ACM -M100% --relative --staged --unified=0 1234567';
6060

6161
const lastCall = mockedChildProcess.execFileSync.mock.calls.at(-1);
6262
const [command, argsIncludingFile = []] = lastCall ?? [""];

src/git.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const COMMAND = "git";
77
const getDiffForFile = (filePath: string, staged = false): string => {
88
const args = [
99
"diff",
10+
"--no-ext-diff",
1011
"--diff-algorithm=histogram",
1112
"--diff-filter=ACM",
1213
"-M100%",
@@ -27,6 +28,7 @@ const getDiffForFile = (filePath: string, staged = false): string => {
2728
const getDiffFileList = (): string[] => {
2829
const args = [
2930
"diff",
31+
"--no-ext-diff",
3032
"--diff-algorithm=histogram",
3133
"--diff-filter=ACM",
3234
"-M100%",
@@ -47,6 +49,7 @@ const getDiffFileList = (): string[] => {
4749
const hasCleanIndex = (filePath: string): boolean => {
4850
const args = [
4951
"diff",
52+
"--no-ext-diff",
5053
"--quiet",
5154
"--relative",
5255
"--unified=0",

0 commit comments

Comments
 (0)