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 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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 = new SectionParser<CoreConfig>() {
  57. public CoreConfig parse(final Config cfg) {
  58. return new CoreConfig(cfg);
  59. }
  60. };
  61. /** Permissible values for {@code core.autocrlf}. */
  62. public static enum AutoCRLF {
  63. /** Automatic CRLF-&gt;LF conversion is disabled. */
  64. FALSE,
  65. /** Automatic CRLF-&gt;LF conversion is enabled. */
  66. TRUE,
  67. /** CRLF-&gt;LF performed, but no LF-&gt;CRLF. */
  68. INPUT;
  69. }
  70. /**
  71. * Permissible values for {@code core.eol}.
  72. * <p>
  73. * https://git-scm.com/docs/gitattributes
  74. *
  75. * @since 4.3
  76. */
  77. public static enum EOL {
  78. /** checkin with LF, checkout with CRLF. */
  79. CRLF,
  80. /** checkin with LF, checkout without conversion. */
  81. LF,
  82. /** use the platform's native line ending. */
  83. NATIVE;
  84. }
  85. /**
  86. * EOL stream conversion protocol
  87. *
  88. * @since 4.3
  89. */
  90. public static enum EolStreamType {
  91. /** convert to CRLF without binary detection */
  92. TEXT_CRLF,
  93. /** convert to LF without binary detection */
  94. TEXT_LF,
  95. /** convert to CRLF with binary detection */
  96. AUTO_CRLF,
  97. /** convert to LF with binary detection */
  98. AUTO_LF,
  99. /** do not convert */
  100. DIRECT;
  101. }
  102. /**
  103. * Permissible values for {@code core.checkstat}
  104. *
  105. * @since 3.0
  106. */
  107. public static enum CheckStat {
  108. /**
  109. * Only check the size and whole second part of time stamp when
  110. * comparing the stat info in the dircache with actual file stat info.
  111. */
  112. MINIMAL,
  113. /**
  114. * Check as much of the dircache stat info as possible. Implementation
  115. * limits may apply.
  116. */
  117. DEFAULT
  118. }
  119. private final int compression;
  120. private final int packIndexVersion;
  121. private final boolean logAllRefUpdates;
  122. private final String excludesfile;
  123. private final String attributesfile;
  124. /**
  125. * Options for symlink handling
  126. *
  127. * @since 3.3
  128. */
  129. public static enum SymLinks {
  130. /** Checkout symbolic links as plain files */
  131. FALSE,
  132. /** Checkout symbolic links as links */
  133. TRUE
  134. }
  135. /**
  136. * Options for hiding files whose names start with a period
  137. *
  138. * @since 3.5
  139. */
  140. public static enum HideDotFiles {
  141. /** Do not hide .files */
  142. FALSE,
  143. /** Hide add .files */
  144. TRUE,
  145. /** Hide only .git */
  146. DOTGITONLY
  147. }
  148. private CoreConfig(final Config rc) {
  149. compression = rc.getInt(ConfigConstants.CONFIG_CORE_SECTION,
  150. ConfigConstants.CONFIG_KEY_COMPRESSION, DEFAULT_COMPRESSION);
  151. packIndexVersion = rc.getInt(ConfigConstants.CONFIG_PACK_SECTION,
  152. ConfigConstants.CONFIG_KEY_INDEXVERSION, 2);
  153. logAllRefUpdates = rc.getBoolean(ConfigConstants.CONFIG_CORE_SECTION,
  154. ConfigConstants.CONFIG_KEY_LOGALLREFUPDATES, true);
  155. excludesfile = rc.getString(ConfigConstants.CONFIG_CORE_SECTION, null,
  156. ConfigConstants.CONFIG_KEY_EXCLUDESFILE);
  157. attributesfile = rc.getString(ConfigConstants.CONFIG_CORE_SECTION,
  158. null, ConfigConstants.CONFIG_KEY_ATTRIBUTESFILE);
  159. }
  160. /**
  161. * @return The compression level to use when storing loose objects
  162. */
  163. public int getCompression() {
  164. return compression;
  165. }
  166. /**
  167. * @return the preferred pack index file format; 0 for oldest possible.
  168. */
  169. public int getPackIndexVersion() {
  170. return packIndexVersion;
  171. }
  172. /**
  173. * @return whether to log all refUpdates
  174. */
  175. public boolean isLogAllRefUpdates() {
  176. return logAllRefUpdates;
  177. }
  178. /**
  179. * @return path of excludesfile
  180. */
  181. public String getExcludesFile() {
  182. return excludesfile;
  183. }
  184. /**
  185. * @return path of attributesfile
  186. * @since 3.7
  187. */
  188. public String getAttributesFile() {
  189. return attributesfile;
  190. }
  191. }