Skip to content

Commit 0459b28

Browse files
authored
Merge pull request #496 from nickgra/fastfetchPort
Stand up FastFetch on MacOS
2 parents d30b669 + f379d3e commit 0459b28

38 files changed

Lines changed: 678 additions & 416 deletions

GVFS.sln

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GVFS.Common", "GVFS\GVFS.Co
2828
{A4984251-840E-4622-AD0C-66DFCE2B2574} = {A4984251-840E-4622-AD0C-66DFCE2B2574}
2929
EndProjectSection
3030
EndProject
31-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastFetch", "GVFS\FastFetch\FastFetch.csproj", "{07F2A520-2AB7-46DD-97C0-75D8E988D55B}"
31+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FastFetch", "GVFS\FastFetch\FastFetch.csproj", "{07F2A520-2AB7-46DD-97C0-75D8E988D55B}"
3232
EndProject
3333
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GVFS.Tests", "GVFS\GVFS.Tests\GVFS.Tests.csproj", "{72701BC3-5DA9-4C7A-BF10-9E98C9FC8EAC}"
3434
ProjectSection(ProjectDependencies) = postProject
@@ -104,7 +104,6 @@ EndProject
104104
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GVFS.SignFiles", "GVFS\GVFS.SignFiles\GVFS.SignFiles.csproj", "{2F63B22B-EE26-4266-BF17-28A9146483A1}"
105105
ProjectSection(ProjectDependencies) = postProject
106106
{17498502-AEFF-4E70-90CC-1D0B56A8ADF5} = {17498502-AEFF-4E70-90CC-1D0B56A8ADF5}
107-
{07F2A520-2AB7-46DD-97C0-75D8E988D55B} = {07F2A520-2AB7-46DD-97C0-75D8E988D55B}
108107
{1118B427-7063-422F-83B9-5023C8EC5A7A} = {1118B427-7063-422F-83B9-5023C8EC5A7A}
109108
{2D23AB54-541F-4ABC-8DCA-08C199E97ABB} = {2D23AB54-541F-4ABC-8DCA-08C199E97ABB}
110109
{F468B05A-95E5-46BC-8C67-B80A78527B7D} = {F468B05A-95E5-46BC-8C67-B80A78527B7D}
@@ -159,7 +158,6 @@ EndProject
159158
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GVFS.FunctionalTests.Windows", "GVFS\GVFS.FunctionalTests.Windows\GVFS.FunctionalTests.Windows.csproj", "{0F0A008E-AB12-40EC-A671-37A541B08C7F}"
160159
ProjectSection(ProjectDependencies) = postProject
161160
{17498502-AEFF-4E70-90CC-1D0B56A8ADF5} = {17498502-AEFF-4E70-90CC-1D0B56A8ADF5}
162-
{07F2A520-2AB7-46DD-97C0-75D8E988D55B} = {07F2A520-2AB7-46DD-97C0-75D8E988D55B}
163161
{3771C555-B5C1-45E2-B8B7-2CEF1619CDC5} = {3771C555-B5C1-45E2-B8B7-2CEF1619CDC5}
164162
{FA273F69-5762-43D8-AEA1-B4F08090D624} = {FA273F69-5762-43D8-AEA1-B4F08090D624}
165163
{B8C1DFBA-CAFD-4F7E-A1A3-E11907B5467B} = {B8C1DFBA-CAFD-4F7E-A1A3-E11907B5467B}
@@ -213,9 +211,11 @@ Global
213211
{374BF1E5-0B2D-4D4A-BD5E-4212299DEF09}.Release.Windows|x64.ActiveCfg = Release|x64
214212
{374BF1E5-0B2D-4D4A-BD5E-4212299DEF09}.Release.Windows|x64.Build.0 = Release|x64
215213
{07F2A520-2AB7-46DD-97C0-75D8E988D55B}.Debug.Mac|x64.ActiveCfg = Debug|x64
214+
{07F2A520-2AB7-46DD-97C0-75D8E988D55B}.Debug.Mac|x64.Build.0 = Debug|x64
216215
{07F2A520-2AB7-46DD-97C0-75D8E988D55B}.Debug.Windows|x64.ActiveCfg = Debug|x64
217216
{07F2A520-2AB7-46DD-97C0-75D8E988D55B}.Debug.Windows|x64.Build.0 = Debug|x64
218217
{07F2A520-2AB7-46DD-97C0-75D8E988D55B}.Release.Mac|x64.ActiveCfg = Release|x64
218+
{07F2A520-2AB7-46DD-97C0-75D8E988D55B}.Release.Mac|x64.Build.0 = Release|x64
219219
{07F2A520-2AB7-46DD-97C0-75D8E988D55B}.Release.Windows|x64.ActiveCfg = Release|x64
220220
{07F2A520-2AB7-46DD-97C0-75D8E988D55B}.Release.Windows|x64.Build.0 = Release|x64
221221
{72701BC3-5DA9-4C7A-BF10-9E98C9FC8EAC}.Debug.Mac|x64.ActiveCfg = Debug|x64

