您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

CoreConfig.java 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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> and others
  8. *
  9. * This program and the accompanying materials are made available under the
  10. * terms of the Eclipse Distribution License v. 1.0 which is available at
  11. * https://www.eclipse.org/org/documents/edl-v10.php.
  12. *
  13. * SPDX-License-Identifier: BSD-3-Clause
  14. */
  15. package org.eclipse.jgit.lib;
  16. import static java.util.zip.Deflater.DEFAULT_COMPRESSION;
  17. import org.eclipse.jgit.lib.Config.SectionParser;
  18. /**
  19. * This class keeps git repository core parameters.
  20. */
  21. public class CoreConfig {
  22. /** Key for {@link Config#get(SectionParser)}. */
  23. public static final Config.SectionParser<CoreConfig> KEY = CoreConfig::new;
  24. /** Permissible values for {@code core.autocrlf}. */
  25. public enum AutoCRLF {
  26. /** Automatic CRLF-&gt;LF conversion is disabled. */
  27. FALSE,
  28. /** Automatic CRLF-&gt;LF conversion is enabled. */
  29. TRUE,
  30. /** CRLF-&gt;LF performed, but no LF-&gt;CRLF. */
  31. INPUT;
  32. }
  33. /**
  34. * Permissible values for {@code core.eol}.
  35. * <p>
  36. * https://git-scm.com/docs/gitattributes
  37. *
  38. * @since 4.3
  39. */
  40. public enum EOL {
  41. /** Check in with LF, check out with CRLF. */
  42. CRLF,
  43. /** Check in with LF, check out without conversion. */
  44. LF,
  45. /** Use the platform's native line ending. */
  46. NATIVE;
  47. }
  48. /**
  49. * EOL stream conversion protocol.
  50. *
  51. * @since 4.3
  52. */
  53. public enum EolStreamType {
  54. /** Convert to CRLF without binary detection. */
  55. TEXT_CRLF,
  56. /** Convert to LF without binary detection. */
  57. TEXT_LF,
  58. /** Convert to CRLF with binary detection. */
  59. AUTO_CRLF,
  60. /** Convert to LF with binary detection. */
  61. AUTO_LF,
  62. /** Do not convert. */
  63. DIRECT;
  64. }
  65. /**
  66. * Permissible values for {@code core.checkstat}.
  67. *
  68. * @since 3.0
  69. */
  70. public enum CheckStat {
  71. /**
  72. * Only check the size and whole second part of time stamp when
  73. * comparing the stat info in the dircache with actual file stat info.
  74. */
  75. MINIMAL,
  76. /**
  77. * Check as much of the dircache stat info as possible. Implementation
  78. * limits may apply.
  79. */
  80. DEFAULT
  81. }
  82. /**
  83. * Permissible values for {@code core.logAllRefUpdates}.
  84. *
  85. * @since 5.6
  86. */
  87. public enum LogRefUpdates {
  88. /** Don't create ref logs; default for bare repositories. */
  89. FALSE,
  90. /**
  91. * Create ref logs for refs/heads/**, refs/remotes/**, refs/notes/**,
  92. * and for HEAD. Default for non-bare repositories.
  93. */
  94. TRUE,
  95. /** Create ref logs for all refs/** and for HEAD. */
  96. ALWAYS
  97. }
  98. private final int compression;
  99. private final int packIndexVersion;
  100. private final LogRefUpdates logAllRefUpdates;
  101. private final String excludesfile;
  102. private final String attributesfile;
  103. /**
  104. * Options for symlink handling
  105. *
  106. * @since 3.3
  107. */
  108. public enum SymLinks {
  109. /** Check out symbolic links as plain files . */
  110. FALSE,
  111. /** Check out symbolic links as links. */
  112. TRUE
  113. }
  114. /**
  115. * Options for hiding files whose names start with a period.
  116. *
  117. * @since 3.5
  118. */
  119. public enum HideDotFiles {
  120. /** Do not hide .files. */
  121. FALSE,
  122. /** Hide add .files. */
  123. TRUE,
  124. /** Hide only .git. */
  125. DOTGITONLY
  126. }
  127. private CoreConfig(Config rc) {
  128. compression = rc.getInt(ConfigConstants.CONFIG_CORE_SECTION,
  129. ConfigConstants.CONFIG_KEY_COMPRESSION, DEFAULT_COMPRESSION);
  130. packIndexVersion = rc.getInt(ConfigConstants.CONFIG_PACK_SECTION,
  131. ConfigConstants.CONFIG_KEY_INDEXVERSION, 2);
  132. logAllRefUpdates = rc.getEnum(ConfigConstants.CONFIG_CORE_SECTION, null,
  133. ConfigConstants.CONFIG_KEY_LOGALLREFUPDATES,
  134. LogRefUpdates.TRUE);
  135. excludesfile = rc.getString(ConfigConstants.CONFIG_CORE_SECTION, null,
  136. ConfigConstants.CONFIG_KEY_EXCLUDESFILE);
  137. attributesfile = rc.getString(ConfigConstants.CONFIG_CORE_SECTION,
  138. null, ConfigConstants.CONFIG_KEY_ATTRIBUTESFILE);
  139. }
  140. /**
  141. * Get the compression level to use when storing loose objects
  142. *
  143. * @return The compression level to use when storing loose objects
  144. */
  145. public int getCompression() {
  146. return compression;
  147. }
  148. /**
  149. * Get the preferred pack index file format; 0 for oldest possible.
  150. *
  151. * @return the preferred pack index file format; 0 for oldest possible.
  152. */
  153. public int getPackIndexVersion() {
  154. return packIndexVersion;
  155. }
  156. /**
  157. * Whether to log all refUpdates
  158. *
  159. * @return whether to log all refUpdates
  160. * @deprecated since 5.6; default value depends on whether the repository is
  161. * bare. Use
  162. * {@link Config#getEnum(String, String, String, Enum)}
  163. * directly.
  164. */
  165. @Deprecated
  166. public boolean isLogAllRefUpdates() {
  167. return !LogRefUpdates.FALSE.equals(logAllRefUpdates);
  168. }
  169. /**
  170. * Get path of excludesfile
  171. *
  172. * @return path of excludesfile
  173. */
  174. public String getExcludesFile() {
  175. return excludesfile;
  176. }
  177. /**
  178. * Get path of attributesfile
  179. *
  180. * @return path of attributesfile
  181. * @since 3.7
  182. */
  183. public String getAttributesFile() {
  184. return attributesfile;
  185. }
  186. }