Skip to content

Commit a34a5ce

Browse files
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=<X>'. 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>
1 parent 2d2658e commit a34a5ce

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

src/shared/Core/GitConfiguration.cs

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,8 @@ public class GitProcessConfiguration : IGitConfiguration
324324
{
325325
private static readonly GitVersion TypeConfigMinVersion = new GitVersion(2, 18, 0);
326326
private static readonly GitVersion ConfigListTypeMinVersion = new GitVersion(2, 54, 0);
327+
private static readonly GitVersion ConfigListTypeMinVfsBase = new GitVersion(2, 53, 0);
328+
private static readonly GitVersion ConfigListTypeMinVfsSuffix = new GitVersion(0, 1);
327329

328330
private readonly ITrace _trace;
329331
private readonly GitProcess _git;
@@ -342,17 +344,43 @@ internal GitProcessConfiguration(ITrace trace, GitProcess git, bool useCache)
342344
_trace = trace;
343345
_git = git;
344346

345-
// 'git config list --type=<X>' requires Git 2.54.0+
346-
if (useCache && git.Version < ConfigListTypeMinVersion)
347+
// 'git config list --type=<X>' requires Git 2.54.0+,
348+
// or microsoft/git fork 2.53.0.vfs.0.1+
349+
if (useCache && !SupportsConfigListType(git))
347350
{
348-
trace.WriteLine($"Git version {git.Version} is below {ConfigListTypeMinVersion}; config cache disabled");
351+
trace.WriteLine($"Git version {git.Version.OriginalString} does not support 'git config list --type'; config cache disabled");
349352
useCache = false;
350353
}
351354

352355
_useCache = useCache;
353356
_cache = useCache ? new Dictionary<GitConfigurationType, ConfigCache>() : null;
354357
}
355358

359+
private static bool SupportsConfigListType(GitProcess git)
360+
{
361+
if (git.Version >= ConfigListTypeMinVersion)
362+
return true;
363+
364+
// The microsoft/git fork fast-tracked the fix into 2.53.0.vfs.0.1.
365+
// Version strings like "2.53.0.vfs.0.1" parse as [2,53,0] because
366+
// GitVersion stops at the non-integer "vfs" component, so we check
367+
// the original string for the ".vfs." marker and parse the suffix.
368+
string versionStr = git.Version.OriginalString;
369+
if (versionStr != null)
370+
{
371+
int vfsIdx = versionStr.IndexOf(".vfs.");
372+
if (vfsIdx >= 0)
373+
{
374+
var baseVersion = new GitVersion(versionStr.Substring(0, vfsIdx));
375+
var vfsSuffix = new GitVersion(versionStr.Substring(vfsIdx + 5));
376+
return baseVersion >= ConfigListTypeMinVfsBase
377+
&& vfsSuffix >= ConfigListTypeMinVfsSuffix;
378+
}
379+
}
380+
381+
return false;
382+
}
383+
356384
private void EnsureCacheLoaded(GitConfigurationType type)
357385
{
358386
ConfigCache cache;

0 commit comments

Comments
 (0)