diff --git a/src/git/cli.ts b/src/git/cli.ts index daaca02..176f82e 100644 --- a/src/git/cli.ts +++ b/src/git/cli.ts @@ -43,6 +43,7 @@ async function _diffIndex( "--find-renames", "--find-copies", "--no-color", + "-z", ...options, "HEAD", ]; @@ -53,7 +54,7 @@ async function _diffIndex( console.debug(`stderr for 'git ${cmd}' command:`, stderr); } - const lines = stdout.split("\n"); + const lines = stdout.split("\0"); return lines.filter(line => line !== ""); } diff --git a/src/git/parseOutput.ts b/src/git/parseOutput.ts index 8924c5b..9a13500 100644 --- a/src/git/parseOutput.ts +++ b/src/git/parseOutput.ts @@ -54,10 +54,12 @@ export function parseStatus(line: string): FileChange { * than `undefined`). */ export function parseDiffIndex(line: string): FileChange { + // this was failing for some reason + // adding logging helps otherwise it is swallowed if (line.length <= 4) { - throw new Error( - `Invalid input. Input string must be at least 4 characters. Got: '${line}'`, - ); + const errorMsg = `Invalid input. Input string must be at least 4 characters. Got: '${line}'`; + console.error(errorMsg); + throw new Error(errorMsg); } const x = line[0]; const y = UNMODIFIED;