]> source.dussan.org Git - jgit.git/commitdiff
Set core.precomposeunicode to true when creating repository on Mac 16/7116/3
authorRobin Rosenberg <robin.rosenberg@dewire.com>
Thu, 2 Aug 2012 22:56:46 +0000 (00:56 +0200)
committerRobin Rosenberg <robin.rosenberg@dewire.com>
Tue, 21 Aug 2012 22:36:11 +0000 (00:36 +0200)
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

org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ConfigTest.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileRepository.java

index 71e4c38698970fdf6284c4f746f8c364988ff267..e869e8556800944abac322ca5eccc95cf6242b8d 100644 (file)
@@ -44,6 +44,9 @@ package org.eclipse.jgit.pgm;
 
 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 class ConfigTest extends CLIRepositoryTestCase {
        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<String> expect = new ArrayList<String>();
+               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);
        }
 }
index 237fb66d0a918514072faf769b8e6615f1b9f6ee..aaa427bae62f073b61a1b5f4c42fe95e36575de7 100644 (file)
@@ -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";
 }
index 7934e7f9be8430e20e67ace6ce2d641ed04ebce1..33a51269de2fc5ed613ba2e3d2907144b0ebcbfd 100644 (file)
@@ -280,6 +280,10 @@ public class FileRepository extends Repository {
                                        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();
        }