Skip to content

Commit dfba880

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 0fea6fa commit dfba880

1 file changed

Lines changed: 31 additions & 3 deletions

File tree

src/shared/Core/GitConfiguration.cs

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,8 @@ public class GitProcessConfiguration : IGitConfiguration
344344
{
345345
private static readonly GitVersion TypeConfigMinVersion = new GitVersion(2, 18, 0);
346346
private static readonly GitVersion ConfigListTypeMinVersion = new GitVersion(2, 54, 0);
347+
private static readonly GitVersion ConfigListTypeMinVfsBase = new GitVersion(2, 53, 0);
348+
private static readonly GitVersion ConfigListTypeMinVfsSuffix = new GitVersion(0, 1);
347349

348350
private readonly ITrace _trace;
349351
private readonly GitProcess _git;
@@ -362,17 +364,43 @@ internal GitProcessConfiguration(ITrace trace, GitProcess git, bool useCache)
362364
_trace = trace;
363365
_git = git;
364366

365-
// 'git config list --type=<X>' requires Git 2.54.0+
366-
if (useCache && git.Version < ConfigListTypeMinVersion)
367+
// 'git config list --type=<X>' requires Git 2.54.0+,
368+
// or microsoft/git fork 2.53.0.vfs.0.1+
369+
if (useCache && !SupportsConfigListType(git))
367370
{
368-
trace.WriteLine($"Git version {git.Version} is below {ConfigListTypeMinVersion}; config cache disabled");
371+
trace.WriteLine($"Git version {git.Version.OriginalString} does not support 'git config list --type'; config cache disabled");
369372
useCache = false;
370373
}
371374

372375
_useCache = useCache;
373376
_cache = useCache ? new Dictionary<GitConfigurationType, ConfigCache>() : null;
374377
}
375378

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

0 commit comments

Comments
 (0)