Skip to content

Commit

Permalink
Merge pull request #1193: Mac ProjFS: Only hydrate/expand when deleti…
Browse files Browse the repository at this point in the history
…ng due to rename

Mac ProjFS: Only hydrate/expand when deleting due to rename
  • Loading branch information
jeschu1 committed Jun 13, 2019
2 parents dcdd18d + 63d18aa commit c7df435
Show file tree
Hide file tree
Showing 27 changed files with 851 additions and 63 deletions.
Expand Up @@ -376,19 +376,23 @@ public void FileMovedFromOutsideRepoToInside()
[TestCase, Order(17)]
public void FileMovedFromInsideRepoToOutside()
{
string fileName = "InsideRepoToOutside.txt";
string fileInsideRepo = this.Enlistment.GetVirtualPathTo(fileName);
this.fileSystem.WriteAllText(fileInsideRepo, "Contents for the new file");
fileInsideRepo.ShouldBeAFile(this.fileSystem);
this.Enlistment.WaitForBackgroundOperations();
GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileName);
string fileInsideRepoEntry = "GitCommandsTests/RenameFileTests/1/#test";
string fileNameFullPath = Path.Combine("GitCommandsTests", "RenameFileTests", "1", "#test");
string fileInsideRepo = this.Enlistment.GetVirtualPathTo(fileNameFullPath);
GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, fileInsideRepoEntry);

string fileNameOutsideRepo = "FileNameOutSideRepo";
string fileMovedOutsideRepo = Path.Combine(this.Enlistment.EnlistmentRoot, fileNameOutsideRepo);
GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, fileNameOutsideRepo);

string fileMovedOutsideRepo = Path.Combine(this.Enlistment.EnlistmentRoot, fileName);
this.fileSystem.MoveFile(fileInsideRepo, fileMovedOutsideRepo);

fileInsideRepo.ShouldNotExistOnDisk(this.fileSystem);
fileMovedOutsideRepo.ShouldBeAFile(this.fileSystem);
this.fileSystem.ReadAllText(fileMovedOutsideRepo).ShouldContain("test");
this.Enlistment.WaitForBackgroundOperations();
GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, fileName);
GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileInsideRepoEntry);
GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, fileNameOutsideRepo);
}

[TestCase, Order(18)]
Expand Down
4 changes: 4 additions & 0 deletions ProjFS.Mac/PrjFS.xcodeproj/project.pbxproj
Expand Up @@ -283,6 +283,8 @@
4A08257021E77BDD00E21AFD /* org.vfsforgit.prjfs.PrjFSKextLogDaemon.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = org.vfsforgit.prjfs.PrjFSKextLogDaemon.plist; sourceTree = "<group>"; };
4A08257121E77BDD00E21AFD /* PrjFSKextLogDaemon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrjFSKextLogDaemon.cpp; sourceTree = "<group>"; };
4A08257221E77BDD00E21AFD /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4A2A699B2295AA7800ACAAAF /* ArrayUtilities.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ArrayUtilities.hpp; sourceTree = "<group>"; };
4A2A699D2296BACE00ACAAAF /* KauthHandlerPrivate.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = KauthHandlerPrivate.hpp; sourceTree = "<group>"; };
4A2A699F2297339A00ACAAAF /* KextAssertIntegration.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KextAssertIntegration.m; sourceTree = "<group>"; };
4A2A69A12297375A00ACAAAF /* KextAssertIntegration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KextAssertIntegration.h; sourceTree = "<group>"; };
4A558DB822357AB000AFDE07 /* ProviderMessaging.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ProviderMessaging.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -439,9 +441,11 @@
4391F88D21E42AA70008103C /* PrjFSKext */ = {
isa = PBXGroup;
children = (
4A2A699B2295AA7800ACAAAF /* ArrayUtilities.hpp */,
4391F88F21E42AC40008103C /* Info.plist */,
4391F89321E42AC40008103C /* KauthHandler.cpp */,
4391F8A421E42AC50008103C /* KauthHandler.hpp */,
4A2A699D2296BACE00ACAAAF /* KauthHandlerPrivate.hpp */,
F5E39C8121F11556006D65C2 /* KauthHandlerTestable.hpp */,
4391F89021E42AC40008103C /* kernel-header-wrappers */,
4391F89121E42AC40008103C /* KextLog.cpp */,
Expand Down
24 changes: 24 additions & 0 deletions ProjFS.Mac/PrjFSKext/ArrayUtilities.hpp
@@ -0,0 +1,24 @@
#pragma once

template<typename T, size_t size>
constexpr size_t Array_Size(T (&array)[size])
{
return size;
}

template <typename T> void Array_CopyElements(T* destination, const T* source, size_t count)
{
for (size_t i = 0; i < count; ++i)
{
destination[i] = source[i];
}
}

template <typename T> void Array_DefaultInit(T* array, size_t count)
{
for (size_t i = 0; i < count; ++i)
{
array[i] = T();
}
}

0 comments on commit c7df435

Please sign in to comment.