Skip to content

Commit 9790dd6

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 3125246 commit 9790dd6

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
@@ -335,6 +335,8 @@ public class GitProcessConfiguration : IGitConfiguration
335335
{
336336
private static readonly GitVersion TypeConfigMinVersion = new GitVersion(2, 18, 0);
337337
private static readonly GitVersion ConfigListTypeMinVersion = new GitVersion(2, 54, 0);
338+
private static readonly GitVersion ConfigListTypeMinVfsBase = new GitVersion(2, 53, 0);
339+
private static readonly GitVersion ConfigListTypeMinVfsSuffix = new GitVersion(0, 1);
338340

339341
private readonly ITrace _trace;
340342
private readonly GitProcess _git;
@@ -353,17 +355,43 @@ internal GitProcessConfiguration(ITrace trace, GitProcess git, bool useCache)
353355
_trace = trace;
354356
_git = git;
355357

356-
// 'git config list --type=<X>' requires Git 2.54.0+
357-
if (useCache && git.Version < ConfigListTypeMinVersion)
358+
// 'git config list --type=<X>' requires Git 2.54.0+,
359+
// or microsoft/git fork 2.53.0.vfs.0.1+
360+
if (useCache && !SupportsConfigListType(git))
358361
{
359-
trace.WriteLine($"Git version {git.Version} is below {ConfigListTypeMinVersion}; config cache disabled");
362+
trace.WriteLine($"Git version {git.Version.OriginalString} does not support 'git config list --type'; config cache disabled");
360363
useCache = false;
361364
}
362365

363366
_useCache = useCache;
364367
_cache = useCache ? new Dictionary<GitConfigurationType, ConfigCache>() : null;
365368
}
366369

370+
private static bool SupportsConfigListType(GitProcess git)
371+
{
372+
if (git.Version >= ConfigListTypeMinVersion)
373+
return true;
374+
375+
// The microsoft/git fork fast-tracked the fix into 2.53.0.vfs.0.1.
376+
// Version strings like "2.53.0.vfs.0.1" parse as [2,53,0] because
377+
// GitVersion stops at the non-integer "vfs" component, so we check
378+
// the original string for the ".vfs." marker and parse the suffix.
379+
string versionStr = git.Version.OriginalString;
380+
if (versionStr != null)
381+
{
382+
int vfsIdx = versionStr.IndexOf(".vfs.");
383+
if (vfsIdx >= 0)
384+
{
385+
var baseVersion = new GitVersion(versionStr.Substring(0, vfsIdx));
386+
var vfsSuffix = new GitVersion(versionStr.Substring(vfsIdx + 5));
387+
return baseVersion >= ConfigListTypeMinVfsBase
388+
&& vfsSuffix >= ConfigListTypeMinVfsSuffix;
389+
}
390+
}
391+
392+
return false;
393+
}
394+
367395
private void EnsureCacheLoaded(GitConfigurationType type)
368396
{
369397
ConfigCache cache;

0 commit comments

Comments
 (0)