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

Re: [JGIT PATCH 3/4] The git config file is case insensitive

From
Shawn O. Pearce <spearce@spearce.org>
Date
Oct 13, 2008, 02:36 UTC
Message-ID
<20081013023636.GK4856@spearce.org>
In-Reply-To
<1223851860-13068-4-git-send-email-robin.rosenberg@dewire.com>
Robin Rosenberg <robin.rosenberg@dewire.com> wrote:
Show 16 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 45c2f8a..7a34cde 100644
> --- a/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java
> +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java
> @@ -682,7 +683,12 @@ public void load() throws IOException {
>  
>  	private void clear() {
>  		entries = new ArrayList<Entry>();
> -		byName = new HashMap<String, Object>();
> +		byName = new TreeMap<String, Object>(new Comparator<String>() {
> +
> +			public int compare(String o1, String o2) {
> +				return o1.compareToIgnoreCase(o2);
> +			}
> +		});
>  	}

This isn't necessary. Everyone who does a get or a put against the byName map already is forming a lower case key string. I'd rather keep the lookup O(1) than O(log N), especially if the code has a ton of .toLowerCase() calls in it to normalize the keys.

If you are going to change it to a TreeMap with a custom Comparator then maybe we should cleanup the code that operates on byName so it can use the original input strings, instead of the .toLowerCase() forms.

For now I'm going to apply your patch without this one hunk.  If you
want to switch to a TreeMap lets also cleanup the get/put calls.
  
-- 
Shawn.
Previous: Robin Rosenberg
Message 8 of 8 in “Decodings”
  1. 0/4 DecodingsRobin Rosenberg, Oct 12, 2008
  2. 1/4 log command: Use explicit US locale for datesRobin Rosenberg, Oct 12, 2008
  3. 2/4 jgit programs: Use i18n.logOutputEncoding or user's locale for outputRobin Rosenberg, Oct 12, 2008
  4. 3/4 The git config file is case insensitiveRobin Rosenberg, Oct 12, 2008
  5. 4/4 Intelligent parsing of ambiguously encoded meta data.Robin Rosenberg, Oct 12, 2008
  6. Shawn O. PearceOct 13, 2008
  7. Robin RosenbergOct 13, 2008
  8. Shawn O. PearceOct 13, 2008

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.