mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-90565 IDEA-175120 git: apply autocrlf conversions when loading file content
This commit is contained in:
@@ -37,6 +37,7 @@ public class GitCommand {
|
||||
public static final GitCommand ADD = write("add");
|
||||
public static final GitCommand BLAME = read("blame");
|
||||
public static final GitCommand BRANCH = read("branch");
|
||||
public static final GitCommand CAT_FILE = write("cat-file");
|
||||
public static final GitCommand CHECKOUT = write("checkout");
|
||||
public static final GitCommand CHECK_ATTR = read("check-attr");
|
||||
public static final GitCommand COMMIT = write("commit");
|
||||
|
||||
@@ -231,6 +231,13 @@ public enum GitVersionSpecialty {
|
||||
public boolean existsIn(@NotNull GitVersion version) {
|
||||
return version.isLaterOrEqual(new GitVersion(2, 0, 0, 0));
|
||||
}
|
||||
},
|
||||
|
||||
CAT_FILE_SUPPORTS_FILTERS {
|
||||
@Override
|
||||
public boolean existsIn(@NotNull GitVersion version) {
|
||||
return version.isLaterOrEqual(new GitVersion(2, 11, 0, 0));
|
||||
}
|
||||
};
|
||||
|
||||
public abstract boolean existsIn(@NotNull GitVersion version);
|
||||
|
||||
@@ -32,6 +32,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static git4idea.config.GitVersionSpecialty.CAT_FILE_SUPPORTS_FILTERS;
|
||||
|
||||
public class GitFileUtils {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance(GitFileUtils.class);
|
||||
@@ -167,10 +169,15 @@ public class GitFileUtils {
|
||||
* @throws VcsException if there is a problem with running git
|
||||
*/
|
||||
public static byte[] getFileContent(Project project, VirtualFile root, String revisionOrBranch, String relativePath) throws VcsException {
|
||||
GitBinaryHandler h = new GitBinaryHandler(project, root, GitCommand.SHOW);
|
||||
GitBinaryHandler h = new GitBinaryHandler(project, root, GitCommand.CAT_FILE);
|
||||
h.setSilent(true);
|
||||
if (CAT_FILE_SUPPORTS_FILTERS.existsIn(project)) {
|
||||
h.addParameters("--filters");
|
||||
}
|
||||
else {
|
||||
h.addParameters("-p");
|
||||
}
|
||||
h.addParameters(revisionOrBranch + ":" + relativePath);
|
||||
h.endOptions();
|
||||
return h.run();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user