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

[JGIT PATCH 2/6] Add setBoolean, setInt to RepositoryConfig

From
Shawn O. Pearce <spearce@spearce.org>
Date
Feb 12, 2009, 23:54 UTC
Message-ID
<1234482880-1316-3-git-send-email-spearce@spearce.org>
In-Reply-To
<1234482880-1316-2-git-send-email-spearce@spearce.org>

This makes it easier for application level code to make edits to the configuration file, especially when setting boolean or integers into any property.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../src/org/spearce/jgit/lib/RepositoryConfig.java |   57 ++++++++++++++++++++
 1 files changed, 57 insertions(+), 0 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java b/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java
index 821d8be..87535d1 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java
@@ -439,6 +439,63 @@ private Object getRawEntry(final String section, final String subsection,
 	/**
 	 * Add or modify a configuration value. The parameters will result in a
 	 * configuration entry like this.
+	 * 
+	 * <pre>
+	 * [section &quot;subsection&quot;]
+	 *         name = value
+	 * </pre>
+	 * 
+	 * @param section
+	 *            section name, e.g "branch"
+	 * @param subsection
+	 *            optional subsection value, e.g. a branch name
+	 * @param name
+	 *            parameter name, e.g. "filemode"
+	 * @param value
+	 *            parameter value
+	 */
+	public void setInt(final String section, final String subsection,
+			final String name, final int value) {
+		final String s;
+
+		if ((value % (1024 * 1024 * 1024)) == 0)
+			s = String.valueOf(value / (1024 * 1024 * 1024)) + " g";
+		else if ((value % (1024 * 1024)) == 0)
+			s = String.valueOf(value / (1024 * 1024)) + " m";
+		else if ((value % 1024) == 0)
+			s = String.valueOf(value / 1024) + " k";
+		else
+			s = String.valueOf(value);
+
+		setString(section, subsection, name, s);
+	}
+
+	/**
+	 * Add or modify a configuration value. The parameters will result in a
+	 * configuration entry like this.
+	 *
+	 * <pre>
+	 * [section &quot;subsection&quot;]
+	 *         name = value
+	 * </pre>
+	 *
+	 * @param section
+	 *            section name, e.g "branch"
+	 * @param subsection
+	 *            optional subsection value, e.g. a branch name
+	 * @param name
+	 *            parameter name, e.g. "filemode"
+	 * @param value
+	 *            parameter value
+	 */
+	public void setBoolean(final String section, final String subsection,
+			final String name, final boolean value) {
+		setString(section, subsection, name, value ? "true" : "false");
+	}
+
+	/**
+	 * Add or modify a configuration value. The parameters will result in a
+	 * configuration entry like this.
 	 *
 	 * <pre>
 	 * [section &quot;subsection&quot;]
-- 
1.6.2.rc0.226.gf08f
Previous: Shawn O. PearceNext: Shawn O. Pearce
Message 3 of 10 in “Add prune of stale tracking branches to fetch”
  1. 0/6 Add prune of stale tracking branches to fetchShawn O. Pearce, Feb 12, 2009
  2. 1/6 Fix RefUpdate.delete to update the result statusShawn O. Pearce, Feb 12, 2009
  3. 2/6 Add setBoolean, setInt to RepositoryConfigShawn O. Pearce, Feb 12, 2009
  4. 3/6 Add RefSpec.expandFromDestination for reverse mappingsShawn O. Pearce, Feb 12, 2009
  5. 4/6 Add the remote.name.mirror flag to RemoteConfigShawn O. Pearce, Feb 12, 2009
  6. 5/6 Don't pass TagOpt to FetchProcess, get it from the TransportShawn O. Pearce, Feb 12, 2009
  7. 6/6 Teach fetch to prune stale tracking branchesShawn O. Pearce, Feb 12, 2009
  8. Junio C HamanoFeb 13, 2009
  9. Shawn O. PearceFeb 13, 2009
  10. Junio C HamanoFeb 13, 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.