You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CoreConfig.java 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. /*
  2. * Copyright (C) 2013, Gunnar Wagenknecht
  3. * Copyright (C) 2010, Chris Aniszczyk <caniszczyk@gmail.com>
  4. * Copyright (C) 2009, Christian Halstrick <christian.halstrick@sap.com>
  5. * Copyright (C) 2009, Google Inc.
  6. * Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
  7. * Copyright (C) 2006-2008, Shawn O. Pearce <spearce@spearce.org>
  8. * and other copyright owners as documented in the project's IP log.
  9. *
  10. * This program and the accompanying materials are made available
  11. * under the terms of the Eclipse Distribution License v1.0 which
  12. * accompanies this distribution, is reproduced below, and is
  13. * available at http://www.eclipse.org/org/documents/edl-v10.php
  14. *
  15. * All rights reserved.
  16. *
  17. * Redistribution and use in source and binary forms, with or
  18. * without modification, are permitted provided that the following
  19. * conditions are met:
  20. *
  21. * - Redistributions of source code must retain the above copyright
  22. * notice, this list of conditions and the following disclaimer.
  23. *
  24. * - Redistributions in binary form must reproduce the above
  25. * copyright notice, this list of conditions and the following
  26. * disclaimer in the documentation and/or other materials provided
  27. * with the distribution.
  28. *
  29. * - Neither the name of the Eclipse Foundation, Inc. nor the
  30. * names of its contributors may be used to endorse or promote
  31. * products derived from this software without specific prior
  32. * written permission.
  33. *
  34. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  35. * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  36. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  38. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  39. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  41. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  42. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  43. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  44. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  45. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  46. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  47. */
  48. package org.eclipse.jgit.lib;
  49. import static java.util.zip.Deflater.DEFAULT_COMPRESSION;
  50. import org.eclipse.jgit.lib.Config.SectionParser;
  51. /**
  52. * This class keeps git repository core parameters.
  53. */
  54. public class CoreConfig {
  55. /** Key for {@link Config#get(SectionParser)}. */
  56. public static final Config.SectionParser<CoreConfig> KEY = CoreConfig::new;
  57. /** Permissible values for {@code core.autocrlf}. */
  58. public enum AutoCRLF {
  59. /** Automatic CRLF-&gt;LF conversion is disabled. */
  60. FALSE,
  61. /** Automatic CRLF-&gt;LF conversion is enabled. */
  62. TRUE,
  63. /** CRLF-&gt;LF performed, but no LF-&gt;CRLF. */
  64. INPUT;
  65. }
  66. /**
  67. * Permissible values for {@code core.eol}.
  68. * <p>
  69. * https://git-scm.com/docs/gitattributes
  70. *
  71. * @since 4.3
  72. */
  73. public enum EOL {
  74. /** Check in with LF, check out with CRLF. */
  75. CRLF,
  76. /** Check in with LF, check out without conversion. */
  77. LF,
  78. /** Use the platform's native line ending. */
  79. NATIVE;
  80. }
  81. /**
  82. * EOL stream conversion protocol.
  83. *
  84. * @since 4.3
  85. */
  86. public enum EolStreamType {
  87. /** Convert to CRLF without binary detection. */
  88. TEXT_CRLF,
  89. /** Convert to LF without binary detection. */
  90. TEXT_LF,
  91. /** Convert to CRLF with binary detection. */
  92. AUTO_CRLF,
  93. /** Convert to LF with binary detection. */
  94. AUTO_LF,
  95. /** Do not convert. */
  96. DIRECT;
  97. }
  98. /**
  99. * Permissible values for {@code core.checkstat}.
  100. *
  101. * @since 3.0
  102. */
  103. public enum CheckStat {
  104. /**
  105. * Only check the size and whole second part of time stamp when
  106. * comparing the stat info in the dircache with actual file stat info.
  107. */
  108. MINIMAL,
  109. /**
  110. * Check as much of the dircache stat info as possible. Implementation
  111. * limits may apply.
  112. */
  113. DEFAULT
  114. }
  115. /**
  116. * Permissible values for {@code core.logAllRefUpdates}.
  117. *
  118. * @since 5.6
  119. */
  120. public enum LogRefUpdates {
  121. /** Don't create ref logs; default for bare repositories. */
  122. FALSE,
  123. /**
  124. * Create ref logs for refs/heads/**, refs/remotes/**, refs/notes/**,
  125. * and for HEAD. Default for non-bare repositories.
  126. */
  127. TRUE,
  128. /** Create ref logs for all refs/** and for HEAD. */
  129. ALWAYS
  130. }
  131. private final int compression;
  132. private final int packIndexVersion;
  133. private final LogRefUpdates logAllRefUpdates;
  134. private final String excludesfile;
  135. private final String attributesfile;
  136. /**
  137. * Options for symlink handling
  138. *
  139. * @since 3.3
  140. */
  141. public enum SymLinks {
  142. /** Check out symbolic links as plain files . */
  143. FALSE,
  144. /** Check out symbolic links as links. */
  145. TRUE
  146. }
  147. /**
  148. * Options for hiding files whose names start with a period.
  149. *
  150. * @since 3.5
  151. */
  152. public enum HideDotFiles {
  153. /** Do not hide .files. */
  154. FALSE,
  155. /** Hide add .files. */
  156. TRUE,
  157. /** Hide only .git. */
  158. DOTGITONLY
  159. }
  160. private CoreConfig(Config rc) {
  161. compression = rc.getInt(ConfigConstants.CONFIG_CORE_SECTION,
  162. ConfigConstants.CONFIG_KEY_COMPRESSION, DEFAULT_COMPRESSION);
  163. packIndexVersion = rc.getInt(ConfigConstants.CONFIG_PACK_SECTION,
  164. ConfigConstants.CONFIG_KEY_INDEXVERSION, 2);
  165. logAllRefUpdates = rc.getEnum(ConfigConstants.CONFIG_CORE_SECTION, null,
  166. ConfigConstants.CONFIG_KEY_LOGALLREFUPDATES,
  167. LogRefUpdates.TRUE);
  168. excludesfile = rc.getString(ConfigConstants.CONFIG_CORE_SECTION, null,
  169. ConfigConstants.CONFIG_KEY_EXCLUDESFILE);
  170. attributesfile = rc.getString(ConfigConstants.CONFIG_CORE_SECTION,
  171. null, ConfigConstants.CONFIG_KEY_ATTRIBUTESFILE);
  172. }
  173. /**
  174. * Get the compression level to use when storing loose objects
  175. *
  176. * @return The compression level to use when storing loose objects
  177. */
  178. public int getCompression() {
  179. return compression;
  180. }
  181. /**
  182. * Get the preferred pack index file format; 0 for oldest possible.
  183. *
  184. * @return the preferred pack index file format; 0 for oldest possible.
  185. */
  186. public int getPackIndexVersion() {
  187. return packIndexVersion;
  188. }
  189. /**
  190. * Whether to log all refUpdates
  191. *
  192. * @return whether to log all refUpdates
  193. * @deprecated since 5.6; default value depends on whether the repository is
  194. * bare. Use
  195. * {@link Config#getEnum(String, String, String, Enum)}
  196. * directly.
  197. */
  198. @Deprecated
  199. public boolean isLogAllRefUpdates() {
  200. return !LogRefUpdates.FALSE.equals(logAllRefUpdates);
  201. }
  202. /**
  203. * Get path of excludesfile
  204. *
  205. * @return path of excludesfile
  206. */
  207. public String getExcludesFile() {
  208. return excludesfile;
  209. }
  210. /**
  211. * Get path of attributesfile
  212. *
  213. * @return path of attributesfile
  214. * @since 3.7
  215. */
  216. public String getAttributesFile() {
  217. return attributesfile;
  218. }
  219. }