Re: [PATCH 1/5] t7300: add testcase showing unnecessary traversal into ignored directory
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- May 7, 2021, 23:15 UTC
- Message-ID
- <CAPig+cSP-5mvK0z=A21y4DQ_u07S+xHV3L+ADgaxzaK51yjX_w@mail.gmail.com>
- In-Reply-To
- <YJXHrXWVDSgg5TZw@coredump.intra.peff.net>
On Fri, May 7, 2021 at 7:05 PM Jeff King <peff@peff.net> wrote:
> I don't have a better way of checking the dir.c behavior. But I think > the other half of Eric's question was: why can't we do this setup way > more efficiently with "mkdir -p"?
I didn't really have that other half-question, as I understood the portability ramifications. Rather, I just wanted to make sure the reason I thought the code was doing the for-loop-plus-mv dance was indeed correct, and that I wasn't overlooking something non-obvious. I was also indirectly hinting that that bit of code might deserve an in-code comment explaining why the for-loop is there so that someone doesn't come along in the future and try replacing it with `mkdir -p`.
Show 10 quoted lines
> I'd be suspicious that it would work portably because of the long path.
> But I think the perl I showed earlier would create it in much less time:
>
> $ time perl -e '
> for (reverse 1..400) {
> my $d = "directory$_";
> mkdir($d) and chdir($d) or die "mkdir($d): $!";
> }
> open(my $fh, ">", "some-file");
> 'Yep, this and your other Perl code snippet for removing the directory seemed much nicer than the far more expensive shell for-loop-plus-mv (especially for Windows folk).