From 190add075270a1b390c309a3142ec57c3d62336c Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 2 Sep 2015 07:32:27 +1000 Subject: Set a sane autocrlf value on fresh clones. --- src/main/java/org/spigotmc/builder/Builder.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/spigotmc/builder/Builder.java b/src/main/java/org/spigotmc/builder/Builder.java index 1ea7a4f..ebc7d86 100644 --- a/src/main/java/org/spigotmc/builder/Builder.java +++ b/src/main/java/org/spigotmc/builder/Builder.java @@ -58,6 +58,7 @@ import org.apache.commons.io.output.TeeOutputStream; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.ResetCommand; import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.lib.StoredConfig; import org.eclipse.jgit.revwalk.RevCommit; public class Builder @@ -66,6 +67,7 @@ public class Builder public static final String LOG_FILE = "BuildTools.log.txt"; public static final boolean IS_WINDOWS = System.getProperty( "os.name" ).startsWith( "Windows" ); public static final File CWD = new File( "." ); + private static final boolean autocrlf = !"\n".equals( System.getProperty( "line.separator" ) ); private static boolean dontUpdate; private static boolean skipCompile; private static boolean generateSource; @@ -610,7 +612,7 @@ public class Builder } } - public static void clone(String url, File target) throws GitAPIException + public static void clone(String url, File target) throws GitAPIException, IOException { System.out.println( "Starting clone of " + url + " to " + target ); @@ -618,8 +620,11 @@ public class Builder try { - System.out.println( "Cloned git repository " + url + " to " + target.getAbsolutePath() + ". Current HEAD: " + commitHash( result ) ); + StoredConfig config = result.getRepository().getConfig(); + config.setBoolean( "core", null, "autocrlf", autocrlf ); + config.save(); + System.out.println( "Cloned git repository " + url + " to " + target.getAbsolutePath() + ". Current HEAD: " + commitHash( result ) ); } finally { result.close(); -- cgit v1.2.3