From a34a5ce2e3db7a309a346091bb964e93beb64f60 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Sun, 1 Mar 2026 13:13:48 -0500 Subject: [PATCH] feat: Allow config cache for microsoft/git 2.53.0.vfs.0.1+ Context: The config cache version gate requires Git 2.54.0+ because that is when upstream Git will include the fix for 'git config list --type='. However, the microsoft/git fork may fast-track this fix into a 2.53.0.vfs.0.1 release, allowing users of Git for Windows (VFS-enabled builds) to benefit from the cache sooner. Justification: The microsoft/git fork uses version strings like '2.53.0.vfs.0.1' where the '.vfs.' marker distinguishes it from upstream Git. GitVersion parsing stops at the non-integer 'vfs' component, so a simple numeric comparison would treat this as 2.53.0 and disable caching. We need an additional check that recognizes VFS builds and compares their suffix version. The base version (2.53.0) and VFS suffix (0.1) are checked separately, allowing any future 2.53+ VFS build with the fix to also benefit. Upstream 2.54.0+ continues to pass the existing numeric check without hitting the VFS path. Implementation: Added SupportsConfigListType() helper that first checks the upstream minimum (2.54.0), then looks for '.vfs.' in the original version string. For VFS builds, it parses the base version and VFS suffix independently and checks both against their respective minimums (2.53.0 and 0.1). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/shared/Core/GitConfiguration.cs | 34 ++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/shared/Core/GitConfiguration.cs b/src/shared/Core/GitConfiguration.cs index e5eb08d6d..83a10d591 100644 --- a/src/shared/Core/GitConfiguration.cs +++ b/src/shared/Core/GitConfiguration.cs @@ -324,6 +324,8 @@ public class GitProcessConfiguration : IGitConfiguration { private static readonly GitVersion TypeConfigMinVersion = new GitVersion(2, 18, 0); private static readonly GitVersion ConfigListTypeMinVersion = new GitVersion(2, 54, 0); + private static readonly GitVersion ConfigListTypeMinVfsBase = new GitVersion(2, 53, 0); + private static readonly GitVersion ConfigListTypeMinVfsSuffix = new GitVersion(0, 1); private readonly ITrace _trace; private readonly GitProcess _git; @@ -342,10 +344,11 @@ internal GitProcessConfiguration(ITrace trace, GitProcess git, bool useCache) _trace = trace; _git = git; - // 'git config list --type=' requires Git 2.54.0+ - if (useCache && git.Version < ConfigListTypeMinVersion) + // 'git config list --type=' requires Git 2.54.0+, + // or microsoft/git fork 2.53.0.vfs.0.1+ + if (useCache && !SupportsConfigListType(git)) { - trace.WriteLine($"Git version {git.Version} is below {ConfigListTypeMinVersion}; config cache disabled"); + trace.WriteLine($"Git version {git.Version.OriginalString} does not support 'git config list --type'; config cache disabled"); useCache = false; } @@ -353,6 +356,31 @@ internal GitProcessConfiguration(ITrace trace, GitProcess git, bool useCache) _cache = useCache ? new Dictionary() : null; } + private static bool SupportsConfigListType(GitProcess git) + { + if (git.Version >= ConfigListTypeMinVersion) + return true; + + // The microsoft/git fork fast-tracked the fix into 2.53.0.vfs.0.1. + // Version strings like "2.53.0.vfs.0.1" parse as [2,53,0] because + // GitVersion stops at the non-integer "vfs" component, so we check + // the original string for the ".vfs." marker and parse the suffix. + string versionStr = git.Version.OriginalString; + if (versionStr != null) + { + int vfsIdx = versionStr.IndexOf(".vfs."); + if (vfsIdx >= 0) + { + var baseVersion = new GitVersion(versionStr.Substring(0, vfsIdx)); + var vfsSuffix = new GitVersion(versionStr.Substring(vfsIdx + 5)); + return baseVersion >= ConfigListTypeMinVfsBase + && vfsSuffix >= ConfigListTypeMinVfsSuffix; + } + } + + return false; + } + private void EnsureCacheLoaded(GitConfigurationType type) { ConfigCache cache;