Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add setBoolean, setInt to RepositoryConfig

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>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
  • Loading branch information...
commit 0414c6762fb91d04a52509dd8d0829774d304904 1 parent dcbb668
@spearce spearce authored robinrosenberg committed
Showing with 57 additions and 0 deletions.
  1. +57 −0 org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java
View
57 org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java
@@ -452,6 +452,63 @@ private Object getRawEntry(final String section, final String subsection,
* @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;]
+ * 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, e.g. "true"
*/
public void setString(final String section, final String subsection,
Please sign in to comment.
Something went wrong with that request. Please try again.