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

Re: [PATCH v4 2/5] dir_iterator: iterate over dir after its contents

From
Duy Nguyen <pclouds@gmail.com>
Date
Apr 5, 2017, 09:21 UTC
Message-ID
<CACsJy8BTKHZqsJfbvmi9YgeaDyHK6wjBLf9dkBXfbZ=BRMa=pA@mail.gmail.com>
In-Reply-To
<CAEA2_RKFwL8K=-QBYbmfbjJ44obB+PJit0pd5im0Jy_=E_-+MA@mail.gmail.com>

On Sun, Apr 2, 2017 at 11:25 AM, Daniel Ferreira (theiostream) <bnmvco@gmail.com> wrote:

> Why exactly would it not be applicable to read_directory_recursively()?

Because that function is a beast (and probably should have "beast" in the function name).

The function is supposed to read .gitignore, index file and whatever else needed, traverse the directory and return the list of untracked files, or ignored files. It even has options to return a directory path, if all entries inside is ignored/untracked, instead of the list of files inside. On top of that, it has "untracked cache" to skip traversing directories to speed up.

Using dir_iterator might be possible but we'll need to improve it a lot. read_directory_recursively() needs really fine control over traversing: it can decide to not recurse in a subdirectory, it can decide to ignore the rest of the entries in a directory and go back to its parent, and in the case of untracked cache, it can switch to traversing the cache instead of on-disk directories.

It's possible, probably, but it's going to need quite a lot of work (and care, since I think there are corner cases that have been abused in real world and we just cannot change those behaviors). Using iterator interface would be a good improvement to clean up the "on disk or on cache" directory traversal there though.

Show 13 quoted lines
>
> On Thu, Mar 30, 2017 at 8:08 AM, Duy Nguyen <pclouds@gmail.com> wrote:
>> On Thu, Mar 30, 2017 at 1:39 PM, Michael Haggerty <mhagger@alum.mit.edu> wrote:
>>> * DIR_ITERATOR_RECURSE -- recurse into subdirectories
>>>
>>> would make the set of possible options complete. If this option is not
>>> set, then the iteration would be over the entries in a single directory
>>> without traversing its subdirectories.
>>
>> And would make it possible to use dir-iterator everywhere (except
>> read_directory_recursiveky). That would be really nice :)
>> --
>> Duy
-- 
Duy
Previous: Daniel Ferreira (theiostream)Next: Junio C Hamano
Message 18 of 19 in “[GSoC] remove_subtree(): reimplement using iterators”
  1. 0/5 [GSoC] remove_subtree(): reimplement using iteratorsDaniel Ferreira, Mar 29, 2017
  2. 4/5 remove_subtree(): test removing nested directoriesDaniel Ferreira, Mar 29, 2017
  3. 5/5 files_reflog_iterator: amend use of dir_iteratorDaniel Ferreira, Mar 29, 2017
  4. Michael HaggertyMar 29, 2017
  5. 1/5 dir_iterator: add helpers to dir_iterator_advanceDaniel Ferreira, Mar 29, 2017
  6. Michael HaggertyMar 29, 2017
  7. 3/5 remove_subtree(): reimplement using iteratorsDaniel Ferreira, Mar 29, 2017
  8. Michael HaggertyMar 29, 2017
  9. 2/5 dir_iterator: iterate over dir after its contentsDaniel Ferreira, Mar 29, 2017
  10. Michael HaggertyMar 29, 2017
  11. Michael HaggertyMar 29, 2017
  12. Junio C HamanoMar 29, 2017
  13. Michael HaggertyMar 30, 2017
  14. Junio C HamanoMar 30, 2017
  15. Michael HaggertyMar 30, 2017
  16. Duy NguyenMar 30, 2017
  17. Daniel Ferreira (theiostream)Apr 2, 2017
  18. Duy NguyenApr 5, 2017
  19. Junio C HamanoMar 30, 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.