Skip to content

Commit

Permalink
Merge remote-tracking branch 'msft/master' into powershell_hardlink_a…
Browse files Browse the repository at this point in the history
…nd_more_mac_tests
  • Loading branch information
wilbaker committed Sep 15, 2018
2 parents bc6f896 + 0cf25d4 commit e5dd216
Show file tree
Hide file tree
Showing 29 changed files with 640 additions and 557 deletions.
20 changes: 5 additions & 15 deletions GVFS/GVFS.Common/Prefetch/Git/GitIndexGenerator.cs
Expand Up @@ -60,11 +60,11 @@ public GitIndexGenerator(ITracer tracer, Enlistment enlistment, bool shouldHashI

public bool HasFailures { get; private set; }

public void CreateFromHeadTree(uint indexVersion, HashSet<string> sparseCheckoutEntries = null)
public void CreateFromHeadTree(uint indexVersion)
{
using (ITracer updateIndexActivity = this.tracer.StartActivity("CreateFromHeadTree", EventLevel.Informational))
{
Thread entryWritingThread = new Thread(() => this.WriteAllEntries(indexVersion, sparseCheckoutEntries));
Thread entryWritingThread = new Thread(() => this.WriteAllEntries(indexVersion));
entryWritingThread.Start();

GitProcess git = new GitProcess(this.enlistment);
Expand Down Expand Up @@ -94,7 +94,7 @@ private void EnqueueEntriesFromLsTree(string line)
}
}

private void WriteAllEntries(uint version, HashSet<string> sparseCheckoutEntries)
private void WriteAllEntries(uint version)
{
try
{
Expand All @@ -109,11 +109,7 @@ private void WriteAllEntries(uint version, HashSet<string> sparseCheckoutEntries
LsTreeEntry entry;
while (this.entryQueue.TryTake(out entry, Timeout.Infinite))
{
bool skipWorkTree =
sparseCheckoutEntries != null &&
!sparseCheckoutEntries.Contains(entry.Filename) &&
!sparseCheckoutEntries.Contains(this.GetDirectoryNameForGitPath(entry.Filename));
this.WriteEntry(writer, version, entry.Sha, entry.Filename, skipWorkTree, ref lastStringLength);
this.WriteEntry(writer, version, entry.Sha, entry.Filename, ref lastStringLength);
}

// Update entry count
Expand Down Expand Up @@ -143,7 +139,7 @@ private string GetDirectoryNameForGitPath(string filename)
return filename.Substring(0, idx + 1);
}

private void WriteEntry(BinaryWriter writer, uint version, string sha, string filename, bool skipWorktree, ref uint lastStringLength)
private void WriteEntry(BinaryWriter writer, uint version, string sha, string filename, ref uint lastStringLength)
{
long startPosition = writer.BaseStream.Position;

Expand All @@ -156,14 +152,8 @@ private void WriteEntry(BinaryWriter writer, uint version, string sha, string fi
byte[] filenameBytes = Encoding.UTF8.GetBytes(filename);

ushort flags = (ushort)(filenameBytes.Length & 0xFFF);
flags |= version >= 3 && skipWorktree ? ExtendedBit : (ushort)0;
writer.Write(EndianHelper.Swap(flags));

if (version >= 3 && skipWorktree)
{
writer.Write(EndianHelper.Swap(SkipWorktreeBit));
}

if (version >= 4)
{
this.WriteReplaceLength(writer, lastStringLength);
Expand Down
Expand Up @@ -101,6 +101,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Windows\Tests\DiskLayoutUpgradeTests.cs" />
<Compile Include="Windows\Tests\JunctionAndSubstTests.cs" />
<Compile Include="Windows\Tests\WindowsUpdatePlaceholderTests.cs.cs" />
<Compile Include="Windows\Tests\WindowsFileSystemTests.cs" />
<Compile Include="Windows\Tests\ServiceTests.cs" />
<Compile Include="Windows\Tests\SharedCacheUpgradeTests.cs" />
Expand Down
Expand Up @@ -27,6 +27,17 @@ public class DiskLayoutUpgradeTests : TestsWithEnlistmentPerTestCase

private FileSystemRunner fileSystem = new SystemIORunner();

[SetUp]
public override void CreateEnlistment()
{
base.CreateEnlistment();

// Since there isn't a sparse-checkout file that is used anymore one needs to be added
// in order to test the old upgrades that might have needed it
string sparseCheckoutPath = Path.Combine(this.Enlistment.RepoRoot, TestConstants.DotGit.Info.SparseCheckoutPath);
this.fileSystem.WriteAllText(sparseCheckoutPath, "/.gitattributes\r\n");
}

[TestCase]
public void MountUpgradesFromVersion7()
{
Expand Down
Expand Up @@ -48,6 +48,11 @@ public void MountUpgradesLocalSizesToSharedCache()
versionJsonPath.ShouldBeAFile(this.fileSystem);
this.fileSystem.DeleteFile(versionJsonPath);

// Since there isn't a sparse-checkout file that is used anymore one needs to be added
// in order to test the old upgrades that might have needed it
string sparseCheckoutPath = Path.Combine(enlistment.RepoRoot, TestConstants.DotGit.Info.SparseCheckoutPath);
this.fileSystem.WriteAllText(sparseCheckoutPath, "/.gitattributes\r\n");

// "13.0" was the last version before blob sizes were moved out of Esent
string metadataPath = Path.Combine(enlistment.DotGVFSRoot, GVFSHelpers.RepoMetadataName);
this.fileSystem.CreateEmptyFile(metadataPath);
Expand Down Expand Up @@ -103,6 +108,11 @@ public void MountUpgradesLocalSizesToSharedCache()
versionJsonPath.ShouldBeAFile(this.fileSystem);
this.fileSystem.DeleteFile(versionJsonPath);

// Since there isn't a sparse-checkout file that is used anymore one needs to be added
// in order to test the old upgrades that might have needed it
string sparseCheckoutPath2 = Path.Combine(enlistment2.RepoRoot, TestConstants.DotGit.Info.SparseCheckoutPath);
this.fileSystem.WriteAllText(sparseCheckoutPath2, "/.gitattributes\r\n");

// "13.0" was the last version before blob sizes were moved out of Esent
metadataPath = Path.Combine(enlistment2.DotGVFSRoot, GVFSHelpers.RepoMetadataName);
this.fileSystem.CreateEmptyFile(metadataPath);
Expand Down

0 comments on commit e5dd216

Please sign in to comment.