public void MergeConflictEnsureStatusFailsDueToConfig()
        {
            // This is compared against the message emitted by GVFS.Hooks\Program.cs
            string expectedErrorMessagePart = "--no-renames --no-breaks";

            this.ValidateGitCommand("checkout " + GitRepoTests.ConflictTargetBranch);
            this.RunGitCommand("merge " + GitRepoTests.ConflictSourceBranch, checkStatus: false);

            ProcessResult result1 = GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, "status");

            result1.Errors.Contains(expectedErrorMessagePart);

            ProcessResult result2 = GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, "status --no-renames");

            result2.Errors.Contains(expectedErrorMessagePart);

            ProcessResult result3 = GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, "status --no-breaks");

            result3.Errors.Contains(expectedErrorMessagePart);

            // only renames in config
            GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, "config --local status.renames false");
            GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, "status --no-breaks").Errors.ShouldBeEmpty();
            ProcessResult result4 = GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, "status");

            result4.Errors.Contains(expectedErrorMessagePart);

            // only breaks in config
            GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, "config --local --unset status.renames");
            GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, "config --local status.breaks false");
            GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, "status --no-renames").Errors.ShouldBeEmpty();
            ProcessResult result5 = GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, "status");

            result5.Errors.Contains(expectedErrorMessagePart);

            // Complete setup to ensure teardown succeeds
            GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, "config --local status.renames false");
            GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, "config --local status.breaks false");
        }
        public void CheckoutCleansUpTombstones()
        {
            const string folderToDelete = "Scripts";

            // Delete directory to create the tombstone
            string directoryToDelete = this.Enlistment.GetVirtualPathTo(folderToDelete);

            this.fileSystem.DeleteDirectory(directoryToDelete);
            this.Enlistment.UnmountGVFS();

            // Remove the directory entry from modified paths so git will not keep the folder up to date
            string modifiedPathsFile    = Path.Combine(this.Enlistment.DotGVFSRoot, TestConstants.Databases.ModifiedPaths);
            string modifiedPathsContent = this.fileSystem.ReadAllText(modifiedPathsFile);

            modifiedPathsContent = string.Join(Delimiter, modifiedPathsContent.Split(new[] { Delimiter }, StringSplitOptions.RemoveEmptyEntries).Where(x => !x.StartsWith($"A {folderToDelete}/")));
            this.fileSystem.WriteAllText(modifiedPathsFile, modifiedPathsContent + Delimiter);

            // Add tombstone folder entry to the placeholder database so the checkout will remove the tombstone
            // and start projecting the folder again
            string placeholderDatabasePath = Path.Combine(this.Enlistment.DotGVFSRoot, TestConstants.Databases.VFSForGit);

            GVFSHelpers.AddPlaceholderFolder(placeholderDatabasePath, folderToDelete, TombstoneFolderPlaceholderType);

            this.Enlistment.MountGVFS();
            directoryToDelete.ShouldNotExistOnDisk(this.fileSystem);

            // checkout branch to remove tombstones and project the folder again
            GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, "checkout -f HEAD");
            directoryToDelete.ShouldBeADirectory(this.fileSystem);

            this.Enlistment.UnmountGVFS();

            string placholders = GVFSHelpers.GetAllSQLitePlaceholdersAsString(placeholderDatabasePath);

            placholders.ShouldNotContain(ignoreCase: false, unexpectedSubstrings: $"{folderToDelete}{GVFSHelpers.PlaceholderFieldDelimiter}{TombstoneFolderPlaceholderType}{GVFSHelpers.PlaceholderFieldDelimiter}");
        }
 private ProcessResult InvokeGitAgainstGVFSRepo(string command)
 {
     return(GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, command));
 }
 private void GitCheckoutCommitId(string commitId)
 {
     GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, "checkout " + commitId).Errors.ShouldContain("HEAD is now at " + commitId);
 }