git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[JGIT PATCH 04/19] Allow a RemoteConfig to use the more generic Config class

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jul 25, 2009, 18:52 UTC
Message-ID
<1248547982-4003-5-git-send-email-spearce@spearce.org>
In-Reply-To
<1248547982-4003-4-git-send-email-spearce@spearce.org>

A RemoteConfig can be parsed from any Config type object, not just the RepositoryConfig object. This change makes it easier to use other types of Config storage, such as in unit tests.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../org/spearce/jgit/transport/RemoteConfig.java   |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/RemoteConfig.java b/org.spearce.jgit/src/org/spearce/jgit/transport/RemoteConfig.java
index 93a5873..ca84acf 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/RemoteConfig.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/RemoteConfig.java
@@ -43,6 +43,7 @@
 import java.util.Collections;
 import java.util.List;
 
+import org.spearce.jgit.lib.Config;
 import org.spearce.jgit.lib.RepositoryConfig;
 
 /**
@@ -143,7 +144,7 @@
 	 * @throws URISyntaxException
 	 *             one of the URIs within the remote's configuration is invalid.
 	 */
-	public RemoteConfig(final RepositoryConfig rc, final String remoteName)
+	public RemoteConfig(final Config rc, final String remoteName)
 			throws URISyntaxException {
 		name = remoteName;
 
@@ -192,7 +193,7 @@ public RemoteConfig(final RepositoryConfig rc, final String remoteName)
 	 * @param rc
 	 *            the configuration file to store ourselves into.
 	 */
-	public void update(final RepositoryConfig rc) {
+	public void update(final Config rc) {
 		final List<String> vlst = new ArrayList<String>();
 
 		vlst.clear();
@@ -222,7 +223,7 @@ public void update(final RepositoryConfig rc) {
 		set(rc, KEY_TIMEOUT, timeout, 0);
 	}
 
-	private void set(final RepositoryConfig rc, final String key,
+	private void set(final Config rc, final String key,
 			final String currentValue, final String defaultValue) {
 		if (defaultValue.equals(currentValue))
 			unset(rc, key);
@@ -230,7 +231,7 @@ private void set(final RepositoryConfig rc, final String key,
 			rc.setString(SECTION, getName(), key, currentValue);
 	}
 
-	private void set(final RepositoryConfig rc, final String key,
+	private void set(final Config rc, final String key,
 			final boolean currentValue, final boolean defaultValue) {
 		if (defaultValue == currentValue)
 			unset(rc, key);
@@ -238,15 +239,15 @@ private void set(final RepositoryConfig rc, final String key,
 			rc.setBoolean(SECTION, getName(), key, currentValue);
 	}
 
-	private void set(final RepositoryConfig rc, final String key,
-			final int currentValue, final int defaultValue) {
+	private void set(final Config rc, final String key, final int currentValue,
+			final int defaultValue) {
 		if (defaultValue == currentValue)
 			unset(rc, key);
 		else
 			rc.setInt(SECTION, getName(), key, currentValue);
 	}
 
-	private void unset(final RepositoryConfig rc, final String key) {
+	private void unset(final Config rc, final String key) {
 		rc.unset(SECTION, getName(), key);
 	}
 
-- 
1.6.4.rc2.216.g769fa
Previous: Shawn O. PearceNext: Shawn O. Pearce
Message 5 of 26 in “More Config class cleanup work”
  1. 00/19 More Config class cleanup workShawn O. Pearce, Jul 25, 2009
  2. 01/19 Cleanup nonstandard references to encoding strings to bytesShawn O. Pearce, Jul 25, 2009
  3. 02/19 Delete incorrect Javadoc from Config's getRawString methodShawn O. Pearce, Jul 25, 2009
  4. 03/19 Make Config.escapeValue a private methodShawn O. Pearce, Jul 25, 2009
  5. 04/19 Allow a RemoteConfig to use the more generic Config classShawn O. Pearce, Jul 25, 2009
  6. 05/19 Use type specific sets when creating a new RepositoryConfigShawn O. Pearce, Jul 25, 2009
  7. 06/19 Move SystemReader out of RepositoryConfigShawn O. Pearce, Jul 25, 2009
  8. 07/19 Correct user config to be of type FileBasedConfigShawn O. Pearce, Jul 25, 2009
  9. 08/19 Extract the test specific SystemReader out of RepositoryTestCaseShawn O. Pearce, Jul 25, 2009
  10. 09/19 Refactor Config hierarchy to make IO more explicitShawn O. Pearce, Jul 25, 2009
  11. 10/19 Test for the config file when creating a new repositoryShawn O. Pearce, Jul 25, 2009
  12. 11/19 Remove the map lookup for values in ConfigShawn O. Pearce, Jul 25, 2009
  13. 12/19 Return base values first from Config.getStringList()Shawn O. Pearce, Jul 25, 2009
  14. 13/19 Make Config thread safe by using copy-on-write semanticsShawn O. Pearce, Jul 25, 2009
  15. 14/19 Support cached application models in a ConfigShawn O. Pearce, Jul 25, 2009
  16. 15/19 Cache Config subsection names when requested by application codeShawn O. Pearce, Jul 25, 2009
  17. 16/19 Refactor author/committer lookup to use cached dataShawn O. Pearce, Jul 25, 2009
  18. 17/19 Move repository config creation fully into Repository classShawn O. Pearce, Jul 25, 2009
  19. 18/19 Use Config SectionParser cache to store daemon enable statesShawn O. Pearce, Jul 25, 2009
  20. 19/19 Use Config cache for fetch and receive configuration parsingShawn O. Pearce, Jul 25, 2009
  21. Robin RosenbergJul 25, 2009
  22. Shawn O. PearceJul 25, 2009
  23. Robin RosenbergJul 25, 2009
  24. Shawn O. PearceJul 25, 2009
  25. Robin RosenbergJul 25, 2009
  26. Shawn O. PearceJul 25, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.