summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse
diff options
context:
space:
mode:
authorRobin Rosenberg <robin.rosenberg@dewire.com>2014-02-11 01:06:27 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2014-09-04 11:24:54 +0200
commit00c4a73fbcedf8696f573c9a749a7d4da70a832f (patch)
treea1cb3c6d499338673488db8bb57277fa276ab83d /org.eclipse.jgit/src/org/eclipse
parent348dd52ef16c3590dcdf44efd330be500d5c26e2 (diff)
downloadjgit-00c4a73fbcedf8696f573c9a749a7d4da70a832f.tar.gz
jgit-00c4a73fbcedf8696f573c9a749a7d4da70a832f.zip
Windows: Hide the .git directory if hidedotfiles is set to non-false
Other .git files are not hidden with this patch Change-Id: Idf63ca08d08f3a77c33f5848d02074f8d6a75758 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java7
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/CoreConfig.java14
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeOptions.java14
4 files changed, 41 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java
index 4c420f693c..447e357d5a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java
@@ -64,6 +64,7 @@ import org.eclipse.jgit.internal.storage.file.ObjectDirectory.AlternateRepositor
import org.eclipse.jgit.lib.BaseRepositoryBuilder;
import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.CoreConfig.HideDotFiles;
import org.eclipse.jgit.lib.CoreConfig.SymLinks;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
@@ -268,6 +269,12 @@ public class FileRepository extends Repository {
JGitText.get().repositoryAlreadyExists, getDirectory()));
}
FileUtils.mkdirs(getDirectory(), true);
+ HideDotFiles hideDotFiles = getConfig().getEnum(
+ ConfigConstants.CONFIG_CORE_SECTION, null,
+ ConfigConstants.CONFIG_KEY_HIDEDOTFILES,
+ HideDotFiles.DOTGITONLY);
+ if (hideDotFiles != HideDotFiles.FALSE)
+ getFS().setHidden(getDirectory(), true);
refs.create();
objectDatabase.create();
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 b52ecd8156..378d91c58c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
@@ -214,6 +214,12 @@ public class ConfigConstants {
/** The "indexversion" key */
public static final String CONFIG_KEY_INDEXVERSION = "indexversion";
+ /**
+ * The "hidedotfiles" key
+ * @since 3.5
+ */
+ public static final String CONFIG_KEY_HIDEDOTFILES = "hidedotfiles";
+
/** The "precomposeunicode" key */
public static final String CONFIG_KEY_PRECOMPOSEUNICODE = "precomposeunicode";
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/CoreConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/CoreConfig.java
index 962f2e7c24..8f31d96de6 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/CoreConfig.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/CoreConfig.java
@@ -113,6 +113,20 @@ public class CoreConfig {
TRUE
}
+ /**
+ * Options for hiding files whose names start with a period
+ *
+ * @since 3.5
+ */
+ public static enum HideDotFiles {
+ /** Do not hide .files */
+ FALSE,
+ /** Hide add .files */
+ TRUE,
+ /** Hide only .git */
+ DOTGITONLY
+ }
+
private CoreConfig(final Config rc) {
compression = rc.getInt(ConfigConstants.CONFIG_CORE_SECTION,
ConfigConstants.CONFIG_KEY_COMPRESSION, DEFAULT_COMPRESSION);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeOptions.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeOptions.java
index e5e22413d2..a6dccce031 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeOptions.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeOptions.java
@@ -48,6 +48,7 @@ import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Config.SectionParser;
import org.eclipse.jgit.lib.CoreConfig.AutoCRLF;
import org.eclipse.jgit.lib.CoreConfig.CheckStat;
+import org.eclipse.jgit.lib.CoreConfig.HideDotFiles;
import org.eclipse.jgit.lib.CoreConfig.SymLinks;
/** Options used by the {@link WorkingTreeIterator}. */
@@ -67,6 +68,8 @@ public class WorkingTreeOptions {
private final SymLinks symlinks;
+ private final HideDotFiles hideDotFiles;
+
private WorkingTreeOptions(final Config rc) {
fileMode = rc.getBoolean(ConfigConstants.CONFIG_CORE_SECTION,
ConfigConstants.CONFIG_KEY_FILEMODE, true);
@@ -76,6 +79,9 @@ public class WorkingTreeOptions {
ConfigConstants.CONFIG_KEY_CHECKSTAT, CheckStat.DEFAULT);
symlinks = rc.getEnum(ConfigConstants.CONFIG_CORE_SECTION, null,
ConfigConstants.CONFIG_KEY_SYMLINKS, SymLinks.TRUE);
+ hideDotFiles = rc.getEnum(ConfigConstants.CONFIG_CORE_SECTION, null,
+ ConfigConstants.CONFIG_KEY_HIDEDOTFILES,
+ HideDotFiles.DOTGITONLY);
}
/** @return true if the execute bit on working files should be trusted. */
@@ -103,4 +109,12 @@ public class WorkingTreeOptions {
public SymLinks getSymLinks() {
return symlinks;
}
+
+ /**
+ * @return how we create '.'-files (on Windows)
+ * @since 3.5
+ */
+ public HideDotFiles getHideDotFiles() {
+ return hideDotFiles;
+ }
}