From: "Shawn O. Pearce" <spearce@spearce.org>
To: Robin Rosenberg <robin.rosenberg@dewire.com>
Cc: git@vger.kernel.org
Subject: [JGIT PATCH 2/6] Add setBoolean, setInt to RepositoryConfig
Date: Thu, 12 Feb 2009 15:54:36 -0800 [thread overview]
Message-ID: <1234482880-1316-3-git-send-email-spearce@spearce.org> (raw)
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 "subsection"]
+ * 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 "subsection"]
+ * 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 "subsection"]
--
1.6.2.rc0.226.gf08f
next prev parent reply other threads:[~2009-02-12 23:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-12 23:54 [JGIT PATCH 0/6] Add prune of stale tracking branches to fetch Shawn O. Pearce
2009-02-12 23:54 ` [JGIT PATCH 1/6] Fix RefUpdate.delete to update the result status Shawn O. Pearce
2009-02-12 23:54 ` Shawn O. Pearce [this message]
2009-02-12 23:54 ` [JGIT PATCH 3/6] Add RefSpec.expandFromDestination for reverse mappings Shawn O. Pearce
2009-02-12 23:54 ` [JGIT PATCH 4/6] Add the remote.name.mirror flag to RemoteConfig Shawn O. Pearce
2009-02-12 23:54 ` [JGIT PATCH 5/6] Don't pass TagOpt to FetchProcess, get it from the Transport Shawn O. Pearce
2009-02-12 23:54 ` [JGIT PATCH 6/6] Teach fetch to prune stale tracking branches Shawn O. Pearce
2009-02-13 0:37 ` [JGIT PATCH 0/6] Add prune of stale tracking branches to fetch Junio C Hamano
2009-02-13 0:42 ` Shawn O. Pearce
2009-02-13 0:48 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1234482880-1316-3-git-send-email-spearce@spearce.org \
--to=spearce@spearce.org \
--cc=git@vger.kernel.org \
--cc=robin.rosenberg@dewire.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).