diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index a7ae3c953c82..bae7290c2278 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -1160,6 +1160,8 @@ git.force.commit.using.staging.area=false git.force.commit.using.staging.area.description=When enabled, perform all git commits by updating staging area. If disable, use `git commit --only` when possible. git.clone.recurse.submodules=true git.clone.recurse.submodules.description=When enabled, Checkout from Git calls `git clone --recurse-submodules`, i.e. clones the main repository with all submodules if there are any. +git.use.textconv=false +git.use.textconv.description=Apply `textconv` transformations when reading file content from git. hg4idea.process.ignored=true hg4idea.process.ignored.description=Process and highlight mercurial ignored files. \ diff --git a/plugins/git4idea/src/git4idea/config/GitVersionSpecialty.java b/plugins/git4idea/src/git4idea/config/GitVersionSpecialty.java index 2dce4ec68947..986a3d4bb780 100644 --- a/plugins/git4idea/src/git4idea/config/GitVersionSpecialty.java +++ b/plugins/git4idea/src/git4idea/config/GitVersionSpecialty.java @@ -238,6 +238,13 @@ public enum GitVersionSpecialty { public boolean existsIn(@NotNull GitVersion version) { return version.isLaterOrEqual(new GitVersion(2, 11, 0, 0)); } + }, + + CAT_FILE_SUPPORTS_TEXTCONV { + @Override + public boolean existsIn(@NotNull GitVersion version) { + return version.isLaterOrEqual(new GitVersion(2, 2, 0, 0)); + } }; public abstract boolean existsIn(@NotNull GitVersion version); diff --git a/plugins/git4idea/src/git4idea/util/GitFileUtils.java b/plugins/git4idea/src/git4idea/util/GitFileUtils.java index 7af01c28024a..e1d36e22a0dc 100644 --- a/plugins/git4idea/src/git4idea/util/GitFileUtils.java +++ b/plugins/git4idea/src/git4idea/util/GitFileUtils.java @@ -17,6 +17,7 @@ package git4idea.util; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vcs.VcsException; @@ -33,6 +34,7 @@ import org.jetbrains.annotations.NotNull; import java.util.*; import static git4idea.config.GitVersionSpecialty.CAT_FILE_SUPPORTS_FILTERS; +import static git4idea.config.GitVersionSpecialty.CAT_FILE_SUPPORTS_TEXTCONV; public class GitFileUtils { @@ -171,7 +173,11 @@ public class GitFileUtils { public static byte[] getFileContent(Project project, VirtualFile root, String revisionOrBranch, String relativePath) throws VcsException { GitBinaryHandler h = new GitBinaryHandler(project, root, GitCommand.CAT_FILE); h.setSilent(true); - if (CAT_FILE_SUPPORTS_FILTERS.existsIn(project)) { + if (CAT_FILE_SUPPORTS_TEXTCONV.existsIn(project) && + Registry.is("git.use.textconv")) { + h.addParameters("--textconv"); + } + else if (CAT_FILE_SUPPORTS_FILTERS.existsIn(project)) { h.addParameters("--filters"); } else {