Skip to content

Commit 2db0c03

Browse files
committed
New features:
- Added a new volume-wide cache for downloaded git objects that is shared amongst multiple repos. Only newly created repos will use the new cache location. Existing clones will continue to use their own private cache. - The installer now unmounts and remounts existing repos automatically - GVFS no longer forces an antivirus exclusion. This was a relic from long ago when the gvflt driver and the Defender driver used to interfere with each other, but antivirus is no longer GVFS's concern. - Added better diagnostic info in the GVFS logs when there are network errors - `git status` now supports an option to avoid doing its ahead/behind calculations. This allows the user to decide if they want to skip that overhead if all they care about is the status of the working directory. Bug fixes: - Lots of bug fixes to make GVFS's file writes (e.g. to its database files) more reliable, even in the face of power loss - GVFS can now recover from corrupted git object files (e.g. caused by a torn write), by re-downloading them whenever git asks for an object. The assumption is that git would not be asking GVFS for it if the object was valid. - Fixed an annoying bug where a Ctrl+C'd git process could leak a GVFS lock
1 parent a410acd commit 2db0c03

File tree

170 files changed

+6215
-2250
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+6215
-2250
lines changed

GVFS.sln

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GVFS", "GVFS", "{2EF2EC94-3
2222
EndProject
2323
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GVFS.GVFlt", "GVFS\GVFS.GVFlt\GVFS.GVFlt.csproj", "{1118B427-7063-422F-83B9-5023C8EC5A7A}"
2424
EndProject
25-
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GvLib", "GVFS\GVFS.GvFltWrapper\GvLib.vcxproj", "{FB0831AE-9997-401B-B31F-3A065FDBEB20}"
25+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GvLib.Managed", "GVFS\GVFS.GvFltWrapper\GvLib.vcxproj", "{FB0831AE-9997-401B-B31F-3A065FDBEB20}"
2626
ProjectSection(ProjectDependencies) = postProject
2727
{5A6656D5-81C7-472C-9DC8-32D071CB2258} = {5A6656D5-81C7-472C-9DC8-32D071CB2258}
2828
{374BF1E5-0B2D-4D4A-BD5E-4212299DEF09} = {374BF1E5-0B2D-4D4A-BD5E-4212299DEF09}
@@ -105,6 +105,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GitHooksLoader", "GitHooksL
105105
{A4984251-840E-4622-AD0C-66DFCE2B2574} = {A4984251-840E-4622-AD0C-66DFCE2B2574}
106106
EndProjectSection
107107
EndProject
108+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GVFS.Installer", "GVFS\GVFS.Installer\GVFS.Installer.csproj", "{3AB4FB1F-9E23-4CD8-BFAC-8A2221C8F893}"
109+
ProjectSection(ProjectDependencies) = postProject
110+
{32220664-594C-4425-B9A0-88E0BE2F3D2A} = {32220664-594C-4425-B9A0-88E0BE2F3D2A}
111+
EndProjectSection
112+
EndProject
108113
Global
109114
GlobalSection(SolutionConfigurationPlatforms) = preSolution
110115
Debug|x64 = Debug|x64
@@ -179,6 +184,10 @@ Global
179184
{798DE293-6EDA-4DC4-9395-BE7A71C563E3}.Debug|x64.Build.0 = Debug|x64
180185
{798DE293-6EDA-4DC4-9395-BE7A71C563E3}.Release|x64.ActiveCfg = Release|x64
181186
{798DE293-6EDA-4DC4-9395-BE7A71C563E3}.Release|x64.Build.0 = Release|x64
187+
{3AB4FB1F-9E23-4CD8-BFAC-8A2221C8F893}.Debug|x64.ActiveCfg = Debug|x64
188+
{3AB4FB1F-9E23-4CD8-BFAC-8A2221C8F893}.Debug|x64.Build.0 = Debug|x64
189+
{3AB4FB1F-9E23-4CD8-BFAC-8A2221C8F893}.Release|x64.ActiveCfg = Release|x64
190+
{3AB4FB1F-9E23-4CD8-BFAC-8A2221C8F893}.Release|x64.Build.0 = Release|x64
182191
EndGlobalSection
183192
GlobalSection(SolutionProperties) = preSolution
184193
HideSolutionNode = FALSE
@@ -201,5 +210,6 @@ Global
201210
{C5D3CA26-562F-4CA4-A378-B93E97A730E3} = {C41F10F9-1163-4CFA-A465-EA728F75E9FA}
202211
{93B403FD-DAFB-46C5-9636-B122792A548A} = {2EF2EC94-3A68-4ED7-9A58-B7057ADBA01C}
203212
{A4984251-840E-4622-AD0C-66DFCE2B2574} = {AB0D9230-3893-4486-8899-F9C871FB5D5F}
213+
{3AB4FB1F-9E23-4CD8-BFAC-8A2221C8F893} = {2EF2EC94-3A68-4ED7-9A58-B7057ADBA01C}
204214
EndGlobalSection
205215
EndGlobal

GVFS/FastFetch/FastFetch.csproj

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="..\LibGit2Sharp.NativeBinaries.props" Condition="Exists('..\LibGit2Sharp.NativeBinaries.props')" />
44
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
5+
<Import Project="$(SolutionDir)\GVFS\GVFS.Build\GVFS.props" />
56
<PropertyGroup>
6-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
7-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
87
<ProjectGuid>{07F2A520-2AB7-46DD-97C0-75D8E988D55B}</ProjectGuid>
98
<OutputType>Exe</OutputType>
109
<AppDesignerFolder>Properties</AppDesignerFolder>
@@ -18,8 +17,6 @@
1817
</PropertyGroup>
1918
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
2019
<DebugSymbols>true</DebugSymbols>
21-
<OutputPath>..\..\..\BuildOutput\FastFetch\bin\x64\Debug\</OutputPath>
22-
<IntermediateOutputPath>..\..\..\BuildOutput\FastFetch\obj\x64\Debug\</IntermediateOutputPath>
2320
<DefineConstants>DEBUG;TRACE</DefineConstants>
2421
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
2522
<DebugType>full</DebugType>
@@ -30,8 +27,6 @@
3027
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
3128
</PropertyGroup>
3229
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
33-
<OutputPath>..\..\..\BuildOutput\FastFetch\bin\x64\Release\</OutputPath>
34-
<IntermediateOutputPath>..\..\..\BuildOutput\FastFetch\obj\x64\Release\</IntermediateOutputPath>
3530
<DefineConstants>TRACE</DefineConstants>
3631
<Optimize>true</Optimize>
3732
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@@ -62,7 +57,7 @@
6257
<Reference Include="System.Xml" />
6358
</ItemGroup>
6459
<ItemGroup>
65-
<Compile Include="..\..\..\BuildOutput\CommonAssemblyVersion.cs">
60+
<Compile Include="$(BuildOutputDir)\CommonAssemblyVersion.cs">
6661
<Link>CommonAssemblyVersion.cs</Link>
6762
</Compile>
6863
<Compile Include="FastFetchVerb.cs" />

GVFS/FastFetch/FastFetchVerb.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ private int ExecuteWithExitCode()
211211
enlistment.EnlistmentRoot,
212212
enlistment.RepoUrl,
213213
cacheServer.Url,
214-
enlistment.GitObjectsRoot,
215214
new EventMetadata
216215
{
217216
{ "TargetCommitish", commitish },

GVFS/FastFetch/FetchHelper.cs

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using FastFetch.Git;
22
using FastFetch.Jobs;
33
using GVFS.Common;
4+
using GVFS.Common.FileSystem;
45
using GVFS.Common.Git;
56
using GVFS.Common.Http;
67
using GVFS.Common.Tracing;
@@ -129,6 +130,38 @@ public static bool TryLoadFileList(Enlistment enlistment, string filesInput, Lis
129130
return true;
130131
}
131132

133+
public static void AppendToNewlineSeparatedFile(string filename, string newContent)
134+
{
135+
AppendToNewlineSeparatedFile(new PhysicalFileSystem(), filename, newContent);
136+
}
137+
138+
public static void AppendToNewlineSeparatedFile(PhysicalFileSystem fileSystem, string filename, string newContent)
139+
{
140+
using (Stream fileStream = fileSystem.OpenFileStream(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite, false))
141+
{
142+
using (StreamReader reader = new StreamReader(fileStream))
143+
using (StreamWriter writer = new StreamWriter(fileStream))
144+
{
145+
long position = reader.BaseStream.Seek(0, SeekOrigin.End);
146+
if (position > 0)
147+
{
148+
reader.BaseStream.Seek(position - 1, SeekOrigin.Begin);
149+
}
150+
151+
string lastCharacter = reader.ReadToEnd();
152+
if (lastCharacter != "\n" && lastCharacter != string.Empty)
153+
{
154+
writer.Write("\n");
155+
}
156+
157+
writer.Write(newContent.Trim());
158+
writer.Write("\n");
159+
}
160+
161+
fileStream.Close();
162+
}
163+
}
164+
132165
/// <param name="branchOrCommit">A specific branch to filter for, or null for all branches returned from info/refs</param>
133166
public virtual void FastFetch(string branchOrCommit, bool isBranch)
134167
{
@@ -198,12 +231,22 @@ public void FastFetchWithStats(
198231
}
199232
}
200233

201-
new Thread(
202-
() =>
203-
{
204-
blobEnumerator.PerformDiff(previousCommit, commitToFetch);
205-
this.HasFailures |= blobEnumerator.HasFailures;
206-
}).Start();
234+
ThreadStart performDiff = () =>
235+
{
236+
blobEnumerator.PerformDiff(previousCommit, commitToFetch);
237+
this.HasFailures |= blobEnumerator.HasFailures;
238+
};
239+
240+
if (readFilesAfterDownload)
241+
{
242+
// Call synchronously to ensure that blobEnumerator.FileAddOperations
243+
// is completely populated when ReadFilesJob starts
244+
performDiff();
245+
}
246+
else
247+
{
248+
new Thread(performDiff).Start();
249+
}
207250

208251
BlockingCollection<string> availableBlobs = new BlockingCollection<string>();
209252

@@ -303,7 +346,7 @@ protected virtual void UpdateRefs(string branchOrCommit, bool isBranch, GitRefs
303346
}
304347

305348
// Update shallow file to ensure this is a valid shallow repo
306-
File.AppendAllText(Path.Combine(this.Enlistment.WorkingDirectoryRoot, GVFSConstants.DotGit.Shallow), commitSha + "\n");
349+
AppendToNewlineSeparatedFile(Path.Combine(this.Enlistment.WorkingDirectoryRoot, GVFSConstants.DotGit.Shallow), commitSha);
307350
}
308351

309352
protected bool UpdateRef(ITracer tracer, string refName, string targetCommitish)

GVFS/FastFetch/GitEnlistment.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@ private GitEnlistment(string repoRoot, string gitBinPath)
1212
repoRoot,
1313
null,
1414
gitBinPath,
15-
gvfsHooksRoot: null)
15+
gvfsHooksRoot: null,
16+
flushFileBuffersForPacks: false)
1617
{
1718
this.GitObjectsRoot = Path.Combine(repoRoot, GVFSConstants.DotGit.Objects.Root);
1819
this.GitPackRoot = Path.Combine(this.GitObjectsRoot, GVFSConstants.DotGit.Objects.Pack.Name);
1920
}
2021

