Re: [JGIT PATCH 1/2] Add support for boolean config values "yes", "no"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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);

--
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

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]