git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
May 7, 2009, 17:56 UTC
Message-ID
<eOxTQ_L3wmawK8rFbXMLnksiI7lh8eiyptpquFGaI28e3RO7dN9GMw@cipher.nrlssc.navy.mil>
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
Show 26 quoted lines
> 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);
Previous: Shawn O. PearceNext: Shawn O. Pearce
Message 13 of 18 in “Add support for boolean config values "yes", "no"”
  1. 1/2 Add support for boolean config values "yes", "no"Shawn O. Pearce, May 7, 2009
  2. 2/2 Make Repository.isValidRefName compatible with Git 1.6.3Shawn O. Pearce, May 7, 2009
  3. Robin RosenbergMay 7, 2009
  4. Linus TorvaldsMay 7, 2009
  5. Junio C HamanoMay 8, 2009
  6. Shawn O. PearceMay 8, 2009
  7. Alex RiesenMay 8, 2009
  8. Johannes SchindelinMay 8, 2009
  9. Junio C HamanoMay 8, 2009
  10. Johannes SchindelinMay 8, 2009
  11. Alex RiesenMay 8, 2009
  12. Shawn O. PearceMay 8, 2009
  13. Brandon CaseyMay 7, 2009
  14. 1/2 Add support for boolean config values "on", "off"Shawn O. Pearce, May 7, 2009
  15. Shawn O. PearceMay 8, 2009
  16. Junio C HamanoMay 8, 2009
  17. Shawn O. PearceMay 8, 2009
  18. Junio C HamanoMay 8, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.