git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Ben Peart <peartben@gmail.com>,
	git@vger.kernel.org, asottile@umich.edu, benpeart@microsoft.com,
	gitster@pobox.com, pclouds@gmail.com
Subject: Re: [PATCH v2 2/2] checkout: fix regression in checkout -b on intitial checkout
Date: Tue, 22 Jan 2019 13:49:59 -0500	[thread overview]
Message-ID: <20190122184959.GF4399@sigill.intra.peff.net> (raw)
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:

> 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

  parent reply	other threads:[~2019-01-22 18:50 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-01 23:17 Regression `git checkout $rev -b branch` while in a `--no-checkout` clone does not check out files Anthony Sottile
2019-01-02 11:08 ` Duy Nguyen
2019-01-02 16:18   ` Anthony Sottile
2019-01-03 10:04     ` Duy Nguyen
2019-01-03 20:25       ` Junio C Hamano
2019-01-03 20:35         ` Anthony Sottile
2019-01-03 21:51           ` Junio C Hamano
2019-01-03 22:05             ` Anthony Sottile
2019-01-16 14:39               ` Ben Peart
2019-01-18 18:55 ` [PATCH v1 0/2] Fix regression in checkout -b Ben Peart
2019-01-18 18:55   ` [PATCH v1 1/2] checkout: add test to demonstrate regression with checkout -b on initial commit Ben Peart
2019-01-18 19:23     ` SZEDER Gábor
2019-01-18 18:55   ` [PATCH v1 2/2] checkout: fix regression in checkout -b on intitial checkout Ben Peart
2019-01-18 20:00     ` Junio C Hamano
2019-01-19  0:52     ` SZEDER Gábor
2019-01-19  1:26   ` [PATCH v1 0/2] Fix regression in checkout -b Junio C Hamano
2019-01-21 19:50   ` [PATCH v2 " Ben Peart
2019-01-21 19:50     ` [PATCH v2 1/2] checkout: add test to demonstrate regression with checkout -b on initial commit Ben Peart
2019-01-23 17:57       ` SZEDER Gábor
2019-01-21 19:50     ` [PATCH v2 2/2] checkout: fix regression in checkout -b on intitial checkout Ben Peart
2019-01-22 14:35       ` Johannes Schindelin
2019-01-22 18:42         ` Junio C Hamano
2019-01-22 18:49         ` Jeff King [this message]
2019-01-22 18:54     ` [PATCH v2 0/2] Fix regression in checkout -b Junio C Hamano
2019-01-22 19:31       ` Ben Peart
2019-01-23 19:14         ` Junio C Hamano
2019-01-23 20:01   ` [PATCH v3 " Ben Peart
2019-01-23 20:02     ` [PATCH v3 1/2] checkout: add test demonstrating regression with checkout -b on initial commit Ben Peart
2019-01-23 20:02     ` [PATCH v3 2/2] checkout: fix regression in checkout -b on intitial checkout Ben Peart
2019-01-23 21:23     ` [PATCH v3 0/2] Fix regression in checkout -b Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190122184959.GF4399@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=asottile@umich.edu \
    --cc=benpeart@microsoft.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@gmail.com \
    --cc=peartben@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).