Re: [WIP RFC PATCH v2 5/5] clone: use dir-iterator to avoid explicit dir traversal
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Feb 28, 2019, 07:13 UTC
- Message-ID
- <CACsJy8BV8CHOnbfDysgdo-md0pXLg05rKpMP5a8TUkUcWw0G8g@mail.gmail.com>
- In-Reply-To
- <CAHd-oW6WJ5JSRAbcy+5kcEA4V8qKEUc9B=6WQZvdqaHz4XHBTA@mail.gmail.com>
On Thu, Feb 28, 2019 at 12:40 AM Matheus Tavares Bernardino <matheus.bernardino@usp.br> wrote:
Show 21 quoted lines
> > > @@ -463,7 +460,11 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest,
> > > if (copy_file_with_time(dest->buf, src->buf, 0666))
> > > die_errno(_("failed to copy file to '%s'"), dest->buf);
> > > }
> > > - closedir(dir);
> > > +
> > > + if (iter_status != ITER_DONE) {
> > > + strbuf_setlen(src, src_len);
> > > + die(_("failed to iterate over '%s'"), src->buf);
> > > + }
> >
> > I think you need to abort the iterator even when it returns ITER_DONE.
> > At least that's how the first caller in files-backend.c does it.
> >
>
> Hm, I don't think so, since dir_iterator_advance() already frees the
> resources before returning ITER_DONE. Also, I may be wrong, but it
> doesn't seem to me, that files-backend.c does it. The function
> files_reflog_iterator_advance() that calls dir_iterator_advance() even
> sets the dir-iterator pointer to NULL as soon as ITER_DONE is
> returned.Arghhh.. I read the ref_iterator_abort and thought it was dir_iterator_abort! Sorry for the noise, too many iterators.
-- Duy