Skip to content

Commit f611c94

Browse files
committed
fix: update git command options to handle line endings consistently
1 parent 30d1f9e commit f611c94

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

src/common/file-history.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export class GitFileHistory {
160160
args: string[],
161161
options: { includeWorkTree: boolean; input?: string; env?: NodeJS.ProcessEnv }
162162
): string {
163-
const gitArgs = [`--git-dir=${this.gitDir}`];
163+
const gitArgs = ["-c", "core.autocrlf=false", "-c", "core.eol=lf", `--git-dir=${this.gitDir}`];
164164
if (options.includeWorkTree) {
165165
gitArgs.push(`--work-tree=${this.projectRoot}`);
166166
}

src/tests/session.test.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,12 +2018,16 @@ function runFileHistoryGit(
20182018
input = "",
20192019
env: NodeJS.ProcessEnv = process.env
20202020
): string {
2021-
return execFileSync("git", [`--git-dir=${gitDir}`, `--work-tree=${workspace}`, ...args], {
2022-
encoding: "utf8",
2023-
input,
2024-
env,
2025-
stdio: ["pipe", "pipe", "pipe"],
2026-
});
2021+
return execFileSync(
2022+
"git",
2023+
["-c", "core.autocrlf=false", "-c", "core.eol=lf", `--git-dir=${gitDir}`, `--work-tree=${workspace}`, ...args],
2024+
{
2025+
encoding: "utf8",
2026+
input,
2027+
env,
2028+
stdio: ["pipe", "pipe", "pipe"],
2029+
}
2030+
);
20272031
}
20282032

20292033
function fileHistoryCommitEnv(): NodeJS.ProcessEnv {

0 commit comments

Comments
 (0)