Skip to content

iterate dirs before or after their contents

Plato Kiorpelidis git 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest15 patches 15 repliesIn review
  2. v1 RFC6 patches 15 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/15t0066: refactor dir-iterator testst/t0066-dir-iterator.sh+28 -270 replies
2/15t0066: remove dependency between unrelated testst/t0066-dir-iterator.sh+3 -10 replies
3/15t0066: shorter expected and actual output file namest/t0066-dir-iterator.sh+29 -300 replies
4/15test-dir-iterator: consistently return EXIT_FAILURE or EXIT_SUCCESSt/helper/test-dir-iterator.c+3 -33 replies
5/15test-dir-iterator: print EACCES and ELOOP errno set by dir_iteratort/helper/test-dir-iterator.c+2 -00 replies
6/15test-dir-iterator: print errno name set by dir_iterator_advancet/helper/test-dir-iterator.c t/t0066-dir-iterator.sh+2 -20 replies
7/15t0066: better test coverage for dir-iteratort/t0066-dir-iterator.sh+289 -10 replies
8/15t0066: reorder tests from simple to more complext/t0066-dir-iterator.sh+31 -310 replies
9/15t0066: rename test directoriest/t0066-dir-iterator.sh+99 -990 replies
10/15dir-iterator: refactor dir_iterator_advance()dir-iterator.c+146 -773 replies
11/15dir-iterator: open root dir in dir_iterator_begin()dir-iterator.c t/t0066-dir-iterator.sh+12 -50 replies
12/15t0066: rename subtest descriptionst/t0066-dir-iterator.sh+27 -220 replies
13/15dir-iterator: option to iterate dirs in pre-orderbuiltin/clone.c dir-iterator.c dir-iterator.h +3 more+361 -365 replies
14/15dir-iterator: option to iterate dirs in post-orderdir-iterator.c dir-iterator.h t/helper/test-dir-iterator.c +1 more+828 -340 replies
15/15entry.c: use dir-iterator to avoid explicit dir traversalentry.c+19 -191 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 00/15][GSoC] iterate dirs before or after their contents

This is the second version of a patch series which implements pre-order and post-order iteration over directories. In this version I use the new iteration scheme to convert entry.c remove_subtree() function from using opendir/readdir/ closedir API to dir-iterator API.

v1: https://lore.kernel.org/git/[email protected]/

Fork: https://github.com/kioplato/git/tree/dir-iterator-v2
CI: https://github.com/kioplato/git/actions/runs/2295239114
I've ran the full test suite for each commit.

In comparison to v1 I changed/fixed/improved:

* In this version I followed Phillip's suggestion[1] to explain why I'm making the changes in each commit's description and create smaller, targeted commits. In v1 I did a lot of renaming to directory paths, test descriptions and files. In this version these renames have their own commits.

* Explained why I converted dir_iterator_advance() from iterative implementation to recursive in the related commit. Ævar[2] and Phillip[3] asked about why I did this conversion, so I thought it was appropriate to include an explanation in the commit's description.

* I talked about a subtle unexpected behavior of dir_iterator_begin() [4]. I was wrong about the two new states for the deepest directory. I introduced those states in order to implement recursive dir_iterator_advance() and not to deal with the unexpected behavior of dir_iterator_begin(). Therefore I splitted the conversion of dir_iteartor_advance() and the changes to deal with the unexpected behavior of dir_iteartor_begin() into two different commits. They need their own commits since they are two unrelated changes.

* Split the commit that introduces pre-order and post-order iteration into two. Like Phillip suggested here[5] the first changes dir-iterator default behavior and the second implements post-order iterator over directories. This helps split the tests introduced, which helps generate smaller diffs.

* Like Phillip suggested [6], I'll work with the existing code and change one aspect at a time in stages. In this series I converted entry.c remove_subtree() to use dir-iterator API instead of opendir/readdir/closedir API.

* The redundant tests [7] in this version were not removed. Instead I kept them for more detailed testing which helps in case a test fails.

* Ævar's idea[8] to change the default swich case in test-dir-iterator made me realize that test-dir-iterator does not print errno codes set by failed calls to dir_iterator_advance(). Therefore I made test-dir-iterator print them which makes all tests test_cmp for the errno code set by either dir_iteartor_begin() or dir_iterator_advance(). This presumably has the same effect as changing the default switch case to use BUG() macro. This change also led to two others, one that makes test-dir-iterator explicitly print ELOOP errno and the second that improves readability by consistently returning, C standard constants, either EXIT_SUCCESS or EXIT_FAILURE, instead of mixed integers and exit() calls.

* fixed coding style and introduces an enum for returning constants instead of more integers which worsens readability, as suggested by Ævar [9].

I also didn't CC Michael and Matheus in this version, since they weren't interested in v1 where I did CC them.

[1]: https://lore.kernel.org/git/[email protected]/
[2]: https://lore.kernel.org/git/[email protected]/
[3]: https://lore.kernel.org/git/[email protected]/
[4]: https://lore.kernel.org/git/20220427154526.uuhpkoee322l7kmz@compass/
[5]: https://lore.kernel.org/git/[email protected]/
[6]: https://lore.kernel.org/git/[email protected]/
[7]: https://lore.kernel.org/git/[email protected]/
[8]: https://lore.kernel.org/git/[email protected]/
[9]: https://lore.kernel.org/git/[email protected]/

Plato Kiorpelidis (15):
t0066: refactor dir-iterator tests
t0066: remove dependency between unrelated tests
t0066: shorter expected and actual output file names
test-dir-iterator: consistently return EXIT_FAILURE or EXIT_SUCCESS
test-dir-iterator: print EACCES and ELOOP errno set by dir_iterator
test-dir-iterator: print errno name set by dir_iterator_advance
t0066: better test coverage for dir-iterator
t0066: reorder tests from simple to more complex
t0066: rename test directories
dir-iterator: refactor dir_iterator_advance()
dir-iterator: open root dir in dir_iterator_begin()
t0066: rename subtest descriptions
dir-iterator: option to iterate dirs in pre-order
dir-iterator: option to iterate dirs in post-order entry.c: use dir-iterator to avoid explicit dir traversal

 builtin/clone.c              |    4 +-
 dir-iterator.c               |  334 ++++++--
 dir-iterator.h               |   36 +-
 entry.c                      |   38 +-
 refs/files-backend.c         |    2 +-
 t/helper/test-dir-iterator.c |   24 +-
 t/t0066-dir-iterator.sh      | 1478 +++++++++++++++++++++++++++++++---
 7 files changed, 1704 insertions(+), 212 deletions(-)
Signature · 1 line
2.36.1