Skip to content

Commit

Permalink
Add --no-ext-diff to git diff commands
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
flupke committed Jul 1, 2022
1 parent 0983ec5 commit bb4b3ab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe("getDiffForFile", () => {

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

const lastCall = mockedChildProcess.execFileSync.mock.calls.at(-1);
const [command, argsIncludingFile = []] = lastCall ?? [""];
Expand Down
3 changes: 3 additions & 0 deletions src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const COMMAND = "git";
const getDiffForFile = (filePath: string, staged = false): string => {
const args = [
"diff",
"--no-ext-diff",
"--diff-algorithm=histogram",
"--diff-filter=ACM",
"-M100%",
Expand All @@ -27,6 +28,7 @@ const getDiffForFile = (filePath: string, staged = false): string => {
const getDiffFileList = (): string[] => {
const args = [
"diff",
"--no-ext-diff",
"--diff-algorithm=histogram",
"--diff-filter=ACM",
"-M100%",
Expand All @@ -47,6 +49,7 @@ const getDiffFileList = (): string[] => {
const hasCleanIndex = (filePath: string): boolean => {
const args = [
"diff",
"--no-ext-diff",
"--quiet",
"--relative",
"--unified=0",
Expand Down

0 comments on commit bb4b3ab

Please sign in to comment.