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

Re: [PATCH] [GSOC] prune_worktrees(): reimplement with dir_iterator

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 1, 2017, 18:33 UTC
Message-ID
<xmqq7f34ugf2.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CAJYcaSOMkoAnW82g=moQxz0H9t7C+F++V4Ob1-UiTLiw=gm_0g@mail.gmail.com>
Robert Stanca <robert.stanca7@gmail.com> writes:
Show 10 quoted lines
> On Sat, Apr 1, 2017 at 5:29 AM, Junio C Hamano <gitster@pobox.com> wrote:
>>
>> Using dir_iterator() to make it recursive is not just overkill but
>> is a positively wrong change, isn't it?
>
> Thanks for the review, and yes the commit message is misleading (my
> bad there). I understood that remove_temp_files has no recursion
> component to it and it removes all ".tmp-id-pack-" files from
> /objects/pack , but shouldn't dir-iterator work even if there's no
> recursion level?

The point is what should happen when somebody (perhaps a newer version of Git, or a third-party add-on that works with Git) adds a subdirectory in .git/objects/pack/ or .git/worktrees/. The answer is that files and directories in such a subdirectory must not be touched, because prune_worktrees() or remove_temporary_files() do not know what these files and directories are.

The dir-iterator API does not allow you to say "only scan the directory without recursing into the subdirectories" so your code ends up recursing into them, without knowing what the files and directories inside are (or are not). As Peff mentioned in his review on the other one, if we add a knob to dir-iterator API to allow you to tell it not to recurse, then it would make it possible to do a faithful conversion from the original, but without such a change, you are changing the behaviour.

Previous: Robert Stanca
Message 4 of 4 in “[GSOC] prune_worktrees(): reimplement with dir_iterator”
  1. [GSOC] prune_worktrees(): reimplement with dir_iteratorRobert Stanca, Apr 1, 2017
  2. Junio C HamanoApr 1, 2017
  3. Robert StancaApr 1, 2017
  4. Junio C HamanoApr 1, 2017

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.