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

Re: [PATCH v2 2/2] checkout: fix regression in checkout -b on intitial checkout

From
Jeff King <peff@peff.net>
Date
Jan 22, 2019, 18:49 UTC
Message-ID
<20190122184959.GF4399@sigill.intra.peff.net>
In-Reply-To
<nycvar.QRO.7.76.6.1901221529210.41@tvgsbejvaqbjf.bet>
On Tue, Jan 22, 2019 at 03:35:21PM +0100, Johannes Schindelin wrote:
Show 5 quoted lines
> I also looked at the implementation of `file_exists()` and found that it
> uses `lstat()`. Peff, you introduced this (using `stat()`) in c91f0d92efb3
> (git-commit.sh: convert run_status to a C builtin, 2006-09-08), could you
> enlighten me why you chose `stat()` over `access()` (the latter seems more
> light-weight to me)?

That's quite a while ago, but I'm pretty sure I was just following existing practice. It would be fine to switch from stat() to access(). But...

> Also, Junio, you changed it to use `lstat()` in
> a50f9fc5feb0 (file_exists(): dangling symlinks do exist, 2007-11-18), do
> you think we can/should use `access()` instead?

I think access() will always dereference. So it would not detect a dangling symlink. Whether that matters or not is going to depend on each caller.

I doubt it would matter much either way in this case. And I don't think this is performance critical (it should be once per checkout, not once per file).

If there are callers that care (and I assume there are due to the existence of a50f9fcfeb0), and if we do care about performance on platforms where stat() is slower, it might be reasonable to have a platform-specific implementation of file_exists().

Likewise, anybody converting from access() should consider whether each site cares about dangling symlinks (though in general, I'd expect most of them to simply not have thought of it, and be happy to start considering that as "exists").

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 23 of 30 in “Regression `git checkout $rev -b branch` while in a `--no-checkout` clone does not check out files”
  1. Anthony SottileJan 1, 2019
  2. Duy NguyenJan 2, 2019
  3. Anthony SottileJan 2, 2019
  4. Duy NguyenJan 3, 2019
  5. Junio C HamanoJan 3, 2019
  6. Anthony SottileJan 3, 2019
  7. Junio C HamanoJan 3, 2019
  8. Anthony SottileJan 3, 2019
  9. Ben PeartJan 16, 2019
  10. 0/2 Fix regression in checkout -bBen Peart, Jan 18, 2019
  11. 1/2 checkout: add test to demonstrate regression with checkout -b on initial commitBen Peart, Jan 18, 2019
  12. SZEDER GáborJan 18, 2019
  13. 2/2 checkout: fix regression in checkout -b on intitial checkoutBen Peart, Jan 18, 2019
  14. Junio C HamanoJan 18, 2019
  15. SZEDER GáborJan 19, 2019
  16. Junio C HamanoJan 19, 2019
  17. 0/2 Fix regression in checkout -bBen Peart, Jan 21, 2019
  18. 1/2 checkout: add test to demonstrate regression with checkout -b on initial commitBen Peart, Jan 21, 2019
  19. SZEDER GáborJan 23, 2019
  20. 2/2 checkout: fix regression in checkout -b on intitial checkoutBen Peart, Jan 21, 2019
  21. Johannes SchindelinJan 22, 2019
  22. Junio C HamanoJan 22, 2019
  23. Jeff KingJan 22, 2019
  24. Junio C HamanoJan 22, 2019
  25. Ben PeartJan 22, 2019
  26. Junio C HamanoJan 23, 2019
  27. 0/2 Fix regression in checkout -bBen Peart, Jan 23, 2019
  28. 1/2 checkout: add test demonstrating regression with checkout -b on initial commitBen Peart, Jan 23, 2019
  29. 2/2 checkout: fix regression in checkout -b on intitial checkoutBen Peart, Jan 23, 2019
  30. Junio C HamanoJan 23, 2019

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.