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

Re: [PATCH] dir-iterator: drop unused `DIR_ITERATOR_FOLLOW_SYMLINKS`

From
Jeff King <peff@peff.net>
Date
Feb 16, 2023, 18:49 UTC
Message-ID
<Y+560+/G4pelldXF@coredump.intra.peff.net>
In-Reply-To
<9bb10b607e46f867a3f8f5c71abf13c990d1ecfe.1676572031.git.me@ttaylorr.com>
On Thu, Feb 16, 2023 at 01:27:14PM -0500, Taylor Blau wrote:
Show 21 quoted lines
> The `FOLLOW_SYMLINKS` flag was added to the dir-iterator API in
> fa1da7d2ee (dir-iterator: add flags parameter to dir_iterator_begin,
> 2019-07-10) in order to follow symbolic links while traversing through a
> directory.
> 
> `FOLLOW_SYMLINKS` gained its first caller in ff7ccc8c9a (clone: use
> dir-iterator to avoid explicit dir traversal, 2019-07-10), but it was
> subsequently removed in 6f054f9fb3 (builtin/clone.c: disallow `--local`
> clones with symlinks, 2022-07-28).
> 
> Since then, we've held on to the code for `DIR_ITERATOR_FOLLOW_SYMLINKS`
> in the name of making minimally invasive changes during a security
> embargo.
> 
> In fact, we even changed the dir-iterator API in bffc762f87
> (dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS,
> 2023-01-24) without having any non-test callers of that flag.
> 
> Now that we're past those security embargo(s), let's finalize our
> cleanup of the `DIR_ITERATOR_FOLLOW_SYMLINKS` code and remove its
> implementation since there are no remaining callers.

Thanks for following up on this. I think it's an obviously good direction, and the patch looks sensible. It's hard to grep for --follow-symlinks or FOLLOW_SYMLINKS to make sure you got everything, just because there are other unrelated features that use that name. ;)

But I think you got all the relevant spots. The only thing I wondered is whether we could clean up any of the test setup. Specifically, "dir5" does not seem to be used in the tests, and everything passes with:

diff --git a/t/t0066-dir-iterator.sh b/t/t0066-dir-iterator.sh
index 4ed3136b00..1f3e070ec2 100755
--- a/t/t0066-dir-iterator.sh
+++ b/t/t0066-dir-iterator.sh
@@ -106,12 +106,6 @@ test_expect_success SYMLINKS 'setup dirs with symlinks' '
 	ln -s d dir4/a/e &&
 	ln -s ../b dir4/a/f &&
 
-	mkdir -p dir5/a/b &&
-	mkdir -p dir5/a/c &&
-	ln -s ../c dir5/a/b/d &&
-	ln -s ../ dir5/a/b/e &&
-	ln -s ../../ dir5/a/b/f &&
-
 	ln -s dir4 dir6
 '
 

But...that is true even before your patch. dir5 is not mentioned in any
of the expected output, even in fa1da7d2ee (dir-iterator: add flags
parameter to dir_iterator_begin, 2019-07-10) where it was added. Was it
just vestigial? Or is it somehow important that it is _not_ in the
output?

I didn't dig, and even if it can be removed, it would probably make
sense to do it separately from your patch anyway.

-Peff
Previous: Taylor BlauNext: Taylor Blau
Message 2 of 6 in “dir-iterator: drop unused `DIR_ITERATOR_FOLLOW_SYMLINKS`”
  1. dir-iterator: drop unused `DIR_ITERATOR_FOLLOW_SYMLINKS`Taylor Blau, Feb 16, 2023
  2. Jeff KingFeb 16, 2023
  3. Taylor BlauFeb 16, 2023
  4. Taylor BlauFeb 16, 2023
  5. Matheus Tavares BernardinoFeb 17, 2023
  6. 2/1 t0066: drop setup of "dir5"Jeff King, Feb 17, 2023

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.