Re: [GSoC][PATCH v7 06/10] dir-iterator: add flags parameter to dir_iterator_begin
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jun 27, 2019, 18:48 UTC
- Message-ID
- <nycvar.QRO.7.76.6.1906272046180.44@tvgsbejvaqbjf.bet>
- In-Reply-To
- <CAHd-oW5zea9wzobAQG4FzN-KSS5BsRoM5vf_x_F83=yqGRfUQw@mail.gmail.com>
Hi Matheus,
On Thu, 27 Jun 2019, Matheus Tavares Bernardino wrote:
Show 38 quoted lines
> On Wed, Jun 26, 2019 at 3:04 PM Junio C Hamano <gitster@pobox.com> wrote:
> >
> > Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> >
> > > Hi Matheus,
> > >
> > > On Tue, 18 Jun 2019, Matheus Tavares wrote:
> > >
> > >>[...]
> > >> +/*
> > >> + * Look for a recursive symlink at iter->base.path pointing to any directory on
> > >> + * the previous stack levels. If it is found, return 1. If not, return 0.
> > >> + */
> > >> +static int find_recursive_symlinks(struct dir_iterator_int *iter)
> > >> +{
> > >> + int i;
> > >> +
> > >> + if (!(iter->flags & DIR_ITERATOR_FOLLOW_SYMLINKS) ||
> > >> + !S_ISDIR(iter->base.st.st_mode))
> > >> + return 0;
> > >>
> > >> + for (i = 0; i < iter->levels_nr; ++i)
> > >> + if (iter->base.st.st_ino == iter->levels[i].ino)
> > >
> > > This does not work on Windows. [[ Windows port does not have
> > > usable st_ino field ]]]
> >
> > And if you cross mountpoint, st_ino alone does not guarantee
> > uniqueness; you'd need to combine it with st_dev, I would think,
> > even on POSIX systems.
>
> Ok, thanks for letting me know. I'm trying to think of another
> approach to test for recursive symlinks that does not rely on inode:
> Given any symlink, we could get its real_path() and compare it with
> the path of the directory current being iterated. If the first is a
> prefix of the second, than we mark it as a recursive symlink.
>
> What do you think of this idea?I think this would be pretty expensive. Too expensive.
A better method might be to rely on st_ino/st_dev when we can, and just not bother looking for recursive symlinks when we cannot, like I did in https://github.com/git-for-windows/git/commit/979b00ccf44ec31cff4686e24adf27474923c33a
Ciao, Johannes