From: Brandon Casey Date: Thu, 07 May 2009 17:56:15 GMT Subject: Re: [JGIT PATCH 1/2] Add support for boolean config values "yes", "no" Message-ID: In-Reply-To: <1241708714-20326-1-git-send-email-spearce@spearce.org> Shawn O. Pearce wrote: > In 8f8c6fafd92f (shipped in 1.6.3) Linus taught C Git how to read > boolean configuration values set to "yes" as true and "no" as false. > Add support for these values, and some test cases. Linus added support for "on" and "off" in that commit as it appears your commit is also doing. :) I was about to point out that you are not ignoring case for "on", but using equalsIgnoreCase() appears to be unnecessary since above that you are already doing n = n.toLowerCase(). -brandon > 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 cb287ee..e3a303f 100644 > --- a/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java > +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java > @@ -254,10 +254,19 @@ public boolean getBoolean(final String section, String subsection, > return defaultValue; > > n = n.toLowerCase(); > - if (MAGIC_EMPTY_VALUE.equals(n) || "yes".equalsIgnoreCase(n) || "true".equalsIgnoreCase(n) || "1".equals(n)) { > + if (MAGIC_EMPTY_VALUE.equals(n) > + || "yes".equalsIgnoreCase(n) > + || "true".equalsIgnoreCase(n) > + || "1".equals(n) > + || "on".equals(n)) { > return true; > - } else if ("no".equalsIgnoreCase(n) || "false".equalsIgnoreCase(n) || "0".equalsIgnoreCase(n)) { > + > + } else if ("no".equalsIgnoreCase(n) > + || "false".equalsIgnoreCase(n) > + || "0".equalsIgnoreCase(n) > + || "off".equalsIgnoreCase(n)) { > return false; > + > } else { > throw new IllegalArgumentException("Invalid boolean value: " > + section + "." + name + "=" + n);