21-
public override string GitObjectsRoot { get; }
22+
public override string GitObjectsRoot { get; protected set; }
2223

23-
public override string GitPackRoot { get; }
24+
public override string GitPackRoot { get; protected set; }
2425

2526
public string FastFetchLogRoot
2627
{

GVFS/FastFetch/Jobs/BatchObjectDownloadJob.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,12 @@ protected override void DoAfterWork()
140140
fileName = this.gitObjects.WriteLooseObject(
141141
response.Stream,
142142
sha,
143-
bufToCopyWith);
143+
overwriteExistingObject: false,
144+
bufToCopyWith: bufToCopyWith);
144145
this.AvailableObjects.Add(sha);
145146
break;
146147
case GitObjectContentType.PackFile:
147-
fileName = this.gitObjects.WriteTempPackFile(response);
148+
fileName = this.gitObjects.WriteTempPackFile(response.Stream);
148149
this.AvailablePacks.Add(new IndexPackRequest(fileName, request));
149150
break;
150151
case GitObjectContentType.BatchedLooseObjects:
@@ -153,7 +154,8 @@ protected override void DoAfterWork()
153154
this.gitObjects.WriteLooseObject(
154155
objectStream,
155156
sha1,
156-
bufToCopyWith);
157+
overwriteExistingObject: false,
158+
bufToCopyWith: bufToCopyWith);
157159
this.AvailableObjects.Add(sha1);
158160

