Other .git files are not hidden with this patch Change-Id: Idf63ca08d08f3a77c33f5848d02074f8d6a75758 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>tags/v3.5.0.201409071800-rc1
import org.eclipse.jgit.lib.BaseRepositoryBuilder; | import org.eclipse.jgit.lib.BaseRepositoryBuilder; | ||||
import org.eclipse.jgit.lib.ConfigConstants; | import org.eclipse.jgit.lib.ConfigConstants; | ||||
import org.eclipse.jgit.lib.Constants; | 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.CoreConfig.SymLinks; | ||||
import org.eclipse.jgit.lib.ObjectId; | import org.eclipse.jgit.lib.ObjectId; | ||||
import org.eclipse.jgit.lib.Ref; | import org.eclipse.jgit.lib.Ref; | ||||
JGitText.get().repositoryAlreadyExists, getDirectory())); | JGitText.get().repositoryAlreadyExists, getDirectory())); | ||||
} | } | ||||
FileUtils.mkdirs(getDirectory(), true); | 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(); | refs.create(); | ||||
objectDatabase.create(); | objectDatabase.create(); | ||||
/** The "indexversion" key */ | /** The "indexversion" key */ | ||||
public static final String CONFIG_KEY_INDEXVERSION = "indexversion"; | 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 */ | /** The "precomposeunicode" key */ | ||||
public static final String CONFIG_KEY_PRECOMPOSEUNICODE = "precomposeunicode"; | public static final String CONFIG_KEY_PRECOMPOSEUNICODE = "precomposeunicode"; | ||||
TRUE | 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) { | private CoreConfig(final Config rc) { | ||||
compression = rc.getInt(ConfigConstants.CONFIG_CORE_SECTION, | compression = rc.getInt(ConfigConstants.CONFIG_CORE_SECTION, | ||||
ConfigConstants.CONFIG_KEY_COMPRESSION, DEFAULT_COMPRESSION); | ConfigConstants.CONFIG_KEY_COMPRESSION, DEFAULT_COMPRESSION); |
import org.eclipse.jgit.lib.Config.SectionParser; | import org.eclipse.jgit.lib.Config.SectionParser; | ||||
import org.eclipse.jgit.lib.CoreConfig.AutoCRLF; | import org.eclipse.jgit.lib.CoreConfig.AutoCRLF; | ||||
import org.eclipse.jgit.lib.CoreConfig.CheckStat; | import org.eclipse.jgit.lib.CoreConfig.CheckStat; | ||||
import org.eclipse.jgit.lib.CoreConfig.HideDotFiles; | |||||
import org.eclipse.jgit.lib.CoreConfig.SymLinks; | import org.eclipse.jgit.lib.CoreConfig.SymLinks; | ||||
/** Options used by the {@link WorkingTreeIterator}. */ | /** Options used by the {@link WorkingTreeIterator}. */ | ||||
private final SymLinks symlinks; | private final SymLinks symlinks; | ||||
private final HideDotFiles hideDotFiles; | |||||
private WorkingTreeOptions(final Config rc) { | private WorkingTreeOptions(final Config rc) { | ||||
fileMode = rc.getBoolean(ConfigConstants.CONFIG_CORE_SECTION, | fileMode = rc.getBoolean(ConfigConstants.CONFIG_CORE_SECTION, | ||||
ConfigConstants.CONFIG_KEY_FILEMODE, true); | ConfigConstants.CONFIG_KEY_FILEMODE, true); | ||||
ConfigConstants.CONFIG_KEY_CHECKSTAT, CheckStat.DEFAULT); | ConfigConstants.CONFIG_KEY_CHECKSTAT, CheckStat.DEFAULT); | ||||
symlinks = rc.getEnum(ConfigConstants.CONFIG_CORE_SECTION, null, | symlinks = rc.getEnum(ConfigConstants.CONFIG_CORE_SECTION, null, | ||||
ConfigConstants.CONFIG_KEY_SYMLINKS, SymLinks.TRUE); | 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. */ | /** @return true if the execute bit on working files should be trusted. */ | ||||
public SymLinks getSymLinks() { | public SymLinks getSymLinks() { | ||||
return symlinks; | return symlinks; | ||||
} | } | ||||
/** | |||||
* @return how we create '.'-files (on Windows) | |||||
* @since 3.5 | |||||
*/ | |||||
public HideDotFiles getHideDotFiles() { | |||||
return hideDotFiles; | |||||
} | |||||
} | } |