From dccad56c9a8714398f813f953704a52d3aa3c0cc Mon Sep 17 00:00:00 2001 From: Robin Rosenberg Date: Fri, 3 Aug 2012 00:56:46 +0200 Subject: [PATCH] Set core.precomposeunicode to true when creating repository on Mac Java has no option but to use precomposed Unicode, so we should state that when creating a new repository. Not that Java will use precomposed unicode regardless of this setting, but this reduces the risk of incompatibility with C Git. Change-Id: I3779b75f76d2e2061c836cbc9b4b7c2ae0cf18f4 --- .../tst/org/eclipse/jgit/pgm/ConfigTest.java | 19 ++++++++++++++----- .../org/eclipse/jgit/lib/ConfigConstants.java | 3 +++ .../jgit/storage/file/FileRepository.java | 4 ++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ConfigTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ConfigTest.java index 71e4c3869..e869e8556 100644 --- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ConfigTest.java +++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ConfigTest.java @@ -44,6 +44,9 @@ import static org.junit.Assert.assertArrayEquals; +import java.util.ArrayList; +import java.util.List; + import org.eclipse.jgit.api.Git; import org.eclipse.jgit.lib.CLIRepositoryTestCase; import org.eclipse.jgit.util.SystemReader; @@ -62,12 +65,18 @@ public void setUp() throws Exception { public void testListConfig() throws Exception { boolean isWindows = SystemReader.getInstance().getProperty("os.name") .startsWith("Windows"); + boolean isMac = SystemReader.getInstance().getProperty("os.name") + .equals("Mac OS X"); String[] output = execute("git config --list"); - assertArrayEquals("expected default configuration", // - new String[] { "core.filemode=" + !isWindows, // - "core.logallrefupdates=true", // - "core.repositoryformatversion=0", // - "" /* ends with LF (last line empty) */}, output); + List expect = new ArrayList(); + expect.add("core.filemode=" + !isWindows); + expect.add("core.logallrefupdates=true"); + if (isMac) + expect.add("core.precomposeunicode=true"); + expect.add("core.repositoryformatversion=0"); + expect.add(""); // ends with LF (last line empty) + assertArrayEquals("expected default configuration", expect.toArray(), + output); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java index 237fb66d0..aaa427bae 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java @@ -178,4 +178,7 @@ public class ConfigConstants { /** The "indexversion" key */ public static final String CONFIG_KEY_INDEXVERSION = "indexversion"; + + /** The "precomposeunicode" key */ + public static final String CONFIG_KEY_PRECOMPOSEUNICODE = "precomposeunicode"; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileRepository.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileRepository.java index 7934e7f9b..33a51269d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileRepository.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileRepository.java @@ -280,6 +280,10 @@ public void create(boolean bare) throws IOException { ConfigConstants.CONFIG_KEY_BARE, true); cfg.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_LOGALLREFUPDATES, !bare); + if (SystemReader.getInstance().isMacOS()) + // Java has no other way + cfg.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null, + ConfigConstants.CONFIG_KEY_PRECOMPOSEUNICODE, true); cfg.save(); }