Re: [WIP RFC PATCH 2/7] dir-iterator: use stat() instead of lstat()
- From
Matheus Tavares Bernardino <matheus.bernardino@usp.br>
- Date
- Feb 26, 2019, 01:53 UTC
- Message-ID
- <CAHd-oW5=BoP6=Ti7y=_rugrRnQJ2yBrFqwq_-fjP7UfcNDoxzw@mail.gmail.com>
- In-Reply-To
- <20190226002625.13022-3-avarab@gmail.com>
On Mon, Feb 25, 2019 at 9:26 PM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
Show 19 quoted lines
>
> This is surely a horrible idea, but all tests pass with this (not that
> I trust them much). Doing this for later WIP use in clone.c.
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
> dir-iterator.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/dir-iterator.c b/dir-iterator.c
> index 070a656555..6a9c0c4d08 100644
> --- a/dir-iterator.c
> +++ b/dir-iterator.c
> @@ -149,7 +149,7 @@ int dir_iterator_advance(struct dir_iterator *dir_iterator)
> continue;
>
> strbuf_addstr(&iter->base.path, de->d_name);
> - if (lstat(iter->base.path.buf, &iter->base.st) < 0) {
> + if (stat(iter->base.path.buf, &iter->base.st) < 0) {I think this may have side-effects on other sections that uses the dir-iterator API, because now it would follow symlinks, right?
Show 6 quoted lines
> if (errno != ENOENT) {
> if (iter->pedantic)
> goto error_out;
> --
> 2.21.0.rc2.1.g2d5e20a900.dirty
>