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.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, 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 835101F5AE for ; Fri, 7 May 2021 03:25:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230376AbhEGD0y (ORCPT ); Thu, 6 May 2021 23:26:54 -0400 Received: from cloud.peff.net ([104.130.231.41]:47058 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230366AbhEGD0y (ORCPT ); Thu, 6 May 2021 23:26:54 -0400 Received: (qmail 31940 invoked by uid 109); 7 May 2021 03:25:55 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 07 May 2021 03:25:55 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 29207 invoked by uid 111); 7 May 2021 03:25:56 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Thu, 06 May 2021 23:25:56 -0400 Authentication-Results: peff.net; auth=none Date: Thu, 6 May 2021 23:25:54 -0400 From: Jeff King To: Elijah Newren Cc: "brian m. carlson" , Jason Gore , "git@vger.kernel.org" Subject: Re: Git clean enumerates ignored directories (since 2.27) Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Thu, May 06, 2021 at 07:31:40PM -0700, Elijah Newren wrote: > On alpine linux-musl, I get an "error: Tests passed but test cleanup > failed; aborting", which makes it report as a failed build. I'm not > sure how to fix it and am asking for ideas. > > Apparently the deeply nested directory hierarchy cannot be removed on > that platform with a simple "rm -rf $dirname". It throws a "rm: can't > stat '/__w/git/git/t/trash > directory.t7300-clean/avoid-traversing-deep-hierarchy/directory400/directory399/directory398/.....(you > get the idea)....': Filename too long" error message.[1] > > Adding a "test_when_finished find directory400 -delete" also gives a > "Filename too long" message followed by a lot of "Directory not empty" > messages.[2] > > Anyone have any bright ideas about how to tweak this test? See [3] > for the current incarnation of the code, which was basically taken > from Brian's sample testcase. My guess is that that version of "rm" is trying to feed the entire pathname directly to unlink() and rmdir(), and it exceeds PATH_MAX. Even with GNU tools, for instance, I get: $ rmdir $(find avoid-traversing-deep-hierarchy -type d | tail -1) rmdir: failed to remove 'avoid-traversing-deep-hierarchy/directory400/ [...and so on...]/directory1': File name too long because it feeds the whole to a single rmdir() call. Whereas stracing GNU "rm -rf", it uses unlinkat() and openat() to delete each level individually (probably to avoid this exact problem). Is the actual path length important, or just the depth? If the latter, then calling it "d400/d399/.../d2/d1" would likely help, as that's less than 2000 bytes. -Peff