mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[git] before 2.8.0 git for windows expects to have LF symbol as line separator in standard input instead of CRLF
IDEA-174661
This commit is contained in:
@@ -168,6 +168,14 @@ public enum GitVersionSpecialty {
|
||||
public boolean existsIn(@NotNull GitVersion version) {
|
||||
return version.isLaterOrEqual(new GitVersion(1, 8, 2, 0));
|
||||
}
|
||||
},
|
||||
|
||||
INCORRECT_SEPARATORS_IN_STDIN {
|
||||
@Override
|
||||
public boolean existsIn(@NotNull GitVersion version) {
|
||||
// before 2.8.0 git for windows expects to have LF symbol as line separator in standard input instead of CRLF
|
||||
return SystemInfo.isWindows && !version.isLaterOrEqual(new GitVersion(2, 8, 0, 0));
|
||||
}
|
||||
};
|
||||
|
||||
public abstract boolean existsIn(@NotNull GitVersion version);
|
||||
|
||||
@@ -356,14 +356,15 @@ public class GitLogUtil {
|
||||
};
|
||||
GitLineHandler handler = new GitLineHandler(project, root, GitCommand.LOG, createConfigParameters(true));
|
||||
|
||||
String separator = getSeparator(vcs);
|
||||
Ref<Exception> inputError = new Ref<>();
|
||||
handler.setInputProcessor(stream -> {
|
||||
try (OutputStreamWriter writer = new OutputStreamWriter(stream, handler.getCharset())) {
|
||||
for (String hash : hashes) {
|
||||
writer.write(hash);
|
||||
writer.write(System.lineSeparator());
|
||||
writer.write(separator);
|
||||
}
|
||||
writer.write(System.lineSeparator());
|
||||
writer.write(separator);
|
||||
writer.flush();
|
||||
}
|
||||
catch (IOException e) {
|
||||
@@ -380,6 +381,14 @@ public class GitLogUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getSeparator(@NotNull GitVcs vcs) {
|
||||
if (GitVersionSpecialty.INCORRECT_SEPARATORS_IN_STDIN.existsIn(vcs.getVersion())) {
|
||||
return "\n";
|
||||
}
|
||||
return System.lineSeparator();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getNoWalkParameter(@NotNull GitVcs vcs) {
|
||||
return GitVersionSpecialty.NO_WALK_UNSORTED.existsIn(vcs.getVersion()) ? "--no-walk=unsorted" : "--no-walk";
|
||||
|
||||
Reference in New Issue
Block a user