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

Re: [PATCH 7/7] Make unpack-tree update removed files before any updated files

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 23, 2008, 05:49 UTC
Message-ID
<7vbq56f0qm.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<alpine.LFD.1.00.0803221038320.3020@woody.linux-foundation.org>
Linus Torvalds <torvalds@linux-foundation.org> writes:
Show 6 quoted lines
> Ok, this one looks - and is, really - trivial, but it's actually the only 
> one in the whole series that I'm even remotely nervous about. First off, 
> it actually does what it does regardless of that "core.ignorecase" 
> variable, but that wouldn't worry me if it wasn't for the fact that I 
> don't remember/understand what the heck that "last_symlink" logic was 
> there for.

last_symlink is just a cached information used by underlying has_symlink_leading_path() function for optimization.

The motivation behind has_symlink_leading_path() is reasonably well described in

 - f859c84: Add has_symlink_leading_path() function., 2007-05-11,
 - 64cab59: apply: do not get confused by symlinks in the middle,
   2007-05-11, and
 - 16a4c61: read-tree -m -u: avoid getting confused by intermediate
   symlinks., 2007-05-10
The short version is that:
 - sometimes we want to make sure a path a/b/c/d exists (or does not
   exist) in the work tree;
 - however, !lstat("a/b/c/d") is not quite it.  if a/b is a symlink in the
   work tree that points at somewhere that happens to have c/d underneath,
   !lstat() says "yeah, there is", but that one is _different_ from what
   checking out a cache entry a/b/c/d would produce (because in that case
   we will remove a/b symlink, create a/b/ directory and deposit blob b
   there).
 - So we often need to see if a given path has symlink component in the
   leading part in the work tree (e.g. given "a/b/c/d", we would need to
   check if any of "a", "a/b", "a/b/c" is a symlink).

The function has_symlink_leading_path() answers that question, and its second argument is a buffer to cache "the last work tree path found to be a symlink", so if you call it with "a/b/c/d" and then with "a/b/c/e" in the above example situation, the second call can re-use the information the first call found out, which is "a/b is a symlink".

I do not think your patch breaks the passing around of last_symlink cached information. Although the three commits I quoted above are all backed by real-world breakage cases that they did fix, the issues they deal with are indeed tricky cases. Although your patch (the change in 7/7) should not make any difference to the issues, thinking about them is already making me feel nervous.

Previous: Linus TorvaldsNext: Junio C Hamano
Message 13 of 29 in “Case-insensitive filesystem support, take 1”
  1. 0/7 Case-insensitive filesystem support, take 1Linus Torvalds, Mar 22, 2008
  2. 1/7 Make unpack_trees_options bit flags actual bitfieldsLinus Torvalds, Mar 22, 2008
  3. 2/7 Move name hashing functions into a file of its ownLinus Torvalds, Mar 22, 2008
  4. 3/7 Make "index_name_exists()" return the cache_entry it foundLinus Torvalds, Mar 22, 2008
  5. 4/7 Make hash_name_lookup able to do case-independent lookupsLinus Torvalds, Mar 22, 2008
  6. 5/7 Add 'core.ignorecase' optionLinus Torvalds, Mar 22, 2008
  7. 6/7 Make branch merging aware of underlying case-insensitive filsystemsLinus Torvalds, Mar 22, 2008
  8. 7/7 Make unpack-tree update removed files before any updated filesLinus Torvalds, Mar 22, 2008
  9. 0/7 Final wordsLinus Torvalds, Mar 22, 2008
  10. Linus TorvaldsMar 22, 2008
  11. 8/7 When adding files to the index, add support for case-independent matchesLinus Torvalds, Mar 22, 2008
  12. 9/7 Make git-add behave more sensibly in a case-insensitive environmentLinus Torvalds, Mar 22, 2008
  13. Junio C HamanoMar 23, 2008
  14. Junio C HamanoMar 23, 2008
  15. Linus TorvaldsMar 23, 2008
  16. Johannes SchindelinMar 22, 2008
  17. Linus TorvaldsMar 22, 2008
  18. Johannes SchindelinMar 22, 2008
  19. t0050: Set core.ignorecase case to activate case insensitivitySteffen Prohaska, Mar 22, 2008
  20. git-init: autodetect core.ignorecaseDmitry Potapov, Mar 25, 2008
  21. Johannes SchindelinMar 25, 2008
  22. git-init: autodetect core.ignorecaseDmitry Potapov, Mar 25, 2008
  23. Dmitry PotapovMar 25, 2008
  24. Dmitry PotapovMar 25, 2008
  25. Linus TorvaldsMar 25, 2008
  26. Dmitry PotapovMar 26, 2008
  27. Linus TorvaldsMar 26, 2008
  28. Derek FawcusMar 25, 2008
  29. Jan HudecMar 25, 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.