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@xxxxxxxxxxx> --- .../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 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html