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

Re: [PATCH 2/2] Cached the git configuration, which is now noticibly faster on windows.

From
Jakub Narebski <jnareb@gmail.com>
Date
Nov 8, 2008, 10:13 UTC
Message-ID
<m3mygaeda0.fsf@localhost.localdomain>
In-Reply-To
<ee77f5c20811072119y65738f54o7e6792fb405c142c@mail.gmail.com>
"David Symonds" <dsymonds@gmail.com> writes:
Show 18 quoted lines
> On Fri, Nov 7, 2008 at 7:22 PM, John Chapman <thestar@fussycoder.id.au> wrote:
> 
> > +_gitConfig = {}
> >  def gitConfig(key):
> > -    return read_pipe("git config %s" % key, ignore_error=True).strip()
> > +    if not _gitConfig.has_key(key):
> > +        _gitConfig[key] = read_pipe("git config %s" % key, ignore_error=True).strip()
> > +    return _gitConfig[key]
> 
> If this is truly a noticeable bottleneck on Windows, something like
> the following might be even better:  (completely untested!)
> 
> _gitConfig = None
> def gitConfig(key):
>   if _gitConfig is None:
>     lines = read_pipe("git config -l", ignore_error=True).readlines():
>     _gitConfig = dict([l.strip().split('=', 1) for l in lines])
>   return _gitConfig.get(key, None)

Wouldn't it be better to use "git config -l -z", split lines at "\0" (NUL), and split key from value at first "\N" (CR)? This format was meant for scripts.

-- 
Jakub Narebski
Poland
ShadeHawk on #git
Previous: Steve FrécinauxNext: Junio C Hamano
Message 6 of 11 in “Added support for purged files and also optimised memory usage.”
  1. 1/2 Added support for purged files and also optimised memory usage.John Chapman, Nov 8, 2008
  2. 2/2 Cached the git configuration, which is now noticibly faster on windows.John Chapman, Nov 8, 2008
  3. David SymondsNov 8, 2008
  4. ArafangionNov 8, 2008
  5. Steve FrécinauxNov 10, 2008
  6. Jakub NarebskiNov 8, 2008
  7. Junio C HamanoNov 9, 2008
  8. Han-Wen NienhuysNov 10, 2008
  9. Simon HausmannNov 10, 2008
  10. Junio C HamanoNov 12, 2008
  11. ArafangionNov 12, 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.