From a3de151ff4fe1ab5bbd0eb634a6da4353ba80dc1 Mon Sep 17 00:00:00 2001 From: Hubert Plociniczak Date: Thu, 12 Jan 2023 13:28:09 +0100 Subject: [PATCH] Workaround vcs/restore issues on Windows (#4042) Potential workaround to line endings problems after `vcs/restore` operation is executed. # Important Notes Not really able to reproduce the problem myself so this PR has a lot of _leap of faith_ in it. --- .../scala/org/enso/languageserver/vcsmanager/Git.scala | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/vcsmanager/Git.scala b/engine/language-server/src/main/scala/org/enso/languageserver/vcsmanager/Git.scala index 2d87511d06..22e2692753 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/vcsmanager/Git.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/vcsmanager/Git.scala @@ -38,11 +38,17 @@ private class Git(ensoDataDirectory: Option[Path]) extends VcsApi[BlockingIO] { private def repository(root: Path): Repository = { val builder = new FileRepositoryBuilder() - builder + val repo = builder .setWorkTree(root.toFile) .setGitDir(root.resolve(gitDir).toFile) .setMustExist(true) .build() + disableAutoCRLF(repo) + repo + } + + private def disableAutoCRLF(repo: Repository): Unit = { + repo.getConfig.setString("core", null, "autocrlf", "false") } override def init(root: Path): BlockingIO[VcsFailure, Unit] = { @@ -71,6 +77,7 @@ private class Git(ensoDataDirectory: Option[Path]) extends VcsApi[BlockingIO] { .setDirectory(root.toFile) .setBare(false) .call() + disableAutoCRLF(jgit.getRepository) ensoDataDirectory.foreach { _ => // When `gitDir` is set, JGit **always** creates a .git file (not a directory!) that points at the real