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

Re: [PATCH] checkout: most of the time we have good leading directories

From
Thomas Rast <tr@thomasrast.ch>
Date
Nov 9, 2013, 14:24 UTC
Message-ID
<87iow1ps9t.fsf@linux-k42r.v.cablecom.net>
In-Reply-To
<xmqqy54zohux.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 13 quoted lines
> When "git checkout" wants to create a path, e.g. a/b/c/d/e, after
> seeing if the entire thing already exists (in which case we check if
> that is up-to-date and do not bother to check it out, or we unlink
> and recreate it), we validate that the leading directory path is
> without funny symlinks by seeing a/, a/b/, a/b/c/ and then a/b/c/d/
> are all without funny symlinks, by calling has_dirs_only_path() in
> this order.
>
> When we are checking out many files (imagine: initial checkout),
> however, it is likely that an earlier checkout would have already
> made sure that the leading directory a/b/c/d/ is in good order; by
> first checking the whole path a/b/c/d/ first, we can often bypass
> calls to has_dirs_only_path() for leading part.

Naively one would think that this is just as much work -- to correctly verify that the path consist only of actual directories (not symlinks) we have to lstat() every component regardless. It seems the reason this is an optimization is that has_dirs_only_path() caches its results, so that we can get 'a/b/c/d/ is okay in every component' from the cache.

Is this analysis correct? If so, can you spell that out in the commit message?

-- 
Thomas Rast
tr@thomasrast.ch
Previous: Junio C HamanoNext: Junio C Hamano
Message 2 of 3 in “checkout: most of the time we have good leading directories”
  1. checkout: most of the time we have good leading directoriesJunio C Hamano, Nov 8, 2013
  2. Thomas RastNov 9, 2013
  3. Junio C HamanoNov 9, 2013

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.