From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 33E1C1F5AE for ; Fri, 7 May 2021 23:16:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229946AbhEGXQ5 (ORCPT ); Fri, 7 May 2021 19:16:57 -0400 Received: from mail-ej1-f45.google.com ([209.85.218.45]:45752 "EHLO mail-ej1-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229812AbhEGXQ5 (ORCPT ); Fri, 7 May 2021 19:16:57 -0400 Received: by mail-ej1-f45.google.com with SMTP id u3so15856805eja.12 for ; Fri, 07 May 2021 16:15:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yqPy9sMo+bwtrgwNZpDtCC+RFWo3jWrexTeiYX1lG8o=; b=RtPoUdlD/2JDmPpBpDVa9cJjx3v9HVP2XLPy1UirFFFkzIOI0x9PORQe+u/IcN7Pg7 r7rUbopaNbj1nEnF7VfKJ8m4tzOuejXyFs1Z0gQV9Y1FtrxSvFpOY1BKxHoUWs6GuHeL e9Cmu6G6NTMzkRTtXm/lJOpji9wo6QChs2RZaxkb1EFpkP6d4kxRpcaZPXLBymWibaUT bJv87uuA37PpeMjlurGlrGROiqOY0dsBEn6/DNViiAJSrwmv/hI/99jLqd7vWUXvjXK+ AXkwMLyUXQefkX2ZTluT9NmUprXlzFYQID47xfOIdTe331YFu9fNqB9E9Apgj3MbWe6w 5dHg== X-Gm-Message-State: AOAM531HVnRTWDbzAI8IdLL4KpG/dvt0k7vbMX6Uj9f0HE+cIKGKFv1N TaZu/UWAjpo6msoZ7b4yBIumeNkAbK+KofIvuk4= X-Google-Smtp-Source: ABdhPJytieJNI0SebK1ypbMEVQZuULz5splIQ77kRdoS9Q28uES4+ZSebkL8ec23Kj2UnmVWsYaRJDQqxI1FAV2J2fo= X-Received: by 2002:a17:906:3115:: with SMTP id 21mr12842165ejx.482.1620429349861; Fri, 07 May 2021 16:15:49 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Eric Sunshine Date: Fri, 7 May 2021 19:15:38 -0400 Message-ID: Subject: Re: [PATCH 1/5] t7300: add testcase showing unnecessary traversal into ignored directory To: Jeff King Cc: Elijah Newren , Elijah Newren via GitGitGadget , Git List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Fri, May 7, 2021 at 7:05 PM Jeff King 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`. > 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).