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

Re: [GSoC][RFC PATCH] clone: use dir-iterator to avoid explicit dir traversal

From
Christian Couder <christian.couder@gmail.com>
Date
Feb 14, 2019, 21:16 UTC
Message-ID
<CAP8UFD1aBn8=KOTp-D=CmO1iEnWUBS1-jR-aqfg3MZ7HZRU7Pg@mail.gmail.com>
In-Reply-To
<20190213205554.4086-1-matheus.bernardino@usp.br>

On Thu, Feb 14, 2019 at 1:16 PM Matheus Tavares <matheus.bernardino@usp.br> wrote:

Show 9 quoted lines
>
> Replace usage of opendir/readdir/closedir API to traverse directories
> recursively, at copy_or_link_directory function, by the dir-iterator
> API.
>
> Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
> ---
> This is my microproject for GSoC 2019. It's still a RFC because I have
> some questions. Any help will be much appreciated.
Thanks for working on a microproject!
> There're three places inside copy_or_link_directory's loop where
> die_errno() is called. Should I call dir_iterator_abort, at these
> places, before die_errno() is called (to free resources)?

I don't think it's necessary. We care about freeing resources when we report errors (for example by returning an error code from inside a function), but not when we are exiting.

> -static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest,
> -                                  const char *src_repo, int src_baselen)
> +static void mkdir_if_missing(const char *pathname, mode_t mode)

It looks like your patch is both splitting copy_or_link_directory() into 2 functions and converting it to use the dir-iterator API. Maybe it would be better to have 2 patches instead, one for splitting it and one for converting it.

Show 6 quoted lines
>  {
> -       struct dirent *de;
> +       /*
> +        * Tries to create a dir at pathname. If pathname already exists and
> +        * is a dir, do nothing.
> +        */

I think we usually put such comments just before the function. And maybe it could be shortened to "Create a dir at pathname unless there's already one"

Previous: Matheus TavaresNext: Matheus Tavares Bernardino
Message 2 of 4 in “clone: use dir-iterator to avoid explicit dir traversal”
  1. Matheus TavaresFeb 13, 2019
  2. Christian CouderFeb 14, 2019
  3. Matheus Tavares BernardinoFeb 14, 2019
  4. Christian CouderFeb 15, 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.