Esempio n. 1
0
        public void MountSetsCoreHooksPath()
        {
            try
            {
                GVFSHelpers.RegisterForOfflineIO();

                this.Enlistment.UnmountGVFS();

                GitProcess.Invoke(this.Enlistment.RepoRoot, "config --unset core.hookspath");
                string.IsNullOrWhiteSpace(
                    GitProcess.Invoke(this.Enlistment.RepoRoot, "config core.hookspath"))
                .ShouldBeTrue();

                this.Enlistment.MountGVFS();
                string expectedHooksPath = this.Enlistment.GetDotGitPath("hooks");
                expectedHooksPath = GitHelpers.ConvertPathToGitFormat(expectedHooksPath);

                GitProcess.Invoke(
                    this.Enlistment.RepoRoot, "config core.hookspath")
                .Trim('\n')
                .ShouldEqual(expectedHooksPath);
            }
            finally
            {
                GVFSHelpers.UnregisterForOfflineIO();
            }
        }
Esempio n. 2
0
        public void CheckoutBranchWithOpenHandleBlockingProjectionDeleteAndRepoMetdataUpdate()
        {
            try
            {
                GVFSHelpers.RegisterForOfflineIO();

                this.ControlGitRepo.Fetch(GitRepoTests.ConflictSourceBranch);
                this.ControlGitRepo.Fetch(GitRepoTests.ConflictTargetBranch);

                this.Enlistment.UnmountGVFS();
                string gitIndexPath = Path.Combine(this.Enlistment.RepoBackingRoot, ".git", "index");
                CopyIndexAndRename(gitIndexPath);
                this.Enlistment.MountGVFS();

                ManualResetEventSlim testReady  = new ManualResetEventSlim(initialState: false);
                ManualResetEventSlim fileLocked = new ManualResetEventSlim(initialState: false);
                Task task = Task.Run(() =>
                {
                    int attempts = 0;
                    while (attempts < 100)
                    {
                        try
                        {
                            using (FileStream projectionStream = new FileStream(Path.Combine(this.Enlistment.DotGVFSRoot, "GVFS_projection"), FileMode.Open, FileAccess.Read, FileShare.None))
                                using (FileStream metadataStream = new FileStream(Path.Combine(this.Enlistment.DotGVFSRoot, "databases", "RepoMetadata.dat"), FileMode.Open, FileAccess.Read, FileShare.None))
                                {
                                    fileLocked.Set();
                                    testReady.Set();
                                    Thread.Sleep(15000);
                                    return;
                                }
                        }
                        catch (Exception)
                        {
                            ++attempts;
                            Thread.Sleep(50);
                        }
                    }

                    testReady.Set();
                });

                // Wait for task to acquire the handle
                testReady.Wait();
                fileLocked.IsSet.ShouldBeTrue("Failed to obtain exclusive file handle.  Exclusive handle required to validate behavior");

                try
                {
                    this.ValidateGitCommand("checkout " + GitRepoTests.ConflictTargetBranch);
                }
                catch (Exception)
                {
                    // If the test fails, we should wait for the Task to complete so that it does not keep a handle open
                    task.Wait();
                    throw;
                }
            }
            finally
            {
                GVFSHelpers.UnregisterForOfflineIO();
            }
        }
Esempio n. 3
0
 public void TurnOfflineIOOn()
 {
     GVFSHelpers.RegisterForOfflineIO();
 }