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: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id F2EC71F59D for ; Fri, 15 Jul 2022 08:31:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232515AbiGOI31 (ORCPT ); Fri, 15 Jul 2022 04:29:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232409AbiGOI3Z (ORCPT ); Fri, 15 Jul 2022 04:29:25 -0400 Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com [209.85.219.177]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78E284E60E for ; Fri, 15 Jul 2022 01:29:23 -0700 (PDT) Received: by mail-yb1-f177.google.com with SMTP id e69so7364032ybh.2 for ; Fri, 15 Jul 2022 01:29:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=emOIv8uasUIi53sADKzTaHY+WdQ++xE9/egOMc2WdhA=; b=sCFDFA64LgOGFyanGbJ3g2wj8HKnUCTrZLPuR7X/2HDaZop2kpcBIro6UHXvS1tZ4J mXCCbXc8yQkPz6/cGfD7dNhgq0qOJiQ7EKp5law8dbKfLqoVPpmiGw08Den07oy1FGel pkKK06wrb98SagxSDQht87Wx8OHok+Q4BUkf3Inp8QWmoG5sJrrSyyvsbJrLNwZR+AJt W9Wd0m/zBMnyP16DwXW10+1uyh9qgMii+thksfPwut0RmG3TnMtpzj8ICXwrHogXPCam 9uw9BTJd3p4x38j+mnXBFEHFfN+toP9yewP1Iqoskz1vvTsQSUkoVFwO/iARGUzi/xxl y/CA== X-Gm-Message-State: AJIora+vGylz3JL+oBH2QnbBUvpYneH4mCAsrWYNplC4uXftIj3dAlMV 0VMlCbAYb1MPUbEvWeBDzieoxP4Pj2hQDCXwFJs= X-Google-Smtp-Source: AGRyM1vHD5IL0CMoCV6cskmi14P3CIzvuv3CtrSTBD8O2TrUEfkeLW3l64GqX3KqEt+7TzcWtB5qDigm8LYxZiwp6zo= X-Received: by 2002:a25:2b03:0:b0:664:271f:924 with SMTP id r3-20020a252b03000000b00664271f0924mr13174477ybr.211.1657873762486; Fri, 15 Jul 2022 01:29:22 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Eric Sunshine Date: Fri, 15 Jul 2022 04:29:11 -0400 Message-ID: Subject: Re: [PATCH] refs: work around network caching on Windows To: Johannes Schindelin via GitGitGadget Cc: Git List , Johannes Schindelin , Pierre Garnier Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Fri, Jul 15, 2022 at 4:18 AM Johannes Schindelin via GitGitGadget wrote: > Network shares sometimes use aggressive caching, in which case a > just-created directory might not be immediately visible to Git. > > One symptom of this scenario is the following error: > > $ git tag -a -m "automatic tag creation" test_dir/test_tag > fatal: cannot lock ref 'refs/tags/test_dir/test_tag': unable to resolve reference 'refs/tags/test_dir/test_tag': Not a directory > > Note: This does not necessarily happen in all Windows setups. One setup > where it _did_ happen is a Windows Server 2019 VM, and as hinted in > > http://woshub.com/slow-network-shared-folder-refresh-windows-server/ > > the following commands worked around it: > > Set-SmbClientConfiguration -DirectoryCacheLifetime 0 > Set-SmbClientConfiguration -FileInfoCacheLifetime 0 > Set-SmbClientConfiguration -FileNotFoundCacheLifetime 0 > > This would impact performance negatively, though, as it essentially > turns off all caching, therefore we do not want to require users to do > that just to be able to use Git on Windows. > > The underlying culprit is that `GetFileAttributesExW()` that is called from > `mingw_lstat()` can raise an error `ERROR_PATH_NOT_FOUND`, which is > translated to `ENOTDIR`, as opposed to `ENOENT` as expected on Linux. > > Therefore, when trying to read a ref, let's allow `ENOTDIR` in addition > to `ENOENT` to indicate that said ref is missing. > > This fixes https://github.com/git-for-windows/git/issues/3727 > > Signed-off-by: Pierre Garnier > Signed-off-by: Johannes Schindelin > --- > diff --git a/refs/files-backend.c b/refs/files-backend.c > @@ -381,7 +381,7 @@ stat_ref: > - if (myerr != ENOENT || skip_packed_refs) > + if ((myerr != ENOENT && myerr != ENOTDIR) || skip_packed_refs) > diff --git a/refs/packed-backend.c b/refs/packed-backend.c > @@ -480,7 +480,7 @@ static int load_contents(struct snapshot *snapshot) > - if (errno == ENOENT) { > + if (errno == ENOENT || errno == ENOTDIR) { The first question which popped into my mind upon reading the patch was why these changes need to be made to files-backend.c and packed-backend.c rather than "fixing" mingw_lstat() to return ENOENT instead of ENOTDIR. Patching mingw_lstat() seems more tractable and less likely to lead to discovery of other code in the future which needs to be patched in a similar way to how files-backend.c and packed-backend.c are being patched here. Perhaps it's a silly question and the answer is perfectly obvious to folks directly involved in Git development on Windows, but the commit message doesn't seem to answer it for people who don't have such inside knowledge.