GVFS/FastFetch/App.config

Lines changed: 0 additions & 6 deletions
This file was deleted.

GVFS/FastFetch/CheckoutStage.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ private void HandleAllFileDeleteOperations()
250250

251251
private void HandleAllFileAddOperations()
252252
{
253-
using (PrefetchLibGit2Repo repo = new PrefetchLibGit2Repo(this.tracer, this.enlistment.WorkingDirectoryRoot))
253+
using (FastFetchLibGit2Repo repo = new FastFetchLibGit2Repo(this.tracer, this.enlistment.WorkingDirectoryRoot))
254254
{
255255
string availableBlob;
256256
while (this.AvailableBlobShas.TryTake(out availableBlob, Timeout.Infinite))
@@ -262,7 +262,7 @@ private void HandleAllFileAddOperations()
262262

263263
Interlocked.Increment(ref this.shasReceived);
264264

265-
HashSet<string> paths;
265+
HashSet<PathWithMode> paths;
266266
if (this.diff.FileAddOperations.TryRemove(availableBlob, out paths))
267267
{
268268
try
@@ -276,9 +276,9 @@ private void HandleAllFileAddOperations()
276276

277277
Interlocked.Add(ref this.bytesWritten, written);
278278

279-
foreach (string path in paths)
279+
foreach (PathWithMode modeAndPath in paths)
280280
{
281-
this.AddedOrEditedLocalFiles.Add(path);
281+
this.AddedOrEditedLocalFiles.Add(modeAndPath.Path);
282282

283283
if (Interlocked.Increment(ref this.fileWriteCount) % NumOperationsPerStatus == 0)
284284
{

GVFS/FastFetch/FastFetch.csproj

Lines changed: 54 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,54 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="..\LibGit2Sharp.NativeBinaries.props" Condition="Exists('..\LibGit2Sharp.NativeBinaries.props')" />
4-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
5-
<Import Project="$(SolutionDir)\GVFS\GVFS.Build\GVFS.cs.props" />
6-
<PropertyGroup>
7-
<ProjectGuid>{07F2A520-2AB7-46DD-97C0-75D8E988D55B}</ProjectGuid>
8-
<OutputType>Exe</OutputType>
9-
<AppDesignerFolder>Properties</AppDesignerFolder>
10-
<RootNamespace>FastFetch</RootNamespace>
11-
<AssemblyName>FastFetch</AssemblyName>
12-
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
13-
<FileAlignment>512</FileAlignment>
14-
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
15-
<NuGetPackageImportStamp>
16-
</NuGetPackageImportStamp>
17-
</PropertyGroup>
18-
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
19-
<DebugSymbols>true</DebugSymbols>
20-
<DefineConstants>DEBUG;TRACE</DefineConstants>
21-
<DebugType>full</DebugType>
22-
<PlatformTarget>x64</PlatformTarget>
23-
<ErrorReport>prompt</ErrorReport>
24-
<Prefer32Bit>true</Prefer32Bit>
25-
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
26-
</PropertyGroup>
27-
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
28-
<DefineConstants>TRACE</DefineConstants>
29-
<Optimize>true</Optimize>
30-
<DebugType>pdbonly</DebugType>
31-
<PlatformTarget>x64</PlatformTarget>
32-
<ErrorReport>prompt</ErrorReport>
33-
<Prefer32Bit>true</Prefer32Bit>
34-
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
35-
</PropertyGroup>
36-
<ItemGroup>
37-
<Reference Include="CommandLine, Version=2.0.275.0, Culture=neutral, PublicKeyToken=de6f01bd326f8c32, processorArchitecture=MSIL">
38-
<SpecificVersion>False</SpecificVersion>
39-
<HintPath>..\..\..\packages\CommandLineParser.2.1.1-beta\lib\net45\CommandLine.dll</HintPath>
40-
<Private>True</Private>
41-
</Reference>
42-
<Reference Include="System" />
43-
<Reference Include="System.Core" />
44-
<Reference Include="System.Xml.Linq" />
45-
<Reference Include="System.Data.DataSetExtensions" />
46-
<Reference Include="Microsoft.CSharp" />
47-
<Reference Include="System.Data" />
48-
<Reference Include="System.Net.Http" />
49-
<Reference Include="System.Xml" />
50-
</ItemGroup>
51-
<ItemGroup>
52-
<Compile Include="$(BuildOutputDir)\CommonAssemblyVersion.cs">
53-
<Link>CommonAssemblyVersion.cs</Link>
54-
</Compile>
55-
<Compile Include="CheckoutStage.cs" />
56-
<Compile Include="CheckoutPrefetcher.cs" />
57-
<Compile Include="FastFetchVerb.cs" />
58-
<Compile Include="..\GVFS.PlatformLoader\PlatformLoader.Windows.cs" />
59-
<Compile Include="GitEnlistment.cs" />
60-
<Compile Include="Index.cs" />
61-
<Compile Include="Program.cs" />
62-
<Compile Include="Properties\AssemblyInfo.cs" />
63-
<Compile Include="WorkingTree.cs" />
64-
</ItemGroup>
65-
<ItemGroup>
66-
<None Include="App.config" />
67-
<None Include="packages.config">
68-
<SubType>Designer</SubType>
69-
</None>
70-
</ItemGroup>
71-
<ItemGroup>
72-
<ProjectReference Include="..\GVFS.Common\GVFS.Common.csproj">
73-
<Project>{374bf1e5-0b2d-4d4a-bd5e-4212299def09}</Project>
74-
<Name>GVFS.Common</Name>
75-
</ProjectReference>
76-
<ProjectReference Include="..\GVFS.Platform.Windows\GVFS.Platform.Windows.csproj">
77-
<Project>{4ce404e7-d3fc-471c-993c-64615861ea63}</Project>
78-
<Name>GVFS.Platform.Windows</Name>
79-
</ProjectReference>
80-
<ProjectReference Include="..\GVFS.Virtualization\GVFS.Virtualization.csproj">
81-
<Project>{f468b05a-95e5-46bc-8c67-b80a78527b7d}</Project>
82-
<Name>GVFS.Virtualization</Name>
83-
</ProjectReference>
84-
</ItemGroup>
85-
<ItemGroup>
86-
<Analyzer Include="..\..\..\packages\StyleCop.Analyzers.1.0.2\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll" />
87-
<Analyzer Include="..\..\..\packages\StyleCop.Analyzers.1.0.2\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
88-
</ItemGroup>
89-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
90-
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
91-
<PropertyGroup>
92-
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
93-
</PropertyGroup>
94-
<Error Condition="!Exists('..\LibGit2Sharp.NativeBinaries.props')" Text="$([System.String]::Format('$(ErrorText)', '..\LibGit2Sharp.NativeBinaries.props'))" />
95-
</Target>
96-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
97-
Other similar extension points exist, see Microsoft.Common.targets.
98-
<Target Name="BeforeBuild">
99-
</Target>
100-
<Target Name="AfterBuild">
101-
</Target>
102-
-->
103-
</Project>
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<Import Project="..\GVFS.Build\GVFS.cs.props" />
3+
<Import Project="..\LibGit2Sharp.NativeBinaries.props" />
4+
<PropertyGroup>
5+
<OutputType>Exe</OutputType>
6+
<AssemblyName>FastFetch</AssemblyName>
7+
<TargetFramework>netcoreapp2.1</TargetFramework>
8+
<Platforms>x64</Platforms>
9+
<RunTimeIdentifiers>osx-x64;win-x64</RunTimeIdentifiers>
10+
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
11+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
12+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
13+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
14+
</PropertyGroup>
15+
16+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
17+
<Version>$(GVFSVersion)</Version>
18+
</PropertyGroup>
19+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
20+
<Version>$(GVFSVersion)</Version>
21+
</PropertyGroup>
22+
23+
<PropertyGroup Condition="'$(MSBuildRuntimeType)' == 'Core'">
24+
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
25+
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
26+
</PropertyGroup>
27+
28+
<ItemGroup>
29+
<ProjectReference Include="..\GVFS.Common\GVFS.Common.csproj" />
30+
<ProjectReference Include="..\GVFS.Virtualization\GVFS.Virtualization.csproj" />
31+
</ItemGroup>
32+
33+
<ItemGroup Condition="'$(IsOSX)' == 'true'">
34+
<ProjectReference Include="..\GVFS.Platform.Mac\GVFS.Platform.Mac.csproj" />
35+
<Compile Include="..\GVFS.PlatformLoader\PlatformLoader.Mac.cs">
36+
<Link>PlatformLoader.Mac.cs</Link>
37+
</Compile>
38+
</ItemGroup>
39+
40+
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
41+
<ProjectReference Include="..\GVFS.Platform.Windows\GVFS.Platform.Windows.csproj" />
42+
<Compile Include="..\GVFS.PlatformLoader\PlatformLoader.Windows.cs">
43+
<Link>PlatformLoader.Windows.cs</Link>
44+
</Compile>
45+
</ItemGroup>
46+
47+
<ItemGroup>
48+
<PackageReference Include="CommandLineParser" Version="2.1.1-beta" />
49+
<PackageReference Include="LibGit2Sharp.NativeBinaries" Version="1.0.165" />
50+
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
51+
<PrivateAssets>all</PrivateAssets>
52+
</PackageReference>
53+
</ItemGroup>
54+
</Project>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using GVFS.Common.Git;
2+
using GVFS.Common.Prefetch.Git;
3+
using GVFS.Common.Tracing;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Runtime.InteropServices;
8+
9+
namespace FastFetch
10+
{
11+
public class FastFetchLibGit2Repo : LibGit2Repo
12+
{
13+
public FastFetchLibGit2Repo(ITracer tracer, string repoPath)
14+
: base(tracer, repoPath)
15+
{
16+
}
17+
18+
public virtual bool TryCopyBlobToFile(string sha, IEnumerable<PathWithMode> destinations, out long bytesWritten)
19+
{
20+
IntPtr objHandle;
21+
if (Native.RevParseSingle(out objHandle, this.RepoHandle, sha) != Native.SuccessCode)
22+
{
23+
bytesWritten = 0;
24+
EventMetadata metadata = new EventMetadata();
25+
metadata.Add("ObjectSha", sha);
26+
this.Tracer.RelatedError(metadata, "Couldn't find object");
27+
return false;
28+
}
29+
30+
try
31+
{
32+
// Avoid marshalling raw content by using byte* and native writes
33+
unsafe
34+
{
35+
switch (Native.Object.GetType(objHandle))
36+
{
37+
case Native.ObjectTypes.Blob:
38+
byte* originalData = Native.Blob.GetRawContent(objHandle);
39+
long originalSize = Native.Blob.GetRawSize(objHandle);
40+
41+
foreach (PathWithMode destination in destinations)
42+
{
43+
NativeMethods.WriteFile(this.Tracer, originalData, originalSize, destination.Path, destination.Mode);
44+
}
45+
46+
bytesWritten = originalSize * destinations.Count();
47+
break;
48+
default:
49+
throw new NotSupportedException("Copying object types other than blobs is not supported.");
50+
}
51+
}
52+
}
53+
finally
54+
{
55+
Native.Object.Free(objHandle);
56+
}
57+
58+
return true;
59+
}
60+
}
61+
}

0 commit comments

Comments
 (0)