159161
if (successfulDownloads != null)

GVFS/FastFetch/Jobs/ReadFilesJob.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private class NativeFileReader
8484

8585
public static SafeFileHandle Open(string fileName)
8686
{
87-
return CreateFile(fileName, GenericRead, (uint)FileShare.ReadWrite, 0, OpenExisting, 0, 0);
87+
return CreateFile(fileName, GenericRead, (uint)(FileShare.ReadWrite | FileShare.Delete), 0, OpenExisting, 0, 0);
8888
}
8989

9090
public static unsafe bool ReadOneByte(SafeFileHandle handle, byte[] buffer)

GVFS/GVFS.Build/GVFS.PreBuild.csproj

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<Import Project="GVFS.props" />
45
<PropertyGroup>
5-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
76
<ProjectGuid>{A4984251-840E-4622-AD0C-66DFCE2B2574}</ProjectGuid>
87
<OutputType>Library</OutputType>
98
<AppDesignerFolder>Properties</AppDesignerFolder>
@@ -14,8 +13,6 @@
1413
</PropertyGroup>
1514
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
1615
<DebugSymbols>true</DebugSymbols>
17-
<OutputPath>..\..\..\BuildOutput\GVFS.Build\bin\x64\Debug\</OutputPath>
18-
<IntermediateOutputPath>..\..\..\BuildOutput\GVFS.Build\obj\x64\Debug\</IntermediateOutputPath>
1916
<DefineConstants>DEBUG;TRACE</DefineConstants>
2017
<DebugType>full</DebugType>
2118
<PlatformTarget>x64</PlatformTarget>
@@ -26,8 +23,6 @@
2623
<RegisterForComInterop>true</RegisterForComInterop>
2724
</PropertyGroup>
2825
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
29-
<OutputPath>..\..\..\BuildOutput\GVFS.Build\bin\x64\Release\</OutputPath>
30-
<IntermediateOutputPath>..\..\..\BuildOutput\GVFS.Build\obj\x64\Release\</IntermediateOutputPath>
3126
<DefineConstants>TRACE</DefineConstants>
3227
<Optimize>true</Optimize>
3328
<DebugType>pdbonly</DebugType>
@@ -39,6 +34,11 @@
3934
<ItemGroup>
4035
<Compile Include="GenerateVersionInfo.cs" />
4136
</ItemGroup>
37+
<ItemGroup>
38+
<None Include="GVFS.props">
39+
<SubType>Designer</SubType>
40+
</None>
41+
</ItemGroup>
4242
<Target Name="GetTargetFrameworkProperties" />
4343
<Target Name="GetNativeManifest" />
4444
<Target Name="GetCopyToOutputDirectoryItems" />
@@ -51,11 +51,6 @@
5151
<Code Type="Class" Source="GenerateVersionInfo.cs" />
5252
</Task>
5353
</UsingTask>
54-
<PropertyGroup>
55-
<GVFSVersion>0.2.173.2</GVFSVersion>
56-
<PackagesPath>$(ProjectDir)..\..\..\packages</PackagesPath>
57-
<BuildOutputPath>$(ProjectDir)..\..\..\BuildOutput</BuildOutputPath>
58-
</PropertyGroup>
5954
<Target Name="Build">
6055
<CallTarget Targets="GenerateAll" />
6156
</Target>
@@ -67,6 +62,6 @@
6762
<Delete Files="$(BuildOutputPath)\CommonAssemblyVersion.cs;$(BuildOutputPath)\CommonVersionHeader.h" />
6863
</Target>
6964
<Target Name="GenerateAll">
70-
<GenerateVersionInfo Version="$(GVFSVersion)" BuildOutputPath="$(BuildOutputPath)" />
65+
<GenerateVersionInfo Version="$(GVFSVersion)" BuildOutputPath="$(BuildOutputDir)" />
7166
</Target>
7267
</Project>

