From f2e2236b4fb406b77a5282e6424a088da546a6ea Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Tue, 27 Aug 2019 15:04:49 -0400 Subject: [PATCH] UntrackedCache: enable based on platform Signed-off-by: Derrick Stolee --- Scalar.Common/FileSystem/IPlatformFileSystem.cs | 1 + Scalar.Platform.POSIX/POSIXFileSystem.cs | 2 ++ Scalar.Platform.Windows/WindowsFileSystem.cs | 2 ++ Scalar.UnitTests/Mock/FileSystem/MockPlatformFileSystem.cs | 2 ++ Scalar/CommandLine/ScalarVerb.cs | 2 +- 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Scalar.Common/FileSystem/IPlatformFileSystem.cs b/Scalar.Common/FileSystem/IPlatformFileSystem.cs index fc9823bbe6..fa5e46f3e4 100644 --- a/Scalar.Common/FileSystem/IPlatformFileSystem.cs +++ b/Scalar.Common/FileSystem/IPlatformFileSystem.cs @@ -5,6 +5,7 @@ namespace Scalar.Common.FileSystem public interface IPlatformFileSystem { bool SupportsFileMode { get; } + bool SupportsUntrackedCache { get; } void FlushFileBuffers(string path); void MoveAndOverwriteFile(string sourceFileName, string destinationFilename); bool TryGetNormalizedPath(string path, out string normalizedPath, out string errorMessage); diff --git a/Scalar.Platform.POSIX/POSIXFileSystem.cs b/Scalar.Platform.POSIX/POSIXFileSystem.cs index 6b24148d09..ff11867bad 100644 --- a/Scalar.Platform.POSIX/POSIXFileSystem.cs +++ b/Scalar.Platform.POSIX/POSIXFileSystem.cs @@ -28,6 +28,8 @@ public enum OpenFlags public bool SupportsFileMode { get; } = true; + public bool SupportsUntrackedCache { get; } = true; + public void FlushFileBuffers(string path) { // TODO(#1057): Use native API to flush file diff --git a/Scalar.Platform.Windows/WindowsFileSystem.cs b/Scalar.Platform.Windows/WindowsFileSystem.cs index 23253059d5..3f594411d7 100644 --- a/Scalar.Platform.Windows/WindowsFileSystem.cs +++ b/Scalar.Platform.Windows/WindowsFileSystem.cs @@ -14,6 +14,8 @@ public partial class WindowsFileSystem : IPlatformFileSystem { public bool SupportsFileMode { get; } = false; + public bool SupportsUntrackedCache { get; } = false; + /// /// Adds a new FileSystemAccessRule granting read (and optionally modify) access for all users. /// diff --git a/Scalar.UnitTests/Mock/FileSystem/MockPlatformFileSystem.cs b/Scalar.UnitTests/Mock/FileSystem/MockPlatformFileSystem.cs index dfb920839f..3aa111c173 100644 --- a/Scalar.UnitTests/Mock/FileSystem/MockPlatformFileSystem.cs +++ b/Scalar.UnitTests/Mock/FileSystem/MockPlatformFileSystem.cs @@ -8,6 +8,8 @@ public class MockPlatformFileSystem : IPlatformFileSystem { public bool SupportsFileMode { get; } = true; + public bool SupportsUntrackedCache { get; } = true; + public void FlushFileBuffers(string path) { throw new NotSupportedException(); diff --git a/Scalar/CommandLine/ScalarVerb.cs b/Scalar/CommandLine/ScalarVerb.cs index f5c2c08516..cdab8f94a3 100644 --- a/Scalar/CommandLine/ScalarVerb.cs +++ b/Scalar/CommandLine/ScalarVerb.cs @@ -117,7 +117,7 @@ public static bool TrySetRequiredGitConfigSettings(Enlistment enlistment) { "core.multiPackIndex", "true" }, { "core.preloadIndex", "true" }, { "core.safecrlf", "false" }, - { "core.untrackedCache", "false" }, + { "core.untrackedCache", ScalarPlatform.Instance.FileSystem.SupportsUntrackedCache ? "true" : "false" }, { "core.repositoryformatversion", "0" }, { "core.filemode", ScalarPlatform.Instance.FileSystem.SupportsFileMode ? "true" : "false" }, { GitConfigSetting.CoreVirtualizeObjectsName, "true" },