GVFS/GVFS.Build/GVFS.props

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup Label="Parameters">
4+
<GVFSVersion>1.0.18026.1</GVFSVersion>
5+
<G4WPackageVersion>2.4882590</G4WPackageVersion>
6+
<BuildInstaller>true</BuildInstaller>
7+
</PropertyGroup>
8+
<PropertyGroup Label="DefaultSettings">
9+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
10+
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
11+
<BuildOutputDir>$(SolutionDir)..\BuildOutput</BuildOutputDir>
12+
<PackagesDir>$(SolutionDir)..\packages</PackagesDir>
13+
<OutputPath>$(BuildOutputDir)\$(MSBuildProjectName)\bin\$(Platform)\$(Configuration)\</OutputPath>
14+
<IntermediateOutputPath>$(BuildOutputDir)\$(MSBuildProjectName)\obj\$(Platform)\$(Configuration)\</IntermediateOutputPath>
15+
<OutDir>$(BuildOutputDir)\$(MSBuildProjectName)\bin\$(Platform)\$(Configuration)\</OutDir>
16+
<IntDir>$(BuildOutputDir)\$(MSBuildProjectName)\intermediate\$(Platform)\$(Configuration)\</IntDir>
17+
</PropertyGroup>
18+
</Project>

GVFS/GVFS.Build/GenerateVersionInfo.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ public override bool Execute()
1616
{
1717
this.Log.LogMessage(MessageImportance.High, "Creating version files");
1818

19+
if (!Directory.Exists(this.BuildOutputPath))
20+
{
21+
Directory.CreateDirectory(this.BuildOutputPath);
22+
}
23+
1924
File.WriteAllText(
2025
Path.Combine(this.BuildOutputPath, "CommonAssemblyVersion.cs"),
2126
string.Format(

0 commit comments

Comments
 (0)