diff --git a/LibGit2Sharp.Tests/AttributesFixture.cs b/LibGit2Sharp.Tests/AttributesFixture.cs index 5092518b3..b6700becb 100644 --- a/LibGit2Sharp.Tests/AttributesFixture.cs +++ b/LibGit2Sharp.Tests/AttributesFixture.cs @@ -30,7 +30,7 @@ private static void AssertNormalization(IRepository repo, string filename, bool Touch(repo.Info.WorkingDirectory, filename, sb.ToString()); - repo.Index.Stage(filename); + repo.Stage(filename); IndexEntry entry = repo.Index[filename]; Assert.NotNull(entry); diff --git a/LibGit2Sharp.Tests/BlobFixture.cs b/LibGit2Sharp.Tests/BlobFixture.cs index f615aed18..8e2722425 100644 --- a/LibGit2Sharp.Tests/BlobFixture.cs +++ b/LibGit2Sharp.Tests/BlobFixture.cs @@ -62,7 +62,7 @@ public void CanGetBlobAsTextWithVariousEncodings(string encodingName, int expect var bomPath = Touch(repo.Info.WorkingDirectory, bomFile, content, encoding); Assert.Equal(expectedContentBytes, File.ReadAllBytes(bomPath).Length); - repo.Index.Stage(bomFile); + repo.Stage(bomFile); var commit = repo.Commit("bom", Constants.Signature, Constants.Signature); var blob = (Blob)commit.Tree[bomFile].Target; @@ -186,7 +186,7 @@ public void CanStageAFileGeneratedFromABlobContentStream() File.AppendAllText(Path.Combine(repo.Info.WorkingDirectory, "small.txt"), sb.ToString()); } - repo.Index.Stage("small.txt"); + repo.Stage("small.txt"); IndexEntry entry = repo.Index["small.txt"]; Assert.Equal("baae1fb3760a73481ced1fa03dc15614142c19ef", entry.Id.Sha); @@ -198,7 +198,7 @@ public void CanStageAFileGeneratedFromABlobContentStream() CopyStream(stream, file); } - repo.Index.Stage("small.fromblob.txt"); + repo.Stage("small.fromblob.txt"); IndexEntry newentry = repo.Index["small.fromblob.txt"]; Assert.Equal("baae1fb3760a73481ced1fa03dc15614142c19ef", newentry.Id.Sha); diff --git a/LibGit2Sharp.Tests/BranchFixture.cs b/LibGit2Sharp.Tests/BranchFixture.cs index 0aef1a27f..8893a20ed 100644 --- a/LibGit2Sharp.Tests/BranchFixture.cs +++ b/LibGit2Sharp.Tests/BranchFixture.cs @@ -966,7 +966,7 @@ public void TrackedBranchExistsFromDefaultConfigInEmptyClone() Assert.Equal("origin", repo.Head.Remote.Name); Touch(repo.Info.WorkingDirectory, "a.txt", "a"); - repo.Index.Stage("a.txt"); + repo.Stage("a.txt"); repo.Commit("A file", Constants.Signature, Constants.Signature); Assert.NotNull(repo.Head.Tip); diff --git a/LibGit2Sharp.Tests/CheckoutFixture.cs b/LibGit2Sharp.Tests/CheckoutFixture.cs index b3a095644..c8e6e9766 100644 --- a/LibGit2Sharp.Tests/CheckoutFixture.cs +++ b/LibGit2Sharp.Tests/CheckoutFixture.cs @@ -28,7 +28,7 @@ public void CanCheckoutAnExistingBranch(string branchName) // Set the working directory to the current head ResetAndCleanWorkingDirectory(repo); - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); Branch branch = repo.Branches[branchName]; Assert.NotNull(branch); @@ -45,7 +45,7 @@ public void CanCheckoutAnExistingBranch(string branchName) Assert.False(master.IsCurrentRepositoryHead); // Working directory should not be dirty - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); // Assert reflog entry is created var reflogEntry = repo.Refs.Log(repo.Refs.Head).First(); @@ -71,7 +71,7 @@ public void CanCheckoutAnExistingBranchByName(string branchName) // Set the working directory to the current head ResetAndCleanWorkingDirectory(repo); - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); Branch test = repo.Checkout(branchName); Assert.False(repo.Info.IsHeadDetached); @@ -83,7 +83,7 @@ public void CanCheckoutAnExistingBranchByName(string branchName) Assert.False(master.IsCurrentRepositoryHead); // Working directory should not be dirty - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); // Assert reflog entry is created var reflogEntry = repo.Refs.Log(repo.Refs.Head).First(); @@ -113,7 +113,7 @@ public void CanCheckoutAnArbitraryCommit(string commitPointer, bool checkoutByCo // Set the working directory to the current head ResetAndCleanWorkingDirectory(repo); - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); var commit = repo.Lookup(commitPointer); AssertBelongsToARepository(repo, commit); @@ -124,7 +124,7 @@ public void CanCheckoutAnArbitraryCommit(string commitPointer, bool checkoutByCo Assert.Equal(commit.Sha, detachedHead.Tip.Sha); Assert.True(repo.Head.IsCurrentRepositoryHead); Assert.True(repo.Info.IsHeadDetached); - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); Assert.True(detachedHead.IsCurrentRepositoryHead); Assert.False(detachedHead.IsRemote); @@ -156,7 +156,7 @@ public void CheckoutAddsMissingFilesInWorkingDirectory() // Remove the file in master branch // Verify it exists after checking out otherBranch. string fileFullPath = Path.Combine(repo.Info.WorkingDirectory, originalFilePath); - repo.Index.Remove(fileFullPath); + repo.Remove(fileFullPath); repo.Commit("2nd commit", Constants.Signature, Constants.Signature); // Checkout other_branch @@ -165,7 +165,7 @@ public void CheckoutAddsMissingFilesInWorkingDirectory() otherBranch.Checkout(); // Verify working directory is updated - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); Assert.Equal(originalFileContent, File.ReadAllText(fileFullPath)); } } @@ -184,7 +184,7 @@ public void CheckoutRemovesExtraFilesInWorkingDirectory() string newFileFullPath = Touch( repo.Info.WorkingDirectory, "b.txt", "hello from master branch!\n"); - repo.Index.Stage(newFileFullPath); + repo.Stage(newFileFullPath); repo.Commit("2nd commit", Constants.Signature, Constants.Signature); // Checkout other_branch @@ -193,7 +193,7 @@ public void CheckoutRemovesExtraFilesInWorkingDirectory() otherBranch.Checkout(); // Verify working directory is updated - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); Assert.False(File.Exists(newFileFullPath)); } } @@ -212,7 +212,7 @@ public void CheckoutUpdatesModifiedFilesInWorkingDirectory() string fullPath = Touch( repo.Info.WorkingDirectory, originalFilePath, "Update : hello from master branch!\n"); - repo.Index.Stage(fullPath); + repo.Stage(fullPath); repo.Commit("2nd commit", Constants.Signature, Constants.Signature); // Checkout other_branch @@ -221,7 +221,7 @@ public void CheckoutUpdatesModifiedFilesInWorkingDirectory() otherBranch.Checkout(); // Verify working directory is updated - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); Assert.Equal(originalFileContent, File.ReadAllText(fullPath)); } } @@ -246,7 +246,7 @@ public void CanForcefullyCheckoutWithConflictingStagedChanges() // Set the working directory to the current head. ResetAndCleanWorkingDirectory(repo); - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); // Create otherBranch from current Head. repo.Branches.Add(otherBranchName, master.Tip); @@ -254,7 +254,7 @@ public void CanForcefullyCheckoutWithConflictingStagedChanges() // Add change to master. Touch(repo.Info.WorkingDirectory, originalFilePath, originalFileContent); - repo.Index.Stage(originalFilePath); + repo.Stage(originalFilePath); repo.Commit("change in master", Constants.Signature, Constants.Signature); // Checkout otherBranch. @@ -262,7 +262,7 @@ public void CanForcefullyCheckoutWithConflictingStagedChanges() // Add change to otherBranch. Touch(repo.Info.WorkingDirectory, originalFilePath, alternateFileContent); - repo.Index.Stage(originalFilePath); + repo.Stage(originalFilePath); // Assert that normal checkout throws exception // for the conflict. @@ -275,7 +275,7 @@ public void CanForcefullyCheckoutWithConflictingStagedChanges() Assert.True(repo.Branches["master"].IsCurrentRepositoryHead); // And that the current index is not dirty. - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); } } @@ -287,7 +287,7 @@ public void CheckingOutWithMergeConflictsThrows() using (var repo = new Repository(repoPath)) { Touch(repo.Info.WorkingDirectory, originalFilePath, "Hello\n"); - repo.Index.Stage(originalFilePath); + repo.Stage(originalFilePath); repo.Commit("Initial commit", Constants.Signature, Constants.Signature); // Create 2nd branch @@ -295,7 +295,7 @@ public void CheckingOutWithMergeConflictsThrows() // Update file in main Touch(repo.Info.WorkingDirectory, originalFilePath, "Hello from master!\n"); - repo.Index.Stage(originalFilePath); + repo.Stage(originalFilePath); repo.Commit("2nd commit", Constants.Signature, Constants.Signature); // Checkout branch2 @@ -307,7 +307,7 @@ public void CheckingOutWithMergeConflictsThrows() Assert.Throws(() => repo.Checkout("master")); // And when there are staged commits - repo.Index.Stage(originalFilePath); + repo.Stage(originalFilePath); Assert.Throws(() => repo.Checkout("master")); } } @@ -322,7 +322,7 @@ public void CanCancelCheckoutThroughNotifyCallback() string relativePath = "a.txt"; Touch(repo.Info.WorkingDirectory, relativePath, "Hello\n"); - repo.Index.Stage(relativePath); + repo.Stage(relativePath); repo.Commit("Initial commit", Constants.Signature, Constants.Signature); // Create 2nd branch @@ -330,7 +330,7 @@ public void CanCancelCheckoutThroughNotifyCallback() // Update file in main Touch(repo.Info.WorkingDirectory, relativePath, "Hello from master!\n"); - repo.Index.Stage(relativePath); + repo.Stage(relativePath); repo.Commit("2nd commit", Constants.Signature, Constants.Signature); // Checkout branch2 @@ -449,13 +449,13 @@ public void CheckingOutCallsCheckoutNotify(CheckoutNotifyFlags notifyFlags, stri string relativePathUpdated = "updated.txt"; Touch(repo.Info.WorkingDirectory, relativePathUpdated, "updated file text A"); - repo.Index.Stage(relativePathUpdated); + repo.Stage(relativePathUpdated); repo.Commit("Commit initial update file", Constants.Signature, Constants.Signature); // Create conflicting change string relativePathConflict = "conflict.txt"; Touch(repo.Info.WorkingDirectory, relativePathConflict, "conflict file text A"); - repo.Index.Stage(relativePathConflict); + repo.Stage(relativePathConflict); repo.Commit("Initial commit of conflict.txt and update.txt", Constants.Signature, Constants.Signature); // Create another branch @@ -463,9 +463,9 @@ public void CheckingOutCallsCheckoutNotify(CheckoutNotifyFlags notifyFlags, stri // Make an edit to conflict.txt and update.txt Touch(repo.Info.WorkingDirectory, relativePathUpdated, "updated file text BB"); - repo.Index.Stage(relativePathUpdated); + repo.Stage(relativePathUpdated); Touch(repo.Info.WorkingDirectory, relativePathConflict, "conflict file text BB"); - repo.Index.Stage(relativePathConflict); + repo.Stage(relativePathConflict); repo.Commit("2nd commit of conflict.txt and update.txt on master branch", Constants.Signature, Constants.Signature); @@ -474,14 +474,14 @@ public void CheckingOutCallsCheckoutNotify(CheckoutNotifyFlags notifyFlags, stri // Make alternate edits to conflict.txt and update.txt Touch(repo.Info.WorkingDirectory, relativePathUpdated, "updated file text CCC"); - repo.Index.Stage(relativePathUpdated); + repo.Stage(relativePathUpdated); Touch(repo.Info.WorkingDirectory, relativePathConflict, "conflict file text CCC"); - repo.Index.Stage(relativePathConflict); + repo.Stage(relativePathConflict); repo.Commit("2nd commit of conflict.txt and update.txt on newbranch", Constants.Signature, Constants.Signature); // make conflicting change to conflict.txt Touch(repo.Info.WorkingDirectory, relativePathConflict, "conflict file text DDDD"); - repo.Index.Stage(relativePathConflict); + repo.Stage(relativePathConflict); // Create ignored change string relativePathIgnore = Path.Combine("bin", "ignored.txt"); @@ -522,14 +522,14 @@ public void CheckoutRetainsUntrackedChanges() string fullPathFileB = Touch(repo.Info.WorkingDirectory, "b.txt", alternateFileContent); // Verify that there is an untracked entry. - Assert.Equal(1, repo.Index.RetrieveStatus().Untracked.Count()); - Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus(fullPathFileB)); + Assert.Equal(1, repo.RetrieveStatus().Untracked.Count()); + Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus(fullPathFileB)); repo.Checkout(otherBranchName); // Verify untracked entry still exists. - Assert.Equal(1, repo.Index.RetrieveStatus().Untracked.Count()); - Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus(fullPathFileB)); + Assert.Equal(1, repo.RetrieveStatus().Untracked.Count()); + Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus(fullPathFileB)); } } @@ -546,14 +546,14 @@ public void ForceCheckoutRetainsUntrackedChanges() string fullPathFileB = Touch(repo.Info.WorkingDirectory, "b.txt", alternateFileContent); // Verify that there is an untracked entry. - Assert.Equal(1, repo.Index.RetrieveStatus().Untracked.Count()); - Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus(fullPathFileB)); + Assert.Equal(1, repo.RetrieveStatus().Untracked.Count()); + Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus(fullPathFileB)); repo.Checkout(otherBranchName, new CheckoutOptions() { CheckoutModifiers = CheckoutModifiers.Force }); // Verify untracked entry still exists. - Assert.Equal(1, repo.Index.RetrieveStatus().Untracked.Count()); - Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus(fullPathFileB)); + Assert.Equal(1, repo.RetrieveStatus().Untracked.Count()); + Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus(fullPathFileB)); } } @@ -570,14 +570,14 @@ public void CheckoutRetainsUnstagedChanges() string fullPathFileA = Touch(repo.Info.WorkingDirectory, originalFilePath, alternateFileContent); // Verify that there is a modified entry. - Assert.Equal(1, repo.Index.RetrieveStatus().Modified.Count()); - Assert.Equal(FileStatus.Modified, repo.Index.RetrieveStatus(fullPathFileA)); + Assert.Equal(1, repo.RetrieveStatus().Modified.Count()); + Assert.Equal(FileStatus.Modified, repo.RetrieveStatus(fullPathFileA)); repo.Checkout(otherBranchName); // Verify modified entry still exists. - Assert.Equal(1, repo.Index.RetrieveStatus().Modified.Count()); - Assert.Equal(FileStatus.Modified, repo.Index.RetrieveStatus(fullPathFileA)); + Assert.Equal(1, repo.RetrieveStatus().Modified.Count()); + Assert.Equal(FileStatus.Modified, repo.RetrieveStatus(fullPathFileA)); } } @@ -592,17 +592,17 @@ public void CheckoutRetainsStagedChanges() // Generate a staged change. string fullPathFileA = Touch(repo.Info.WorkingDirectory, originalFilePath, alternateFileContent); - repo.Index.Stage(fullPathFileA); + repo.Stage(fullPathFileA); // Verify that there is a staged entry. - Assert.Equal(1, repo.Index.RetrieveStatus().Staged.Count()); - Assert.Equal(FileStatus.Staged, repo.Index.RetrieveStatus(fullPathFileA)); + Assert.Equal(1, repo.RetrieveStatus().Staged.Count()); + Assert.Equal(FileStatus.Staged, repo.RetrieveStatus(fullPathFileA)); repo.Checkout(otherBranchName); // Verify staged entry still exists. - Assert.Equal(1, repo.Index.RetrieveStatus().Staged.Count()); - Assert.Equal(FileStatus.Staged, repo.Index.RetrieveStatus(fullPathFileA)); + Assert.Equal(1, repo.RetrieveStatus().Staged.Count()); + Assert.Equal(FileStatus.Staged, repo.RetrieveStatus(fullPathFileA)); } } @@ -621,14 +621,14 @@ public void CheckoutRetainsIgnoredChanges() "bin/some_ignored_file.txt", "hello from this ignored file."); - Assert.Equal(1, repo.Index.RetrieveStatus().Ignored.Count()); + Assert.Equal(1, repo.RetrieveStatus().Ignored.Count()); - Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus(ignoredFilePath)); + Assert.Equal(FileStatus.Ignored, repo.RetrieveStatus(ignoredFilePath)); repo.Checkout(otherBranchName); // Verify that the ignored file still exists. - Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus(ignoredFilePath)); + Assert.Equal(FileStatus.Ignored, repo.RetrieveStatus(ignoredFilePath)); Assert.True(File.Exists(ignoredFilePath)); } } @@ -648,14 +648,14 @@ public void ForceCheckoutRetainsIgnoredChanges() "bin/some_ignored_file.txt", "hello from this ignored file."); - Assert.Equal(1, repo.Index.RetrieveStatus().Ignored.Count()); + Assert.Equal(1, repo.RetrieveStatus().Ignored.Count()); - Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus(ignoredFilePath)); + Assert.Equal(FileStatus.Ignored, repo.RetrieveStatus(ignoredFilePath)); repo.Checkout(otherBranchName, new CheckoutOptions() { CheckoutModifiers = CheckoutModifiers.Force }); // Verify that the ignored file still exists. - Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus(ignoredFilePath)); + Assert.Equal(FileStatus.Ignored, repo.RetrieveStatus(ignoredFilePath)); Assert.True(File.Exists(ignoredFilePath)); } } @@ -676,7 +676,7 @@ public void CheckoutBranchSnapshot() // Add commit to master string fullPath = Touch(repo.Info.WorkingDirectory, originalFilePath, "Update : hello from master branch!\n"); - repo.Index.Stage(fullPath); + repo.Stage(fullPath); repo.Commit("2nd commit", Constants.Signature, Constants.Signature); Assert.False(repo.Info.IsHeadDetached); @@ -685,7 +685,7 @@ public void CheckoutBranchSnapshot() // Head should point at initial commit. Assert.Equal(repo.Head.Tip, initialCommit); - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); // Verify that HEAD is detached. Assert.Equal(repo.Refs["HEAD"].TargetIdentifier, initial.Tip.Sha); @@ -753,7 +753,7 @@ public void CheckoutFromDetachedHead(string commitPointer) { // Set the working directory to the current head ResetAndCleanWorkingDirectory(repo); - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); var commitSha = repo.Lookup(commitPointer).Sha; @@ -779,7 +779,7 @@ public void CheckoutBranchFromDetachedHead() { // Set the working directory to the current head ResetAndCleanWorkingDirectory(repo); - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); Branch initialHead = repo.Checkout("6dcf9bf"); @@ -804,7 +804,7 @@ public void CheckoutBranchByShortNameAttachesTheHead(string shortBranchName, str { // Set the working directory to the current head ResetAndCleanWorkingDirectory(repo); - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); repo.Checkout("6dcf9bf"); Assert.True(repo.Info.IsHeadDetached); @@ -825,7 +825,7 @@ public void CheckoutPreviousCheckedOutBranch() { // Set the working directory to the current head ResetAndCleanWorkingDirectory(repo); - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); Branch previousHead = repo.Checkout("i-do-numbers"); repo.Checkout("diff-test-cases"); @@ -849,7 +849,7 @@ public void CheckoutCurrentReference() Assert.True(master.IsCurrentRepositoryHead); ResetAndCleanWorkingDirectory(repo); - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); var reflogEntriesCount = repo.Refs.Log(repo.Refs.Head).Count(); @@ -943,12 +943,12 @@ public void CanCheckoutPath(string originalBranch, string checkoutFrom, string p ResetAndCleanWorkingDirectory(repo); repo.Checkout(originalBranch); - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); repo.CheckoutPaths(checkoutFrom, new[] { path }); - Assert.Equal(expectedStatus, repo.Index.RetrieveStatus(path)); - Assert.Equal(1, repo.Index.RetrieveStatus().Count()); + Assert.Equal(expectedStatus, repo.RetrieveStatus(path)); + Assert.Equal(1, repo.RetrieveStatus().Count()); } } @@ -962,13 +962,13 @@ public void CanCheckoutPaths() { // Set the working directory to the current head ResetAndCleanWorkingDirectory(repo); - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); repo.CheckoutPaths("i-do-numbers", checkoutPaths); foreach (string checkoutPath in checkoutPaths) { - Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(checkoutPath)); + Assert.Equal(FileStatus.Added, repo.RetrieveStatus(checkoutPath)); } } } @@ -982,7 +982,7 @@ public void CannotCheckoutPathsWithEmptyOrNullPathArgument() { // Set the working directory to the current head ResetAndCleanWorkingDirectory(repo); - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); // Passing null 'paths' parameter should throw Assert.Throws(typeof(ArgumentNullException), @@ -990,7 +990,7 @@ public void CannotCheckoutPathsWithEmptyOrNullPathArgument() // Passing empty list should do nothing repo.CheckoutPaths("i-do-numbers", Enumerable.Empty()); - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); } } @@ -1006,16 +1006,16 @@ public void CanCheckoutPathFromCurrentBranch(string fileName) // Set the working directory to the current head ResetAndCleanWorkingDirectory(repo); - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); Touch(repo.Info.WorkingDirectory, fileName, "new text file"); - Assert.True(repo.Index.RetrieveStatus().IsDirty); + Assert.True(repo.RetrieveStatus().IsDirty); var opts = new CheckoutOptions { CheckoutModifiers = CheckoutModifiers.Force }; repo.CheckoutPaths("HEAD", new[] { fileName }, opts); - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); } } @@ -1028,10 +1028,10 @@ private void PopulateBasicRepository(IRepository repo) { // Generate a .gitignore file. string gitIgnoreFilePath = Touch(repo.Info.WorkingDirectory, ".gitignore", "bin"); - repo.Index.Stage(gitIgnoreFilePath); + repo.Stage(gitIgnoreFilePath); string fullPathFileA = Touch(repo.Info.WorkingDirectory, originalFilePath, originalFileContent); - repo.Index.Stage(fullPathFileA); + repo.Stage(fullPathFileA); repo.Commit("Initial commit", Constants.Signature, Constants.Signature); diff --git a/LibGit2Sharp.Tests/CherryPickFixture.cs b/LibGit2Sharp.Tests/CherryPickFixture.cs index 8ce6b04a0..7afb3f033 100644 --- a/LibGit2Sharp.Tests/CherryPickFixture.cs +++ b/LibGit2Sharp.Tests/CherryPickFixture.cs @@ -28,7 +28,7 @@ public void CanCherryPick(bool fromDetachedHead) Assert.Equal(CherryPickStatus.CherryPicked, result.Status); Assert.Equal(cherryPickedCommitId, result.Commit.Id.Sha); - Assert.False(repo.Index.RetrieveStatus().Any()); + Assert.False(repo.RetrieveStatus().Any()); Assert.Equal(fromDetachedHead, repo.Info.IsHeadDetached); Assert.Equal(commitToMerge.Author, result.Commit.Author); Assert.Equal(Constants.Signature, result.Commit.Committer); @@ -130,7 +130,7 @@ private Commit AddFileCommitToRepo(IRepository repository, string filename, stri { Touch(repository.Info.WorkingDirectory, filename, content); - repository.Index.Stage(filename); + repository.Stage(filename); return repository.Commit("New commit", Constants.Signature, Constants.Signature); } diff --git a/LibGit2Sharp.Tests/CleanFixture.cs b/LibGit2Sharp.Tests/CleanFixture.cs index 9613a2c96..358000b94 100644 --- a/LibGit2Sharp.Tests/CleanFixture.cs +++ b/LibGit2Sharp.Tests/CleanFixture.cs @@ -13,14 +13,14 @@ public void CanCleanWorkingDirectory() using (var repo = new Repository(path)) { // Verify that there are the expected number of entries and untracked files - Assert.Equal(6, repo.Index.RetrieveStatus().Count()); - Assert.Equal(1, repo.Index.RetrieveStatus().Untracked.Count()); + Assert.Equal(6, repo.RetrieveStatus().Count()); + Assert.Equal(1, repo.RetrieveStatus().Untracked.Count()); repo.RemoveUntrackedFiles(); // Verify that there are the expected number of entries and 0 untracked files - Assert.Equal(5, repo.Index.RetrieveStatus().Count()); - Assert.Equal(0, repo.Index.RetrieveStatus().Untracked.Count()); + Assert.Equal(5, repo.RetrieveStatus().Count()); + Assert.Equal(0, repo.RetrieveStatus().Untracked.Count()); } } diff --git a/LibGit2Sharp.Tests/CommitFixture.cs b/LibGit2Sharp.Tests/CommitFixture.cs index e372fd7d2..6ac64c31f 100644 --- a/LibGit2Sharp.Tests/CommitFixture.cs +++ b/LibGit2Sharp.Tests/CommitFixture.cs @@ -534,10 +534,10 @@ public void CanCommitWithSignatureFromConfig() const string relativeFilepath = "new.txt"; string filePath = Touch(repo.Info.WorkingDirectory, relativeFilepath, "null"); - repo.Index.Stage(relativeFilepath); + repo.Stage(relativeFilepath); File.AppendAllText(filePath, "token\n"); - repo.Index.Stage(relativeFilepath); + repo.Stage(relativeFilepath); Assert.Null(repo.Head[relativeFilepath]); @@ -594,7 +594,7 @@ public void CommitCleansUpMergeMetadata() const string relativeFilepath = "new.txt"; Touch(repo.Info.WorkingDirectory, relativeFilepath, "this is a new file"); - repo.Index.Stage(relativeFilepath); + repo.Stage(relativeFilepath); string mergeHeadPath = Touch(repo.Info.Path, "MERGE_HEAD", "abcdefabcdefabcdefabcdefabcdefabcdefabcd"); string mergeMsgPath = Touch(repo.Info.Path, "MERGE_MSG", "This is a dummy merge.\n"); @@ -629,9 +629,9 @@ public void CanCommitALittleBit() const string relativeFilepath = "new.txt"; string filePath = Touch(repo.Info.WorkingDirectory, relativeFilepath, "null"); - repo.Index.Stage(relativeFilepath); + repo.Stage(relativeFilepath); File.AppendAllText(filePath, "token\n"); - repo.Index.Stage(relativeFilepath); + repo.Stage(relativeFilepath); Assert.Null(repo.Head[relativeFilepath]); @@ -662,7 +662,7 @@ public void CanCommitALittleBit() Assert.Equal(commit.Id, repo.Refs.Log(targetCanonicalName).First().To); File.WriteAllText(filePath, "nulltoken commits!\n"); - repo.Index.Stage(relativeFilepath); + repo.Stage(relativeFilepath); var author2 = new Signature(author.Name, author.Email, author.When.AddSeconds(5)); Commit commit2 = repo.Commit("Are you trying to fork me?", author2, author2); @@ -683,7 +683,7 @@ public void CanCommitALittleBit() File.WriteAllText(filePath, "davidfowl commits!\n"); var author3 = new Signature("David Fowler", "david.fowler@microsoft.com", author.When.AddSeconds(2)); - repo.Index.Stage(relativeFilepath); + repo.Stage(relativeFilepath); Commit commit3 = repo.Commit("I'm going to branch you backwards in time!", author3, author3); @@ -709,7 +709,7 @@ private static void AddCommitToRepo(string path) { const string relativeFilepath = "test.txt"; Touch(repo.Info.WorkingDirectory, relativeFilepath, "test\n"); - repo.Index.Stage(relativeFilepath); + repo.Stage(relativeFilepath); var author = new Signature("nulltoken", "emeric.fermas@gmail.com", DateTimeOffset.Parse("Wed, Dec 14 2011 08:29:03 +0100")); repo.Commit("Initial commit", author, author); @@ -793,7 +793,7 @@ private static void CreateAndStageANewFile(IRepository repo) { string relativeFilepath = string.Format("new-file-{0}.txt", Guid.NewGuid()); Touch(repo.Info.WorkingDirectory, relativeFilepath, "brand new content\n"); - repo.Index.Stage(relativeFilepath); + repo.Stage(relativeFilepath); } private static void AssertCommitHasBeenAmended(IRepository repo, Commit amendedCommit, Commit originalCommit) @@ -882,7 +882,7 @@ public void CanCommitOnOrphanedBranch() const string relativeFilepath = "test.txt"; Touch(repo.Info.WorkingDirectory, relativeFilepath, "test\n"); - repo.Index.Stage(relativeFilepath); + repo.Stage(relativeFilepath); repo.Commit("Initial commit", Constants.Signature, Constants.Signature); Assert.Equal(1, repo.Head.Commits.Count()); @@ -998,16 +998,16 @@ public void CanNotAmendACommitInAWayThatWouldLeadTheNewCommitToBecomeEmpty() using (var repo = new Repository(repoPath)) { Touch(repo.Info.WorkingDirectory, "test.txt", "test\n"); - repo.Index.Stage("test.txt"); + repo.Stage("test.txt"); repo.Commit("Initial commit", Constants.Signature, Constants.Signature); Touch(repo.Info.WorkingDirectory, "new.txt", "content\n"); - repo.Index.Stage("new.txt"); + repo.Stage("new.txt"); repo.Commit("One commit", Constants.Signature, Constants.Signature); - repo.Index.Remove("new.txt"); + repo.Remove("new.txt"); Assert.Throws(() => repo.Commit("Oops", Constants.Signature, Constants.Signature, new CommitOptions { AmendPreviousCommit = true })); diff --git a/LibGit2Sharp.Tests/ConflictFixture.cs b/LibGit2Sharp.Tests/ConflictFixture.cs index 9a98bd1b6..148081c4c 100644 --- a/LibGit2Sharp.Tests/ConflictFixture.cs +++ b/LibGit2Sharp.Tests/ConflictFixture.cs @@ -77,12 +77,12 @@ public void CanResolveConflictsByRemovingFromTheIndex( Assert.NotNull(repo.Index.Conflicts[filename]); Assert.Equal(0, repo.Index.Conflicts.ResolvedConflicts.Count()); - repo.Index.Remove(filename, removeFromWorkdir); + repo.Remove(filename, removeFromWorkdir); Assert.Null(repo.Index.Conflicts[filename]); Assert.Equal(count - removedIndexEntries, repo.Index.Count); Assert.Equal(existsAfterRemove, File.Exists(fullpath)); - Assert.Equal(lastStatus, repo.Index.RetrieveStatus(filename)); + Assert.Equal(lastStatus, repo.RetrieveStatus(filename)); Assert.Equal(1, repo.Index.Conflicts.ResolvedConflicts.Count()); Assert.NotNull(repo.Index.Conflicts.ResolvedConflicts[filename]); diff --git a/LibGit2Sharp.Tests/DiffTreeToTargetFixture.cs b/LibGit2Sharp.Tests/DiffTreeToTargetFixture.cs index d58508ca8..79055475f 100644 --- a/LibGit2Sharp.Tests/DiffTreeToTargetFixture.cs +++ b/LibGit2Sharp.Tests/DiffTreeToTargetFixture.cs @@ -12,12 +12,12 @@ private static void SetUpSimpleDiffContext(IRepository repo) { var fullpath = Touch(repo.Info.WorkingDirectory, "file.txt", "hello\n"); - repo.Index.Stage(fullpath); + repo.Stage(fullpath); repo.Commit("Initial commit", Constants.Signature, Constants.Signature); File.AppendAllText(fullpath, "world\n"); - repo.Index.Stage(fullpath); + repo.Stage(fullpath); File.AppendAllText(fullpath, "!!!\n"); } @@ -158,10 +158,10 @@ public void ShowcaseTheDifferenceBetweenTheTwoKindOfComparison() var fullpath = Path.Combine(repo.Info.WorkingDirectory, "file.txt"); File.Move(fullpath, fullpath + ".bak"); - repo.Index.Stage(fullpath); + repo.Stage(fullpath); File.Move(fullpath + ".bak", fullpath); - FileStatus state = repo.Index.RetrieveStatus("file.txt"); + FileStatus state = repo.RetrieveStatus("file.txt"); Assert.Equal(FileStatus.Removed | FileStatus.Untracked, state); var wrkDirToIdxToTree = repo.Diff.Compare(repo.Head.Tip.Tree, @@ -373,11 +373,11 @@ public void CanCopeWithEndOfFileNewlineChanges() { var fullpath = Touch(repo.Info.WorkingDirectory, "file.txt", "a"); - repo.Index.Stage("file.txt"); + repo.Stage("file.txt"); repo.Commit("Add file without line ending", Constants.Signature, Constants.Signature); File.AppendAllText(fullpath, "\n"); - repo.Index.Stage("file.txt"); + repo.Stage("file.txt"); var changes = repo.Diff.Compare(repo.Head.Tip.Tree, DiffTargets.Index); Assert.Equal(1, changes.Modified.Count()); diff --git a/LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs b/LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs index ea230a037..2ba238f4f 100644 --- a/LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs +++ b/LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs @@ -96,7 +96,7 @@ public void CanDetectABinaryChange() CreateBinaryFile(filepath); - repo.Index.Stage(filename); + repo.Stage(filename); var commit = repo.Commit("Add binary file", Constants.Signature, Constants.Signature); File.AppendAllText(filepath, "abcdef"); @@ -104,7 +104,7 @@ public void CanDetectABinaryChange() var patch = repo.Diff.Compare(commit.Tree, DiffTargets.WorkingDirectory, new[] { filename }); Assert.True(patch[filename].IsBinaryComparison); - repo.Index.Stage(filename); + repo.Stage(filename); var commit2 = repo.Commit("Update binary file", Constants.Signature, Constants.Signature); var patch2 = repo.Diff.Compare(commit.Tree, commit2.Tree, new[] { filename }); @@ -122,7 +122,7 @@ public void CanDetectABinaryDeletion() CreateBinaryFile(filepath); - repo.Index.Stage(filename); + repo.Stage(filename); var commit = repo.Commit("Add binary file", Constants.Signature, Constants.Signature); File.Delete(filepath); @@ -130,7 +130,7 @@ public void CanDetectABinaryDeletion() var patch = repo.Diff.Compare(commit.Tree, DiffTargets.WorkingDirectory, new [] {filename}); Assert.True(patch[filename].IsBinaryComparison); - repo.Index.Remove(filename); + repo.Remove(filename); var commit2 = repo.Commit("Delete binary file", Constants.Signature, Constants.Signature); var patch2 = repo.Diff.Compare(commit.Tree, commit2.Tree, new[] { filename }); @@ -282,11 +282,11 @@ public void DetectsTheExactRenamingOfFilesByDefault() Touch(repo.Info.WorkingDirectory, originalPath, "a\nb\nc\nd\n"); - repo.Index.Stage(originalPath); + repo.Stage(originalPath); Commit old = repo.Commit("Initial", Constants.Signature, Constants.Signature); - repo.Index.Move(originalPath, renamedPath); + repo.Move(originalPath, renamedPath); Commit @new = repo.Commit("Updated", Constants.Signature, Constants.Signature); @@ -317,14 +317,14 @@ public void RenameThresholdsAreObeyed() // 4 lines Touch(repo.Info.WorkingDirectory, originalPath, "a\nb\nc\nd\n"); - repo.Index.Stage(originalPath); + repo.Stage(originalPath); Commit old = repo.Commit("Initial", Constants.Signature, Constants.Signature); // 8 lines, 50% are from original file Touch(repo.Info.WorkingDirectory, originalPath, "a\nb\nc\nd\ne\nf\ng\nh\n"); - repo.Index.Stage(originalPath); - repo.Index.Move(originalPath, renamedPath); + repo.Stage(originalPath); + repo.Move(originalPath, renamedPath); Commit @new = repo.Commit("Updated", Constants.Signature, Constants.Signature); @@ -358,11 +358,11 @@ public void ExactModeDetectsExactRenames() Touch(repo.Info.WorkingDirectory, originalPath, "a\nb\nc\nd\n"); - repo.Index.Stage(originalPath); + repo.Stage(originalPath); Commit old = repo.Commit("Initial", Constants.Signature, Constants.Signature); - repo.Index.Move(originalPath, renamedPath); + repo.Move(originalPath, renamedPath); Commit @new = repo.Commit("Updated", Constants.Signature, Constants.Signature); @@ -392,11 +392,11 @@ public void ExactModeDetectsExactCopies() var copiedFullPath = Path.Combine(repo.Info.WorkingDirectory, copiedPath); Touch(repo.Info.WorkingDirectory, originalPath, "a\nb\nc\nd\n"); - repo.Index.Stage(originalPath); + repo.Stage(originalPath); Commit old = repo.Commit("Initial", Constants.Signature, Constants.Signature); File.Copy(originalFullPath, copiedFullPath); - repo.Index.Stage(copiedPath); + repo.Stage(copiedPath); Commit @new = repo.Commit("Updated", Constants.Signature, Constants.Signature); @@ -423,13 +423,13 @@ public void ExactModeDoesntDetectRenamesWithEdits() Touch(repo.Info.WorkingDirectory, originalPath, "a\nb\nc\nd\n"); - repo.Index.Stage(originalPath); + repo.Stage(originalPath); Commit old = repo.Commit("Initial", Constants.Signature, Constants.Signature); - repo.Index.Move(originalPath, renamedPath); + repo.Move(originalPath, renamedPath); File.AppendAllText(Path.Combine(repo.Info.WorkingDirectory, renamedPath), "e\nf\n"); - repo.Index.Stage(renamedPath); + repo.Stage(renamedPath); Commit @new = repo.Commit("Updated", Constants.Signature, Constants.Signature); @@ -460,12 +460,12 @@ public void CanIncludeUnmodifiedEntriesWhenDetectingTheExactRenamingOfFilesWhenE Touch(repo.Info.WorkingDirectory, originalPath, "a\nb\nc\nd\n"); - repo.Index.Stage(originalPath); + repo.Stage(originalPath); Commit old = repo.Commit("Initial", Constants.Signature, Constants.Signature); File.Copy(originalFullPath, copiedFullPath); - repo.Index.Stage(copiedPath); + repo.Stage(copiedPath); Commit @new = repo.Commit("Updated", Constants.Signature, Constants.Signature); @@ -497,11 +497,11 @@ public void CanNotDetectTheExactRenamingFilesWhenNotEnabled() Touch(repo.Info.WorkingDirectory, originalPath, "a\nb\nc\nd\n"); - repo.Index.Stage(originalPath); + repo.Stage(originalPath); Commit old = repo.Commit("Initial", Constants.Signature, Constants.Signature); - repo.Index.Move(originalPath, renamedPath); + repo.Move(originalPath, renamedPath); Commit @new = repo.Commit("Updated", Constants.Signature, Constants.Signature); @@ -531,12 +531,12 @@ public void CanDetectTheExactCopyingOfNonModifiedFilesWhenEnabled() Touch(repo.Info.WorkingDirectory, originalPath, "a\nb\nc\nd\n"); - repo.Index.Stage(originalPath); + repo.Stage(originalPath); Commit old = repo.Commit("Initial", Constants.Signature, Constants.Signature); File.Copy(originalFullPath, copiedFullPath); - repo.Index.Stage(copiedPath); + repo.Stage(copiedPath); Commit @new = repo.Commit("Updated", Constants.Signature, Constants.Signature); @@ -568,12 +568,12 @@ public void CanNotDetectTheExactCopyingOfNonModifiedFilesWhenNotEnabled() Touch(repo.Info.WorkingDirectory, originalPath, "a\nb\nc\nd\n"); - repo.Index.Stage(originalPath); + repo.Stage(originalPath); Commit old = repo.Commit("Initial", Constants.Signature, Constants.Signature); File.Copy(originalFullPath, copiedFullPath); - repo.Index.Stage(copiedPath); + repo.Stage(copiedPath); Commit @new = repo.Commit("Updated", Constants.Signature, Constants.Signature); @@ -598,15 +598,15 @@ public void CanDetectTheExactCopyingOfModifiedFilesWhenEnabled() Touch(repo.Info.WorkingDirectory, originalPath, "a\nb\nc\nd\n"); - repo.Index.Stage(originalPath); + repo.Stage(originalPath); Commit old = repo.Commit("Initial", Constants.Signature, Constants.Signature); File.Copy(originalFullPath, copiedFullPath); Touch(repo.Info.WorkingDirectory, originalPath, "e\n"); - repo.Index.Stage(originalPath); - repo.Index.Stage(copiedPath); + repo.Stage(originalPath); + repo.Stage(copiedPath); Commit @new = repo.Commit("Updated", Constants.Signature, Constants.Signature); @@ -638,15 +638,15 @@ public void CanNotDetectTheExactCopyingOfModifiedFilesWhenNotEnabled() Touch(repo.Info.WorkingDirectory, originalPath, "a\nb\nc\nd\n"); - repo.Index.Stage(originalPath); + repo.Stage(originalPath); Commit old = repo.Commit("Initial", Constants.Signature, Constants.Signature); File.Copy(originalFullPath, copiedFullPath); File.AppendAllText(originalFullPath, "e\n"); - repo.Index.Stage(originalPath); - repo.Index.Stage(copiedPath); + repo.Stage(originalPath); + repo.Stage(copiedPath); Commit @new = repo.Commit("Updated", Constants.Signature, Constants.Signature); @@ -667,11 +667,11 @@ public void CanIncludeUnmodifiedEntriesWhenEnabled() Touch(repo.Info.WorkingDirectory, "a.txt", "abc\ndef\n"); Touch(repo.Info.WorkingDirectory, "b.txt", "abc\ndef\n"); - repo.Index.Stage(new[] {"a.txt", "b.txt"}); + repo.Stage(new[] {"a.txt", "b.txt"}); Commit old = repo.Commit("Initial", Constants.Signature, Constants.Signature); File.AppendAllText(Path.Combine(repo.Info.WorkingDirectory, "b.txt"), "ghi\njkl\n"); - repo.Index.Stage("b.txt"); + repo.Stage("b.txt"); Commit @new = repo.Commit("Updated", Constants.Signature, Constants.Signature); var changes = repo.Diff.Compare(old.Tree, @new.Tree, @@ -701,9 +701,9 @@ public void CanDetectTheExactRenamingExactCopyingOfNonModifiedAndModifiedFilesWh Touch(repo.Info.WorkingDirectory, originalPath2, "1\n2\n3\n4\n"); Touch(repo.Info.WorkingDirectory, originalPath3, "5\n6\n7\n8\n"); - repo.Index.Stage(originalPath); - repo.Index.Stage(originalPath2); - repo.Index.Stage(originalPath3); + repo.Stage(originalPath); + repo.Stage(originalPath2); + repo.Stage(originalPath3); Commit old = repo.Commit("Initial", Constants.Signature, Constants.Signature); @@ -715,10 +715,10 @@ public void CanDetectTheExactRenamingExactCopyingOfNonModifiedAndModifiedFilesWh File.Copy(originalFullPath3, copiedFullPath2); File.AppendAllText(originalFullPath3, "9\n"); - repo.Index.Stage(originalPath3); - repo.Index.Stage(copiedPath1); - repo.Index.Stage(copiedPath2); - repo.Index.Move(originalPath, renamedPath); + repo.Stage(originalPath3); + repo.Stage(copiedPath1); + repo.Stage(copiedPath2); + repo.Move(originalPath, renamedPath); Commit @new = repo.Commit("Updated", Constants.Signature, Constants.Signature); diff --git a/LibGit2Sharp.Tests/DiffWorkdirToIndexFixture.cs b/LibGit2Sharp.Tests/DiffWorkdirToIndexFixture.cs index 2b7c528c4..fd0a34b44 100644 --- a/LibGit2Sharp.Tests/DiffWorkdirToIndexFixture.cs +++ b/LibGit2Sharp.Tests/DiffWorkdirToIndexFixture.cs @@ -47,7 +47,7 @@ public void CanCompareTheWorkDirAgainstTheIndexWithLaxUnmatchedExplicitPathsVali { using (var repo = new Repository(StandardTestRepoPath)) { - Assert.Equal(currentStatus, repo.Index.RetrieveStatus(relativePath)); + Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath)); var changes = repo.Diff.Compare(new[] { relativePath }, false, new ExplicitPathsOptions { ShouldFailOnUnmatchedPath = false }); Assert.Equal(0, changes.Count()); @@ -64,7 +64,7 @@ public void ComparingTheWorkDirAgainstTheIndexWithStrictUnmatchedExplicitPathsVa { using (var repo = new Repository(StandardTestRepoPath)) { - Assert.Equal(currentStatus, repo.Index.RetrieveStatus(relativePath)); + Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath)); Assert.Throws(() => repo.Diff.Compare(new[] { relativePath }, false, new ExplicitPathsOptions())); } @@ -79,7 +79,7 @@ public void CallbackForUnmatchedExplicitPathsIsCalledWhenSet(string relativePath using (var repo = new Repository(StandardTestRepoPath)) { - Assert.Equal(currentStatus, repo.Index.RetrieveStatus(relativePath)); + Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath)); repo.Diff.Compare(new[] { relativePath }, false, new ExplicitPathsOptions { diff --git a/LibGit2Sharp.Tests/IgnoreFixture.cs b/LibGit2Sharp.Tests/IgnoreFixture.cs index 0ad15a3f4..523a08c8b 100644 --- a/LibGit2Sharp.Tests/IgnoreFixture.cs +++ b/LibGit2Sharp.Tests/IgnoreFixture.cs @@ -16,15 +16,15 @@ public void TemporaryRulesShouldApplyUntilCleared() { Touch(repo.Info.WorkingDirectory, "Foo.cs", "Bar"); - Assert.True(repo.Index.RetrieveStatus().Untracked.Select(s => s.FilePath).Contains("Foo.cs")); + Assert.True(repo.RetrieveStatus().Untracked.Select(s => s.FilePath).Contains("Foo.cs")); repo.Ignore.AddTemporaryRules(new[] { "*.cs" }); - Assert.False(repo.Index.RetrieveStatus().Untracked.Select(s => s.FilePath).Contains("Foo.cs")); + Assert.False(repo.RetrieveStatus().Untracked.Select(s => s.FilePath).Contains("Foo.cs")); repo.Ignore.ResetAllTemporaryRules(); - Assert.True(repo.Index.RetrieveStatus().Untracked.Select(s => s.FilePath).Contains("Foo.cs")); + Assert.True(repo.RetrieveStatus().Untracked.Select(s => s.FilePath).Contains("Foo.cs")); } } diff --git a/LibGit2Sharp.Tests/IndexFixture.cs b/LibGit2Sharp.Tests/IndexFixture.cs index 3f5d5c41b..a1ec882a3 100644 --- a/LibGit2Sharp.Tests/IndexFixture.cs +++ b/LibGit2Sharp.Tests/IndexFixture.cs @@ -93,13 +93,13 @@ public void CanRenameAFile() const string oldName = "polite.txt"; - Assert.Equal(FileStatus.Nonexistent, repo.Index.RetrieveStatus(oldName)); + Assert.Equal(FileStatus.Nonexistent, repo.RetrieveStatus(oldName)); Touch(repo.Info.WorkingDirectory, oldName, "hello test file\n"); - Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus(oldName)); + Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus(oldName)); - repo.Index.Stage(oldName); - Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(oldName)); + repo.Stage(oldName); + Assert.Equal(FileStatus.Added, repo.RetrieveStatus(oldName)); // Generated through // $ echo "hello test file" | git hash-object --stdin @@ -111,13 +111,13 @@ public void CanRenameAFile() Signature who = Constants.Signature; repo.Commit("Initial commit", who, who); - Assert.Equal(FileStatus.Unaltered, repo.Index.RetrieveStatus(oldName)); + Assert.Equal(FileStatus.Unaltered, repo.RetrieveStatus(oldName)); const string newName = "being.frakking.polite.txt"; - repo.Index.Move(oldName, newName); - Assert.Equal(FileStatus.Removed, repo.Index.RetrieveStatus(oldName)); - Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(newName)); + repo.Move(oldName, newName); + Assert.Equal(FileStatus.Removed, repo.RetrieveStatus(oldName)); + Assert.Equal(FileStatus.Added, repo.RetrieveStatus(newName)); Assert.Equal(1, repo.Index.Count); Assert.Equal(expectedHash, repo.Index[newName].Id.Sha); @@ -125,8 +125,8 @@ public void CanRenameAFile() who = who.TimeShift(TimeSpan.FromMinutes(5)); Commit commit = repo.Commit("Fix file name", who, who); - Assert.Equal(FileStatus.Nonexistent, repo.Index.RetrieveStatus(oldName)); - Assert.Equal(FileStatus.Unaltered, repo.Index.RetrieveStatus(newName)); + Assert.Equal(FileStatus.Nonexistent, repo.RetrieveStatus(oldName)); + Assert.Equal(FileStatus.Unaltered, repo.RetrieveStatus(newName)); Assert.Equal(expectedHash, commit.Tree[newName].Target.Id.Sha); } @@ -142,13 +142,13 @@ public void CanMoveAnExistingFileOverANonExistingFile(string sourcePath, FileSta string path = CloneStandardTestRepo(); using (var repo = new Repository(path)) { - Assert.Equal(sourceStatus, repo.Index.RetrieveStatus(sourcePath)); - Assert.Equal(destStatus, repo.Index.RetrieveStatus(destPath)); + Assert.Equal(sourceStatus, repo.RetrieveStatus(sourcePath)); + Assert.Equal(destStatus, repo.RetrieveStatus(destPath)); - repo.Index.Move(sourcePath, destPath); + repo.Move(sourcePath, destPath); - Assert.Equal(sourcePostStatus, repo.Index.RetrieveStatus(sourcePath)); - Assert.Equal(destPostStatus, repo.Index.RetrieveStatus(destPath)); + Assert.Equal(sourcePostStatus, repo.RetrieveStatus(sourcePath)); + Assert.Equal(destPostStatus, repo.RetrieveStatus(destPath)); } } @@ -182,12 +182,12 @@ private static void InvalidMoveUseCases(string sourcePath, FileStatus sourceStat { using (var repo = new Repository(StandardTestRepoPath)) { - Assert.Equal(sourceStatus, repo.Index.RetrieveStatus(sourcePath)); + Assert.Equal(sourceStatus, repo.RetrieveStatus(sourcePath)); foreach (var destPath in destPaths) { string path = destPath; - Assert.Throws(() => repo.Index.Move(sourcePath, path)); + Assert.Throws(() => repo.Move(sourcePath, path)); } } } @@ -205,7 +205,7 @@ public void PathsOfIndexEntriesAreExpressedInNativeFormat() Touch(repo.Info.WorkingDirectory, relFilePath, "Anybody out there?"); // Stage the file - repo.Index.Stage(relFilePath); + repo.Stage(relFilePath); // Get the index Index index = repo.Index; @@ -241,7 +241,7 @@ public void StagingAFileWhenTheIndexIsLockedThrowsALockedFileException() Touch(repo.Info.Path, "index.lock"); Touch(repo.Info.WorkingDirectory, "newfile", "my my, this is gonna crash\n"); - Assert.Throws(() => repo.Index.Stage("newfile")); + Assert.Throws(() => repo.Stage("newfile")); } } @@ -258,22 +258,22 @@ public void CanCopeWithExternalChangesToTheIndex() using (var repoWrite = new Repository(path)) using (var repoRead = new Repository(path)) { - var writeStatus = repoWrite.Index.RetrieveStatus(); + var writeStatus = repoWrite.RetrieveStatus(); Assert.True(writeStatus.IsDirty); Assert.Equal(0, repoWrite.Index.Count); - var readStatus = repoRead.Index.RetrieveStatus(); + var readStatus = repoRead.RetrieveStatus(); Assert.True(readStatus.IsDirty); Assert.Equal(0, repoRead.Index.Count); - repoWrite.Index.Stage("*"); + repoWrite.Stage("*"); repoWrite.Commit("message", Constants.Signature, Constants.Signature); - writeStatus = repoWrite.Index.RetrieveStatus(); + writeStatus = repoWrite.RetrieveStatus(); Assert.False(writeStatus.IsDirty); Assert.Equal(2, repoWrite.Index.Count); - readStatus = repoRead.Index.RetrieveStatus(); + readStatus = repoRead.RetrieveStatus(); Assert.False(readStatus.IsDirty); Assert.Equal(2, repoRead.Index.Count); } @@ -293,20 +293,20 @@ public void CanResetFullyMergedIndexFromTree() const string headIndexTreeSha = "e5d221fc5da11a3169bf503d76497c81be3207b6"; Assert.True(repo.Index.IsFullyMerged); - Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(testFile)); + Assert.Equal(FileStatus.Added, repo.RetrieveStatus(testFile)); var headIndexTree = repo.Lookup(headIndexTreeSha); Assert.NotNull(headIndexTree); - repo.Index.Reset(headIndexTree); + repo.Index.Replace(headIndexTree); Assert.True(repo.Index.IsFullyMerged); - Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus(testFile)); + Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus(testFile)); } // Check that the index was persisted to disk. using (var repo = new Repository(path)) { - Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus(testFile)); + Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus(testFile)); } } @@ -324,20 +324,20 @@ public void CanResetIndexWithUnmergedEntriesFromTree() const string headIndexTreeSha = "1cb365141a52dfbb24933515820eb3045fbca12b"; Assert.False(repo.Index.IsFullyMerged); - Assert.Equal(FileStatus.Staged, repo.Index.RetrieveStatus(testFile)); + Assert.Equal(FileStatus.Staged, repo.RetrieveStatus(testFile)); var headIndexTree = repo.Lookup(headIndexTreeSha); Assert.NotNull(headIndexTree); - repo.Index.Reset(headIndexTree); + repo.Index.Replace(headIndexTree); Assert.True(repo.Index.IsFullyMerged); - Assert.Equal(FileStatus.Modified, repo.Index.RetrieveStatus(testFile)); + Assert.Equal(FileStatus.Modified, repo.RetrieveStatus(testFile)); } // Check that the index was persisted to disk. using (var repo = new Repository(path)) { - Assert.Equal(FileStatus.Modified, repo.Index.RetrieveStatus(testFile)); + Assert.Equal(FileStatus.Modified, repo.RetrieveStatus(testFile)); } } @@ -351,19 +351,19 @@ public void CanClearTheIndex() // to verify that the index has indeed been read from the tree. using (var repo = new Repository(path)) { - Assert.Equal(FileStatus.Unaltered, repo.Index.RetrieveStatus(testFile)); + Assert.Equal(FileStatus.Unaltered, repo.RetrieveStatus(testFile)); Assert.NotEqual(0, repo.Index.Count); repo.Index.Clear(); Assert.Equal(0, repo.Index.Count); - Assert.Equal(FileStatus.Removed | FileStatus.Untracked, repo.Index.RetrieveStatus(testFile)); + Assert.Equal(FileStatus.Removed | FileStatus.Untracked, repo.RetrieveStatus(testFile)); } // Check that the index was persisted to disk. using (var repo = new Repository(path)) { - Assert.Equal(FileStatus.Removed | FileStatus.Untracked, repo.Index.RetrieveStatus(testFile)); + Assert.Equal(FileStatus.Removed | FileStatus.Untracked, repo.RetrieveStatus(testFile)); } } } diff --git a/LibGit2Sharp.Tests/MergeFixture.cs b/LibGit2Sharp.Tests/MergeFixture.cs index 7801de718..428a6f677 100644 --- a/LibGit2Sharp.Tests/MergeFixture.cs +++ b/LibGit2Sharp.Tests/MergeFixture.cs @@ -202,7 +202,7 @@ public void CanFastForwardRepos(bool shouldMergeOccurInDetachedHeadState) Assert.Equal(repo.Branches["FirstBranch"].Tip, repo.Head.Tip); Assert.Equal(repo.Head.Tip, mergeResult.Commit); - Assert.Equal(0, repo.Index.RetrieveStatus().Count()); + Assert.Equal(0, repo.RetrieveStatus().Count()); Assert.Equal(shouldMergeOccurInDetachedHeadState, repo.Info.IsHeadDetached); if (!shouldMergeOccurInDetachedHeadState) @@ -314,7 +314,7 @@ public void CanFastForwardCommit(bool fromDetachedHead, FastForwardStrategy fast Assert.Equal(expectedMergeStatus, result.Status); Assert.Equal(expectedCommitId, result.Commit.Id.Sha); - Assert.False(repo.Index.RetrieveStatus().Any()); + Assert.False(repo.RetrieveStatus().Any()); Assert.Equal(fromDetachedHead, repo.Info.IsHeadDetached); } } @@ -339,7 +339,7 @@ public void CanNonFastForwardMergeCommit(bool fromDetachedHead, FastForwardStrat MergeResult result = repo.Merge(commitToMerge, Constants.Signature, new MergeOptions() { FastForwardStrategy = fastForwardStrategy }); Assert.Equal(expectedMergeStatus, result.Status); - Assert.False(repo.Index.RetrieveStatus().Any()); + Assert.False(repo.RetrieveStatus().Any()); Assert.Equal(fromDetachedHead, repo.Info.IsHeadDetached); } } @@ -497,11 +497,11 @@ public void CanMergeAndNotCommit() Assert.Equal(MergeStatus.NonFastForward, result.Status); Assert.Equal(null, result.Commit); - RepositoryStatus repoStatus = repo.Index.RetrieveStatus(); + RepositoryStatus repoStatus = repo.RetrieveStatus(); // Verify that there is a staged entry. Assert.Equal(1, repoStatus.Count()); - Assert.Equal(FileStatus.Staged, repo.Index.RetrieveStatus("b.txt")); + Assert.Equal(FileStatus.Staged, repo.RetrieveStatus("b.txt")); } } @@ -517,7 +517,7 @@ public void CanForceNonFastForwardMerge() Assert.Equal(MergeStatus.NonFastForward, result.Status); Assert.Equal("f58f780d5a0ae392efd4a924450b1bbdc0577d32", result.Commit.Id.Sha); - Assert.False(repo.Index.RetrieveStatus().Any()); + Assert.False(repo.RetrieveStatus().Any()); } } @@ -535,7 +535,7 @@ public void CanForceNonFastForwardMergeThroughConfig() Assert.Equal(MergeStatus.NonFastForward, result.Status); Assert.Equal("f58f780d5a0ae392efd4a924450b1bbdc0577d32", result.Commit.Id.Sha); - Assert.False(repo.Index.RetrieveStatus().Any()); + Assert.False(repo.RetrieveStatus().Any()); } } @@ -551,7 +551,7 @@ public void VerifyUpToDateMerge() Assert.Equal(MergeStatus.UpToDate, result.Status); Assert.Equal(null, result.Commit); - Assert.False(repo.Index.RetrieveStatus().Any()); + Assert.False(repo.RetrieveStatus().Any()); } } @@ -568,7 +568,7 @@ public void CanMergeCommittish(string committish, FastForwardStrategy strategy, MergeResult result = repo.Merge(committish, Constants.Signature, new MergeOptions() { FastForwardStrategy = strategy }); Assert.Equal(expectedMergeStatus, result.Status); - Assert.False(repo.Index.RetrieveStatus().Any()); + Assert.False(repo.RetrieveStatus().Any()); } } @@ -591,7 +591,7 @@ public void MergeWithWorkDirConflictsThrows(bool shouldStage, FastForwardStrateg if (shouldStage) { - repo.Index.Stage("b.txt"); + repo.Stage("b.txt"); } Assert.Throws(() => repo.Merge(committishToMerge, Constants.Signature, new MergeOptions() { FastForwardStrategy = strategy })); @@ -663,7 +663,7 @@ public void MergeCanSpecifyMergeFileFavorOption(MergeFileFavor fileFavorFlag) Branch branch = repo.Branches[conflictBranchName]; Assert.NotNull(branch); - var status = repo.Index.RetrieveStatus(); + var status = repo.RetrieveStatus(); MergeOptions mergeOptions = new MergeOptions() { MergeFileFavor = fileFavorFlag, @@ -675,7 +675,7 @@ public void MergeCanSpecifyMergeFileFavorOption(MergeFileFavor fileFavorFlag) // Verify that the index and working directory are clean Assert.True(repo.Index.IsFullyMerged); - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); // Get the blob containing the expected content. Blob expectedBlob = null; @@ -716,7 +716,7 @@ public void CanMergeBranch(string branchName, FastForwardStrategy strategy, Merg MergeResult result = repo.Merge(branch, Constants.Signature, new MergeOptions() { FastForwardStrategy = strategy }); Assert.Equal(expectedMergeStatus, result.Status); - Assert.False(repo.Index.RetrieveStatus().Any()); + Assert.False(repo.RetrieveStatus().Any()); } } @@ -729,20 +729,20 @@ public void CanMergeIntoOrphanedBranch() repo.Refs.Add("HEAD", "refs/heads/orphan", true); // Remove entries from the working directory - foreach(var entry in repo.Index.RetrieveStatus()) + foreach(var entry in repo.RetrieveStatus()) { - repo.Index.Unstage(entry.FilePath); - repo.Index.Remove(entry.FilePath, true); + repo.Unstage(entry.FilePath); + repo.Remove(entry.FilePath, true); } // Assert that we have an empty working directory. - Assert.False(repo.Index.RetrieveStatus().Any()); + Assert.False(repo.RetrieveStatus().Any()); MergeResult result = repo.Merge("master", Constants.Signature); Assert.Equal(MergeStatus.FastForward, result.Status); Assert.Equal(masterBranchInitialId, result.Commit.Id.Sha); - Assert.False(repo.Index.RetrieveStatus().Any()); + Assert.False(repo.RetrieveStatus().Any()); } } @@ -750,7 +750,7 @@ private Commit AddFileCommitToRepo(IRepository repository, string filename, stri { Touch(repository.Info.WorkingDirectory, filename, content); - repository.Index.Stage(filename); + repository.Stage(filename); return repository.Commit("New commit", Constants.Signature, Constants.Signature); } diff --git a/LibGit2Sharp.Tests/NetworkFixture.cs b/LibGit2Sharp.Tests/NetworkFixture.cs index d1d221de5..509190b94 100644 --- a/LibGit2Sharp.Tests/NetworkFixture.cs +++ b/LibGit2Sharp.Tests/NetworkFixture.cs @@ -144,7 +144,7 @@ public void CanPull(FastForwardStrategy fastForwardStrategy) { repo.Reset(ResetMode.Hard, "HEAD~1"); - Assert.False(repo.Index.RetrieveStatus().Any()); + Assert.False(repo.RetrieveStatus().Any()); Assert.Equal(repo.Lookup("refs/remotes/origin/master~1"), repo.Head.Tip); PullOptions pullOptions = new PullOptions() diff --git a/LibGit2Sharp.Tests/ObjectDatabaseFixture.cs b/LibGit2Sharp.Tests/ObjectDatabaseFixture.cs index 622891aa7..d0f6565cd 100644 --- a/LibGit2Sharp.Tests/ObjectDatabaseFixture.cs +++ b/LibGit2Sharp.Tests/ObjectDatabaseFixture.cs @@ -31,7 +31,7 @@ public void CanCreateABlobFromAFileInTheWorkingDirectory() string path = InitNewRepository(); using (var repo = new Repository(path)) { - Assert.Equal(FileStatus.Nonexistent, repo.Index.RetrieveStatus("hello.txt")); + Assert.Equal(FileStatus.Nonexistent, repo.RetrieveStatus("hello.txt")); File.AppendAllText(Path.Combine(repo.Info.WorkingDirectory, "hello.txt"), "I'm a new file\n"); @@ -40,7 +40,7 @@ public void CanCreateABlobFromAFileInTheWorkingDirectory() Assert.Equal("dc53d4c6b8684c21b0b57db29da4a2afea011565", blob.Sha); /* The file is unknown from the Index nor the Head ... */ - Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus("hello.txt")); + Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus("hello.txt")); /* ...however, it's indeed stored in the repository. */ var fetchedBlob = repo.Lookup(blob.Id); @@ -280,7 +280,7 @@ public void CanCreateATreeContainingABlobFromAFileInTheWorkingDirectory() string path = CloneStandardTestRepo(); using (var repo = new Repository(path)) { - Assert.Equal(FileStatus.Nonexistent, repo.Index.RetrieveStatus("hello.txt")); + Assert.Equal(FileStatus.Nonexistent, repo.RetrieveStatus("hello.txt")); File.AppendAllText(Path.Combine(repo.Info.WorkingDirectory, "hello.txt"), "I'm a new file\n"); TreeDefinition td = TreeDefinition.From(repo.Head.Tip.Tree) diff --git a/LibGit2Sharp.Tests/OdbBackendFixture.cs b/LibGit2Sharp.Tests/OdbBackendFixture.cs index c99442c9b..161dcb938 100644 --- a/LibGit2Sharp.Tests/OdbBackendFixture.cs +++ b/LibGit2Sharp.Tests/OdbBackendFixture.cs @@ -16,7 +16,7 @@ private static Commit AddCommitToRepo(IRepository repo) { string relativeFilepath = "test.txt"; Touch(repo.Info.WorkingDirectory, relativeFilepath, content); - repo.Index.Stage(relativeFilepath); + repo.Stage(relativeFilepath); var ie = repo.Index[relativeFilepath]; Assert.NotNull(ie); @@ -28,7 +28,7 @@ private static Commit AddCommitToRepo(IRepository repo) relativeFilepath = "big.txt"; var zeros = new string('0', 32*1024 + 3); Touch(repo.Info.WorkingDirectory, relativeFilepath, zeros); - repo.Index.Stage(relativeFilepath); + repo.Stage(relativeFilepath); ie = repo.Index[relativeFilepath]; Assert.NotNull(ie); diff --git a/LibGit2Sharp.Tests/PushFixture.cs b/LibGit2Sharp.Tests/PushFixture.cs index 9f2a9e106..d6b906ba6 100644 --- a/LibGit2Sharp.Tests/PushFixture.cs +++ b/LibGit2Sharp.Tests/PushFixture.cs @@ -35,7 +35,7 @@ private void AssertPush(Action push) // Change local state (commit) const string relativeFilepath = "new_file.txt"; Touch(clonedRepo.Info.WorkingDirectory, relativeFilepath, "__content__"); - clonedRepo.Index.Stage(relativeFilepath); + clonedRepo.Stage(relativeFilepath); clonedRepo.Commit("__commit_message__", Constants.Signature, Constants.Signature); // Assert local state has changed @@ -164,7 +164,7 @@ private Commit AddCommitToRepo(IRepository repository) Touch(repository.Info.WorkingDirectory, filename, random); - repository.Index.Stage(filename); + repository.Stage(filename); return repository.Commit("New commit", Constants.Signature, Constants.Signature); } diff --git a/LibGit2Sharp.Tests/ReflogFixture.cs b/LibGit2Sharp.Tests/ReflogFixture.cs index f8bc249d1..155ea5a73 100644 --- a/LibGit2Sharp.Tests/ReflogFixture.cs +++ b/LibGit2Sharp.Tests/ReflogFixture.cs @@ -63,7 +63,7 @@ public void CommitShouldCreateReflogEntryOnHeadAndOnTargetedDirectReference() const string relativeFilepath = "new.txt"; Touch(repo.Info.WorkingDirectory, relativeFilepath, "content\n"); - repo.Index.Stage(relativeFilepath); + repo.Stage(relativeFilepath); var author = Constants.Signature; const string commitMessage = "Hope reflog behaves as it should"; @@ -97,7 +97,7 @@ public void CommitOnUnbornReferenceShouldCreateReflogEntryWithInitialTag() { const string relativeFilepath = "new.txt"; Touch(repo.Info.WorkingDirectory, relativeFilepath, "content\n"); - repo.Index.Stage(relativeFilepath); + repo.Stage(relativeFilepath); var author = Constants.Signature; const string commitMessage = "First commit should be logged as initial"; @@ -124,7 +124,7 @@ public void CommitOnDetachedHeadShouldInsertReflogEntry() const string relativeFilepath = "new.txt"; Touch(repo.Info.WorkingDirectory, relativeFilepath, "content\n"); - repo.Index.Stage(relativeFilepath); + repo.Stage(relativeFilepath); var author = Constants.Signature; const string commitMessage = "Commit on detached head"; diff --git a/LibGit2Sharp.Tests/RemoveFixture.cs b/LibGit2Sharp.Tests/RemoveFixture.cs index 04d12feec..fb9f122e7 100644 --- a/LibGit2Sharp.Tests/RemoveFixture.cs +++ b/LibGit2Sharp.Tests/RemoveFixture.cs @@ -54,21 +54,21 @@ public void CanRemoveAnUnalteredFileFromTheIndexWithoutRemovingItFromTheWorkingD string fullpath = Path.Combine(repo.Info.WorkingDirectory, filename); - Assert.Equal(initialStatus, repo.Index.RetrieveStatus(filename)); + Assert.Equal(initialStatus, repo.RetrieveStatus(filename)); Assert.Equal(existsBeforeRemove, File.Exists(fullpath)); if (throws) { - Assert.Throws(() => repo.Index.Remove(filename, removeFromWorkdir)); + Assert.Throws(() => repo.Remove(filename, removeFromWorkdir)); Assert.Equal(count, repo.Index.Count); } else { - repo.Index.Remove(filename, removeFromWorkdir); + repo.Remove(filename, removeFromWorkdir); Assert.Equal(count - 1, repo.Index.Count); Assert.Equal(existsAfterRemove, File.Exists(fullpath)); - Assert.Equal(lastStatus, repo.Index.RetrieveStatus(filename)); + Assert.Equal(lastStatus, repo.RetrieveStatus(filename)); } } } @@ -91,10 +91,10 @@ public void RemovingAModifiedFileWhoseChangesHaveBeenPromotedToTheIndexAndWithAd Assert.Equal(true, File.Exists(fullpath)); File.AppendAllText(fullpath, "additional content"); - Assert.Equal(FileStatus.Staged | FileStatus.Modified, repo.Index.RetrieveStatus(filename)); + Assert.Equal(FileStatus.Staged | FileStatus.Modified, repo.RetrieveStatus(filename)); - Assert.Throws(() => repo.Index.Remove(filename)); - Assert.Throws(() => repo.Index.Remove(filename, false)); + Assert.Throws(() => repo.Remove(filename)); + Assert.Throws(() => repo.Remove(filename, false)); } } @@ -104,16 +104,16 @@ public void CanRemoveAFolderThroughUsageOfPathspecsForNewlyAddedFiles() string path = CloneStandardTestRepo(); using (var repo = new Repository(path)) { - repo.Index.Stage(Touch(repo.Info.WorkingDirectory, "2/subdir1/2.txt", "whone")); - repo.Index.Stage(Touch(repo.Info.WorkingDirectory, "2/subdir1/3.txt", "too")); - repo.Index.Stage(Touch(repo.Info.WorkingDirectory, "2/subdir2/4.txt", "tree")); - repo.Index.Stage(Touch(repo.Info.WorkingDirectory, "2/5.txt", "for")); - repo.Index.Stage(Touch(repo.Info.WorkingDirectory, "2/6.txt", "fyve")); + repo.Stage(Touch(repo.Info.WorkingDirectory, "2/subdir1/2.txt", "whone")); + repo.Stage(Touch(repo.Info.WorkingDirectory, "2/subdir1/3.txt", "too")); + repo.Stage(Touch(repo.Info.WorkingDirectory, "2/subdir2/4.txt", "tree")); + repo.Stage(Touch(repo.Info.WorkingDirectory, "2/5.txt", "for")); + repo.Stage(Touch(repo.Info.WorkingDirectory, "2/6.txt", "fyve")); int count = repo.Index.Count; Assert.True(Directory.Exists(Path.Combine(repo.Info.WorkingDirectory, "2"))); - repo.Index.Remove("2", false); + repo.Remove("2", false); Assert.Equal(count - 5, repo.Index.Count); } @@ -128,7 +128,7 @@ public void CanRemoveAFolderThroughUsageOfPathspecsForFilesAlreadyInTheIndexAndI int count = repo.Index.Count; Assert.True(Directory.Exists(Path.Combine(repo.Info.WorkingDirectory, "1"))); - repo.Index.Remove("1"); + repo.Remove("1"); Assert.False(Directory.Exists(Path.Combine(repo.Info.WorkingDirectory, "1"))); Assert.Equal(count - 1, repo.Index.Count); @@ -145,10 +145,10 @@ public void RemovingAnUnknownFileWithLaxExplicitPathsValidationDoesntThrow(strin using (var repo = new Repository(StandardTestRepoPath)) { Assert.Null(repo.Index[relativePath]); - Assert.Equal(status, repo.Index.RetrieveStatus(relativePath)); + Assert.Equal(status, repo.RetrieveStatus(relativePath)); - repo.Index.Remove(relativePath, i % 2 == 0); - repo.Index.Remove(relativePath, i % 2 == 0, + repo.Remove(relativePath, i % 2 == 0); + repo.Remove(relativePath, i % 2 == 0, new ExplicitPathsOptions {ShouldFailOnUnmatchedPath = false}); } } @@ -164,10 +164,10 @@ public void RemovingAnUnknownFileThrowsIfExplicitPath(string relativePath, FileS using (var repo = new Repository(StandardTestRepoPath)) { Assert.Null(repo.Index[relativePath]); - Assert.Equal(status, repo.Index.RetrieveStatus(relativePath)); + Assert.Equal(status, repo.RetrieveStatus(relativePath)); Assert.Throws( - () => repo.Index.Remove(relativePath, i%2 == 0, new ExplicitPathsOptions())); + () => repo.Remove(relativePath, i%2 == 0, new ExplicitPathsOptions())); } } } @@ -177,10 +177,10 @@ public void RemovingFileWithBadParamsThrows() { using (var repo = new Repository(StandardTestRepoPath)) { - Assert.Throws(() => repo.Index.Remove(string.Empty)); - Assert.Throws(() => repo.Index.Remove((string)null)); - Assert.Throws(() => repo.Index.Remove(new string[] { })); - Assert.Throws(() => repo.Index.Remove(new string[] { null })); + Assert.Throws(() => repo.Remove(string.Empty)); + Assert.Throws(() => repo.Remove((string)null)); + Assert.Throws(() => repo.Remove(new string[] { })); + Assert.Throws(() => repo.Remove(new string[] { null })); } } } diff --git a/LibGit2Sharp.Tests/RepositoryFixture.cs b/LibGit2Sharp.Tests/RepositoryFixture.cs index 62ca9e1b5..c74804ffd 100644 --- a/LibGit2Sharp.Tests/RepositoryFixture.cs +++ b/LibGit2Sharp.Tests/RepositoryFixture.cs @@ -409,7 +409,7 @@ public void CanLookupWhithShortIdentifers() { const string filename = "new.txt"; Touch(repo.Info.WorkingDirectory, filename, "one "); - repo.Index.Stage(filename); + repo.Stage(filename); Signature author = Constants.Signature; Commit commit = repo.Commit("Initial commit", author, author); diff --git a/LibGit2Sharp.Tests/RepositoryOptionsFixture.cs b/LibGit2Sharp.Tests/RepositoryOptionsFixture.cs index 946d4a31a..e8177a292 100644 --- a/LibGit2Sharp.Tests/RepositoryOptionsFixture.cs +++ b/LibGit2Sharp.Tests/RepositoryOptionsFixture.cs @@ -33,7 +33,7 @@ public void CanOpenABareRepoAsIfItWasAStandardOne() using (var repo = new Repository(BareTestRepoPath, options)) { - var st = repo.Index.RetrieveStatus("1/branch_file.txt"); + var st = repo.RetrieveStatus("1/branch_file.txt"); Assert.Equal(FileStatus.Missing, st); } } @@ -45,7 +45,7 @@ public void CanOpenABareRepoAsIfItWasAStandardOneWithANonExisitingIndexFile() using (var repo = new Repository(BareTestRepoPath, options)) { - var st = repo.Index.RetrieveStatus("1/branch_file.txt"); + var st = repo.RetrieveStatus("1/branch_file.txt"); Assert.Equal(FileStatus.Removed, st); } } @@ -56,7 +56,7 @@ public void CanProvideADifferentWorkDirToAStandardRepo() var path1 = CloneStandardTestRepo(); using (var repo = new Repository(path1)) { - Assert.Equal(FileStatus.Unaltered, repo.Index.RetrieveStatus("1/branch_file.txt")); + Assert.Equal(FileStatus.Unaltered, repo.RetrieveStatus("1/branch_file.txt")); } var options = new RepositoryOptions { WorkingDirectoryPath = newWorkdir }; @@ -64,7 +64,7 @@ public void CanProvideADifferentWorkDirToAStandardRepo() var path2 = CloneStandardTestRepo(); using (var repo = new Repository(path2, options)) { - Assert.Equal(FileStatus.Missing, repo.Index.RetrieveStatus("1/branch_file.txt")); + Assert.Equal(FileStatus.Missing, repo.RetrieveStatus("1/branch_file.txt")); } } @@ -74,11 +74,11 @@ public void CanProvideADifferentIndexToAStandardRepo() var path1 = CloneStandardTestRepo(); using (var repo = new Repository(path1)) { - Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus("new_untracked_file.txt")); + Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus("new_untracked_file.txt")); - repo.Index.Stage("new_untracked_file.txt"); + repo.Stage("new_untracked_file.txt"); - Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus("new_untracked_file.txt")); + Assert.Equal(FileStatus.Added, repo.RetrieveStatus("new_untracked_file.txt")); File.Copy(Path.Combine(repo.Info.Path, "index"), newIndex); } @@ -88,7 +88,7 @@ public void CanProvideADifferentIndexToAStandardRepo() var path2 = CloneStandardTestRepo(); using (var repo = new Repository(path2, options)) { - Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus("new_untracked_file.txt")); + Assert.Equal(FileStatus.Added, repo.RetrieveStatus("new_untracked_file.txt")); } } @@ -107,7 +107,7 @@ public void CanSneakAdditionalCommitsIntoAStandardRepoWithoutAlteringTheWorkdirO { Branch head = repo.Head; - Assert.Equal(FileStatus.Nonexistent, repo.Index.RetrieveStatus("zomg.txt")); + Assert.Equal(FileStatus.Nonexistent, repo.RetrieveStatus("zomg.txt")); string commitSha = MeanwhileInAnotherDimensionAnEvilMastermindIsAtWork(path); @@ -116,7 +116,7 @@ public void CanSneakAdditionalCommitsIntoAStandardRepoWithoutAlteringTheWorkdirO Assert.NotEqual(head.Tip.Sha, newHead.Tip.Sha); Assert.Equal(commitSha, newHead.Tip.Sha); - Assert.Equal(FileStatus.Removed, repo.Index.RetrieveStatus("zomg.txt")); + Assert.Equal(FileStatus.Removed, repo.RetrieveStatus("zomg.txt")); } } @@ -133,7 +133,7 @@ private string MeanwhileInAnotherDimensionAnEvilMastermindIsAtWork(string workin const string filename = "zomg.txt"; Touch(sneakyRepo.Info.WorkingDirectory, filename, "I'm being sneaked in!\n"); - sneakyRepo.Index.Stage(filename); + sneakyRepo.Stage(filename); return sneakyRepo.Commit("Tadaaaa!", Constants.Signature, Constants.Signature).Sha; } } @@ -194,7 +194,7 @@ public void CanCommitOnBareRepository() { const string relativeFilepath = "test.txt"; Touch(repo.Info.WorkingDirectory, relativeFilepath, "test\n"); - repo.Index.Stage(relativeFilepath); + repo.Stage(relativeFilepath); Assert.NotNull(repo.Commit("Initial commit", Constants.Signature, Constants.Signature)); Assert.Equal(1, repo.Head.Commits.Count()); diff --git a/LibGit2Sharp.Tests/ResetHeadFixture.cs b/LibGit2Sharp.Tests/ResetHeadFixture.cs index 870e46c39..ed76df8f0 100644 --- a/LibGit2Sharp.Tests/ResetHeadFixture.cs +++ b/LibGit2Sharp.Tests/ResetHeadFixture.cs @@ -114,7 +114,7 @@ private void AssertSoftReset(Func branchIdentifierRetriever, boo Assert.Equal(expectedHeadName, repo.Head.Name); Assert.Equal(tag.Target.Id, repo.Head.Tip.Id); - Assert.Equal(FileStatus.Staged, repo.Index.RetrieveStatus("a.txt")); + Assert.Equal(FileStatus.Staged, repo.RetrieveStatus("a.txt")); AssertRefLogEntry(repo, "HEAD", tag.Target.Id, @@ -134,7 +134,7 @@ private void AssertSoftReset(Func branchIdentifierRetriever, boo Assert.Equal(expectedHeadName, repo.Head.Name); Assert.Equal(branch.Tip.Sha, repo.Head.Tip.Sha); - Assert.Equal(FileStatus.Unaltered, repo.Index.RetrieveStatus("a.txt")); + Assert.Equal(FileStatus.Unaltered, repo.RetrieveStatus("a.txt")); AssertRefLogEntry(repo, "HEAD", branch.Tip.Id, @@ -156,12 +156,12 @@ private void AssertSoftReset(Func branchIdentifierRetriever, boo private static void FeedTheRepository(IRepository repo) { string fullPath = Touch(repo.Info.WorkingDirectory, "a.txt", "Hello\n"); - repo.Index.Stage(fullPath); + repo.Stage(fullPath); repo.Commit("Initial commit", Constants.Signature, Constants.Signature); repo.ApplyTag("mytag"); File.AppendAllText(fullPath, "World\n"); - repo.Index.Stage(fullPath); + repo.Stage(fullPath); Signature shiftedSignature = Constants.Signature.TimeShift(TimeSpan.FromMinutes(1)); repo.Commit("Update file", shiftedSignature, shiftedSignature); @@ -169,7 +169,7 @@ private static void FeedTheRepository(IRepository repo) repo.Checkout("mybranch"); - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); } [Fact] @@ -187,7 +187,7 @@ public void MixedResetRefreshesTheIndex() repo.Reset(ResetMode.Mixed, tag.CanonicalName); - Assert.Equal(FileStatus.Modified, repo.Index.RetrieveStatus("a.txt")); + Assert.Equal(FileStatus.Modified, repo.RetrieveStatus("a.txt")); AssertRefLogEntry(repo, "HEAD", tag.Target.Id, diff --git a/LibGit2Sharp.Tests/ResetIndexFixture.cs b/LibGit2Sharp.Tests/ResetIndexFixture.cs index 9cc7849ac..ebfdd20f5 100644 --- a/LibGit2Sharp.Tests/ResetIndexFixture.cs +++ b/LibGit2Sharp.Tests/ResetIndexFixture.cs @@ -64,14 +64,14 @@ public void ResetTheIndexWithTheHeadUnstagesEverything() string path = CloneStandardTestRepo(); using (var repo = new Repository(path)) { - RepositoryStatus oldStatus = repo.Index.RetrieveStatus(); + RepositoryStatus oldStatus = repo.RetrieveStatus(); Assert.Equal(3, oldStatus.Where(IsStaged).Count()); var reflogEntriesCount = repo.Refs.Log(repo.Refs.Head).Count(); repo.Reset(); - RepositoryStatus newStatus = repo.Index.RetrieveStatus(); + RepositoryStatus newStatus = repo.RetrieveStatus(); Assert.Equal(0, newStatus.Where(IsStaged).Count()); // Assert that no reflog entry is created @@ -87,7 +87,7 @@ public void CanResetTheIndexToTheContentOfACommitWithCommittishAsArgument() { repo.Reset("be3563a"); - RepositoryStatus newStatus = repo.Index.RetrieveStatus(); + RepositoryStatus newStatus = repo.RetrieveStatus(); var expected = new[] { "1.txt", Path.Combine("1", "branch_file.txt"), "deleted_staged_file.txt", "deleted_unstaged_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt" }; @@ -105,7 +105,7 @@ public void CanResetTheIndexToTheContentOfACommitWithCommitAsArgument() { repo.Reset(repo.Lookup("be3563a")); - RepositoryStatus newStatus = repo.Index.RetrieveStatus(); + RepositoryStatus newStatus = repo.RetrieveStatus(); var expected = new[] { "1.txt", Path.Combine("1", "branch_file.txt"), "deleted_staged_file.txt", "deleted_unstaged_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt" }; @@ -157,10 +157,10 @@ public void CanResetTheIndexWhenARenameExists() { using (var repo = new Repository(CloneStandardTestRepo())) { - repo.Index.Move("branch_file.txt", "renamed_branch_file.txt"); + repo.Move("branch_file.txt", "renamed_branch_file.txt"); repo.Reset(repo.Lookup("32eab9c")); - RepositoryStatus status = repo.Index.RetrieveStatus(); + RepositoryStatus status = repo.RetrieveStatus(); Assert.Equal(0, status.Where(IsStaged).Count()); } } @@ -170,16 +170,16 @@ public void CanResetSourceOfARenameInIndex() { using (var repo = new Repository(CloneStandardTestRepo())) { - repo.Index.Move("branch_file.txt", "renamed_branch_file.txt"); + repo.Move("branch_file.txt", "renamed_branch_file.txt"); - RepositoryStatus oldStatus = repo.Index.RetrieveStatus(); + RepositoryStatus oldStatus = repo.RetrieveStatus(); Assert.Equal(1, oldStatus.RenamedInIndex.Count()); Assert.Equal(FileStatus.Nonexistent, oldStatus["branch_file.txt"].State); Assert.Equal(FileStatus.RenamedInIndex, oldStatus["renamed_branch_file.txt"].State); repo.Reset(repo.Lookup("32eab9c"), new string[] { "branch_file.txt" }); - RepositoryStatus newStatus = repo.Index.RetrieveStatus(); + RepositoryStatus newStatus = repo.RetrieveStatus(); Assert.Equal(0, newStatus.RenamedInIndex.Count()); Assert.Equal(FileStatus.Missing, newStatus["branch_file.txt"].State); Assert.Equal(FileStatus.Added, newStatus["renamed_branch_file.txt"].State); @@ -191,15 +191,15 @@ public void CanResetTargetOfARenameInIndex() { using (var repo = new Repository(CloneStandardTestRepo())) { - repo.Index.Move("branch_file.txt", "renamed_branch_file.txt"); + repo.Move("branch_file.txt", "renamed_branch_file.txt"); - RepositoryStatus oldStatus = repo.Index.RetrieveStatus(); + RepositoryStatus oldStatus = repo.RetrieveStatus(); Assert.Equal(1, oldStatus.RenamedInIndex.Count()); Assert.Equal(FileStatus.RenamedInIndex, oldStatus["renamed_branch_file.txt"].State); repo.Reset(repo.Lookup("32eab9c"), new string[] { "renamed_branch_file.txt" }); - RepositoryStatus newStatus = repo.Index.RetrieveStatus(); + RepositoryStatus newStatus = repo.RetrieveStatus(); Assert.Equal(0, newStatus.RenamedInIndex.Count()); Assert.Equal(FileStatus.Untracked, newStatus["renamed_branch_file.txt"].State); Assert.Equal(FileStatus.Removed, newStatus["branch_file.txt"].State); diff --git a/LibGit2Sharp.Tests/RevertFixture.cs b/LibGit2Sharp.Tests/RevertFixture.cs index 13ab2c3a4..7f60431f9 100644 --- a/LibGit2Sharp.Tests/RevertFixture.cs +++ b/LibGit2Sharp.Tests/RevertFixture.cs @@ -37,7 +37,7 @@ public void CanRevert() // Verify workspace is clean. Assert.True(repo.Index.IsFullyMerged); - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); // Lookup the blob containing the expected reverted content of a.txt. Blob expectedBlob = repo.Lookup("bc90ea420cf6c5ae3db7dcdffa0d79df567f219b"); @@ -82,7 +82,7 @@ public void CanRevertAndNotCommit() Assert.Null(result.Commit); // Verify workspace is dirty. - FileStatus fileStatus = repo.Index.RetrieveStatus(revertedFile); + FileStatus fileStatus = repo.RetrieveStatus(revertedFile); Assert.Equal(FileStatus.Staged, fileStatus); // This is the ID of the blob containing the expected content. @@ -131,8 +131,8 @@ public void RevertWithConflictDoesNotCommit() Assert.NotNull(repo.Index.Conflicts["a.txt"]); // Verify the non-conflicting paths are staged. - Assert.Equal(FileStatus.Staged, repo.Index.RetrieveStatus("b.txt")); - Assert.Equal(FileStatus.Staged, repo.Index.RetrieveStatus("c.txt")); + Assert.Equal(FileStatus.Staged, repo.RetrieveStatus("b.txt")); + Assert.Equal(FileStatus.Staged, repo.RetrieveStatus("c.txt")); } } @@ -344,7 +344,7 @@ public void CanRevertMergeCommit(int mainline, string expectedId) { // In this case, we expect "d_renamed.txt" to be reverted (deleted), // and a.txt to match the tip of the "revert" branch. - Assert.Equal(FileStatus.Nonexistent, repo.Index.RetrieveStatus("d_renamed.txt")); + Assert.Equal(FileStatus.Nonexistent, repo.RetrieveStatus("d_renamed.txt")); // This is the commit containing the expected contents of a.txt. Commit commit = repo.Lookup("b6fbb29b625aabe0fb5736da6fd61d4147e4405e"); @@ -358,7 +358,7 @@ public void CanRevertMergeCommit(int mainline, string expectedId) // In this case, we expect "d_renamed.txt" to be reverted (deleted), // and a.txt to match the tip of the "revert" branch. - Assert.Equal(FileStatus.Unaltered, repo.Index.RetrieveStatus("d_renamed.txt")); + Assert.Equal(FileStatus.Unaltered, repo.RetrieveStatus("d_renamed.txt")); // This is the commit containing the expected contents of "d_renamed.txt". Commit commit = repo.Lookup("c4b5cea70e4cd5b633ed0f10ae0ed5384e8190d8"); diff --git a/LibGit2Sharp.Tests/StageFixture.cs b/LibGit2Sharp.Tests/StageFixture.cs index 3355645f0..a6173719e 100644 --- a/LibGit2Sharp.Tests/StageFixture.cs +++ b/LibGit2Sharp.Tests/StageFixture.cs @@ -23,13 +23,13 @@ public void CanStage(string relativePath, FileStatus currentStatus, bool doesCur { int count = repo.Index.Count; Assert.Equal(doesCurrentlyExistInTheIndex, (repo.Index[relativePath] != null)); - Assert.Equal(currentStatus, repo.Index.RetrieveStatus(relativePath)); + Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath)); - repo.Index.Stage(relativePath); + repo.Stage(relativePath); Assert.Equal(count + expectedIndexCountVariation, repo.Index.Count); Assert.Equal(doesExistInTheIndexOnceStaged, (repo.Index[relativePath] != null)); - Assert.Equal(expectedStatusOnceStaged, repo.Index.RetrieveStatus(relativePath)); + Assert.Equal(expectedStatusOnceStaged, repo.RetrieveStatus(relativePath)); } } @@ -43,17 +43,17 @@ public void CanStageTheUpdationOfAStagedFile() const string filename = "new_tracked_file.txt"; IndexEntry blob = repo.Index[filename]; - Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(filename)); + Assert.Equal(FileStatus.Added, repo.RetrieveStatus(filename)); Touch(repo.Info.WorkingDirectory, filename, "brand new content"); - Assert.Equal(FileStatus.Added | FileStatus.Modified, repo.Index.RetrieveStatus(filename)); + Assert.Equal(FileStatus.Added | FileStatus.Modified, repo.RetrieveStatus(filename)); - repo.Index.Stage(filename); + repo.Stage(filename); IndexEntry newBlob = repo.Index[filename]; Assert.Equal(count, repo.Index.Count); Assert.NotEqual(newBlob.Id, blob.Id); - Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(filename)); + Assert.Equal(FileStatus.Added, repo.RetrieveStatus(filename)); } } @@ -65,9 +65,9 @@ public void StagingAnUnknownFileThrowsIfExplicitPath(string relativePath, FileSt using (var repo = new Repository(StandardTestRepoPath)) { Assert.Null(repo.Index[relativePath]); - Assert.Equal(status, repo.Index.RetrieveStatus(relativePath)); + Assert.Equal(status, repo.RetrieveStatus(relativePath)); - Assert.Throws(() => repo.Index.Stage(relativePath, new StageOptions { ExplicitPathsOptions = new ExplicitPathsOptions() })); + Assert.Throws(() => repo.Stage(relativePath, new StageOptions { ExplicitPathsOptions = new ExplicitPathsOptions() })); } } @@ -79,12 +79,12 @@ public void CanStageAnUnknownFileWithLaxUnmatchedExplicitPathsValidation(string using (var repo = new Repository(StandardTestRepoPath)) { Assert.Null(repo.Index[relativePath]); - Assert.Equal(status, repo.Index.RetrieveStatus(relativePath)); + Assert.Equal(status, repo.RetrieveStatus(relativePath)); - Assert.DoesNotThrow(() => repo.Index.Stage(relativePath)); - Assert.DoesNotThrow(() => repo.Index.Stage(relativePath, new StageOptions { ExplicitPathsOptions = new ExplicitPathsOptions { ShouldFailOnUnmatchedPath = false } })); + Assert.DoesNotThrow(() => repo.Stage(relativePath)); + Assert.DoesNotThrow(() => repo.Stage(relativePath, new StageOptions { ExplicitPathsOptions = new ExplicitPathsOptions { ShouldFailOnUnmatchedPath = false } })); - Assert.Equal(status, repo.Index.RetrieveStatus(relativePath)); + Assert.Equal(status, repo.RetrieveStatus(relativePath)); } } @@ -96,10 +96,10 @@ public void StagingAnUnknownFileWithLaxExplicitPathsValidationDoesntThrow(string using (var repo = new Repository(StandardTestRepoPath)) { Assert.Null(repo.Index[relativePath]); - Assert.Equal(status, repo.Index.RetrieveStatus(relativePath)); + Assert.Equal(status, repo.RetrieveStatus(relativePath)); - repo.Index.Stage(relativePath); - repo.Index.Stage(relativePath, new StageOptions { ExplicitPathsOptions = new ExplicitPathsOptions { ShouldFailOnUnmatchedPath = false } }); + repo.Stage(relativePath); + repo.Stage(relativePath, new StageOptions { ExplicitPathsOptions = new ExplicitPathsOptions { ShouldFailOnUnmatchedPath = false } }); } } @@ -113,16 +113,16 @@ public void CanStageTheRemovalOfAStagedFile() const string filename = "new_tracked_file.txt"; Assert.NotNull(repo.Index[filename]); - Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(filename)); + Assert.Equal(FileStatus.Added, repo.RetrieveStatus(filename)); File.Delete(Path.Combine(repo.Info.WorkingDirectory, filename)); - Assert.Equal(FileStatus.Added | FileStatus.Missing, repo.Index.RetrieveStatus(filename)); + Assert.Equal(FileStatus.Added | FileStatus.Missing, repo.RetrieveStatus(filename)); - repo.Index.Stage(filename); + repo.Stage(filename); Assert.Null(repo.Index[filename]); Assert.Equal(count - 1, repo.Index.Count); - Assert.Equal(FileStatus.Nonexistent, repo.Index.RetrieveStatus(filename)); + Assert.Equal(FileStatus.Nonexistent, repo.RetrieveStatus(filename)); } } @@ -135,22 +135,22 @@ public void CanStageANewFileInAPersistentManner(string filename) string path = CloneStandardTestRepo(); using (var repo = new Repository(path)) { - Assert.Equal(FileStatus.Nonexistent, repo.Index.RetrieveStatus(filename)); + Assert.Equal(FileStatus.Nonexistent, repo.RetrieveStatus(filename)); Assert.Null(repo.Index[filename]); Touch(repo.Info.WorkingDirectory, filename, "some contents"); - Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus(filename)); + Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus(filename)); Assert.Null(repo.Index[filename]); - repo.Index.Stage(filename); + repo.Stage(filename); Assert.NotNull(repo.Index[filename]); - Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(filename)); + Assert.Equal(FileStatus.Added, repo.RetrieveStatus(filename)); } using (var repo = new Repository(path)) { Assert.NotNull(repo.Index[filename]); - Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(filename)); + Assert.Equal(FileStatus.Added, repo.RetrieveStatus(filename)); } } @@ -190,10 +190,10 @@ private static void AssertStage(bool? ignorecase, IRepository repo, string path) { try { - repo.Index.Stage(path); - Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(path)); + repo.Stage(path); + Assert.Equal(FileStatus.Added, repo.RetrieveStatus(path)); repo.Reset(); - Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus(path)); + Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus(path)); } catch (ArgumentException) { @@ -213,7 +213,7 @@ public void CanStageANewFileWithARelativePathContainingNativeDirectorySeparatorC Touch(repo.Info.WorkingDirectory, file, "With backward slash on Windows!"); - repo.Index.Stage(file); + repo.Stage(file); Assert.Equal(count + 1, repo.Index.Count); @@ -232,7 +232,7 @@ public void StagingANewFileWithAFullPathWhichEscapesOutOfTheWorkingDirThrows() { string fullPath = Touch(scd.RootedDirectoryPath, "unit_test.txt", "some contents"); - Assert.Throws(() => repo.Index.Stage(fullPath)); + Assert.Throws(() => repo.Stage(fullPath)); } } @@ -241,10 +241,10 @@ public void StagingFileWithBadParamsThrows() { using (var repo = new Repository(StandardTestRepoPath)) { - Assert.Throws(() => repo.Index.Stage(string.Empty)); - Assert.Throws(() => repo.Index.Stage((string)null)); - Assert.Throws(() => repo.Index.Stage(new string[] { })); - Assert.Throws(() => repo.Index.Stage(new string[] { null })); + Assert.Throws(() => repo.Stage(string.Empty)); + Assert.Throws(() => repo.Stage((string)null)); + Assert.Throws(() => repo.Stage(new string[] { })); + Assert.Throws(() => repo.Stage(new string[] { null })); } } @@ -280,7 +280,7 @@ public void CanStageWithPathspec(string relativePath, int expectedIndexCountVari { int count = repo.Index.Count; - repo.Index.Stage(relativePath); + repo.Stage(relativePath); Assert.Equal(count + expectedIndexCountVariation, repo.Index.Count); } @@ -293,7 +293,7 @@ public void CanStageWithMultiplePathspecs() { int count = repo.Index.Count; - repo.Index.Stage(new string[] { "*", "u*" }); + repo.Stage(new string[] { "*", "u*" }); Assert.Equal(count, repo.Index.Count); // 1 added file, 1 deleted file, so same count } @@ -309,9 +309,9 @@ public void CanIgnoreIgnoredPaths(string path) Touch(repo.Info.WorkingDirectory, ".gitignore", "ignored_file.txt\nignored_folder/\n"); Touch(repo.Info.WorkingDirectory, path, "This file is ignored."); - Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus(path)); - repo.Index.Stage("*"); - Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus(path)); + Assert.Equal(FileStatus.Ignored, repo.RetrieveStatus(path)); + repo.Stage("*"); + Assert.Equal(FileStatus.Ignored, repo.RetrieveStatus(path)); } } @@ -325,9 +325,9 @@ public void CanStageIgnoredPaths(string path) Touch(repo.Info.WorkingDirectory, ".gitignore", "ignored_file.txt\nignored_folder/\n"); Touch(repo.Info.WorkingDirectory, path, "This file is ignored."); - Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus(path)); - repo.Index.Stage(path, new StageOptions { IncludeIgnored = true }); - Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(path)); + Assert.Equal(FileStatus.Ignored, repo.RetrieveStatus(path)); + repo.Stage(path, new StageOptions { IncludeIgnored = true }); + Assert.Equal(FileStatus.Added, repo.RetrieveStatus(path)); } } } diff --git a/LibGit2Sharp.Tests/StashFixture.cs b/LibGit2Sharp.Tests/StashFixture.cs index 2bdf4e33c..14fc38449 100644 --- a/LibGit2Sharp.Tests/StashFixture.cs +++ b/LibGit2Sharp.Tests/StashFixture.cs @@ -29,7 +29,7 @@ public void CanAddAndRemoveStash() { var stasher = Constants.Signature; - Assert.True(repo.Index.RetrieveStatus().IsDirty); + Assert.True(repo.RetrieveStatus().IsDirty); Stash stash = repo.Stashes.Add(stasher, "My very first stash", StashModifiers.IncludeUntracked); @@ -45,7 +45,7 @@ public void CanAddAndRemoveStash() var stashRef = repo.Refs["refs/stash"]; Assert.Equal(stash.WorkTree.Sha, stashRef.TargetIdentifier); - Assert.False(repo.Index.RetrieveStatus().IsDirty); + Assert.False(repo.RetrieveStatus().IsDirty); // Create extra file untrackedFilename = "stash_candidate.txt"; @@ -139,18 +139,18 @@ public void CanStashWithoutOptions() const string staged = "staged_file_path.txt"; Touch(repo.Info.WorkingDirectory, staged, "I'm staged\n"); - repo.Index.Stage(staged); + repo.Stage(staged); Stash stash = repo.Stashes.Add(stasher, "Stash with default options", StashModifiers.Default); Assert.NotNull(stash); //It should not keep staged files - Assert.Equal(FileStatus.Nonexistent, repo.Index.RetrieveStatus(staged)); + Assert.Equal(FileStatus.Nonexistent, repo.RetrieveStatus(staged)); Assert.NotNull(stash.Index[staged]); //It should leave untracked files untracked - Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus(untracked)); + Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus(untracked)); Assert.Null(stash.Untracked); } } @@ -165,13 +165,13 @@ public void CanStashAndKeepIndex() const string filename = "staged_file_path.txt"; Touch(repo.Info.WorkingDirectory, filename, "I'm staged\n"); - repo.Index.Stage(filename); + repo.Stage(filename); Stash stash = repo.Stashes.Add(stasher, "This stash will keep index", StashModifiers.KeepIndex); Assert.NotNull(stash); Assert.NotNull(stash.Index[filename]); - Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(filename)); + Assert.Equal(FileStatus.Added, repo.RetrieveStatus(filename)); Assert.Null(stash.Untracked); } } @@ -186,7 +186,7 @@ public void CanStashIgnoredFiles() const string ignoredFilename = "ignored_file.txt"; Touch(repo.Info.WorkingDirectory, gitIgnore, ignoredFilename); - repo.Index.Stage(gitIgnore); + repo.Stage(gitIgnore); repo.Commit("Modify gitignore", Constants.Signature, Constants.Signature); Touch(repo.Info.WorkingDirectory, ignoredFilename, "I'm ignored\n"); diff --git a/LibGit2Sharp.Tests/StatusFixture.cs b/LibGit2Sharp.Tests/StatusFixture.cs index b70ff0ae0..a7086d857 100644 --- a/LibGit2Sharp.Tests/StatusFixture.cs +++ b/LibGit2Sharp.Tests/StatusFixture.cs @@ -15,7 +15,7 @@ public void CanRetrieveTheStatusOfAFile() { using (var repo = new Repository(StandardTestRepoPath)) { - FileStatus status = repo.Index.RetrieveStatus("new_tracked_file.txt"); + FileStatus status = repo.RetrieveStatus("new_tracked_file.txt"); Assert.Equal(FileStatus.Added, status); } } @@ -32,7 +32,7 @@ public void CanLimitStatusToWorkDirOnly(StatusShowOption show, FileStatus expect { Touch(repo.Info.WorkingDirectory, "file.txt", "content"); - RepositoryStatus status = repo.Index.RetrieveStatus(new StatusOptions() { Show = show }); + RepositoryStatus status = repo.RetrieveStatus(new StatusOptions() { Show = show }); Assert.Equal(expected, status["file.txt"].State); } } @@ -48,9 +48,9 @@ public void CanLimitStatusToIndexOnly(StatusShowOption show, FileStatus expected using (var repo = new Repository(clone)) { Touch(repo.Info.WorkingDirectory, "file.txt", "content"); - repo.Index.Stage("file.txt"); + repo.Stage("file.txt"); - RepositoryStatus status = repo.Index.RetrieveStatus(new StatusOptions() { Show = show }); + RepositoryStatus status = repo.RetrieveStatus(new StatusOptions() { Show = show }); Assert.Equal(expected, status["file.txt"].State); } } @@ -87,7 +87,7 @@ public void CanRetrieveTheStatusOfAnUntrackedFile(string filePath) { Touch(repo.Info.WorkingDirectory, filePath, "content"); - FileStatus status = repo.Index.RetrieveStatus(filePath); + FileStatus status = repo.RetrieveStatus(filePath); Assert.Equal(FileStatus.Untracked, status); } } @@ -97,7 +97,7 @@ public void RetrievingTheStatusOfADirectoryThrows() { using (var repo = new Repository(StandardTestRepoPath)) { - Assert.Throws(() => { FileStatus status = repo.Index.RetrieveStatus("1"); }); + Assert.Throws(() => { FileStatus status = repo.RetrieveStatus("1"); }); } } @@ -109,7 +109,7 @@ public void CanRetrieveTheStatusOfTheWholeWorkingDirectory() { const string file = "modified_staged_file.txt"; - RepositoryStatus status = repo.Index.RetrieveStatus(); + RepositoryStatus status = repo.RetrieveStatus(); Assert.Equal(FileStatus.Staged, status[file].State); @@ -127,9 +127,9 @@ public void CanRetrieveTheStatusOfTheWholeWorkingDirectory() File.AppendAllText(Path.Combine(repo.Info.WorkingDirectory, file), "Tclem's favorite commit message: boom"); - Assert.Equal(FileStatus.Staged | FileStatus.Modified, repo.Index.RetrieveStatus(file)); + Assert.Equal(FileStatus.Staged | FileStatus.Modified, repo.RetrieveStatus(file)); - RepositoryStatus status2 = repo.Index.RetrieveStatus(); + RepositoryStatus status2 = repo.RetrieveStatus(); Assert.Equal(FileStatus.Staged | FileStatus.Modified, status2[file].State); Assert.NotNull(status2); @@ -157,12 +157,12 @@ public void CanRetrieveTheStatusOfRenamedFilesInWorkDir() "This is a file with enough data to trigger similarity matching.\r\n" + "This is a file with enough data to trigger similarity matching.\r\n"); - repo.Index.Stage("old_name.txt"); + repo.Stage("old_name.txt"); File.Move(Path.Combine(repo.Info.WorkingDirectory, "old_name.txt"), Path.Combine(repo.Info.WorkingDirectory, "rename_target.txt")); - RepositoryStatus status = repo.Index.RetrieveStatus( + RepositoryStatus status = repo.RetrieveStatus( new StatusOptions() { DetectRenamesInIndex = true, @@ -184,10 +184,10 @@ public void CanRetrieveTheStatusOfRenamedFilesInIndex() Path.Combine(repo.Info.WorkingDirectory, "1.txt"), Path.Combine(repo.Info.WorkingDirectory, "rename_target.txt")); - repo.Index.Stage("1.txt"); - repo.Index.Stage("rename_target.txt"); + repo.Stage("1.txt"); + repo.Stage("rename_target.txt"); - RepositoryStatus status = repo.Index.RetrieveStatus(); + RepositoryStatus status = repo.RetrieveStatus(); Assert.Equal(FileStatus.RenamedInIndex, status["rename_target.txt"].State); Assert.Equal(100, status["rename_target.txt"].HeadToIndexRenameDetails.Similarity); @@ -206,7 +206,7 @@ public void CanDetectedVariousKindsOfRenaming() "This is a file with enough data to trigger similarity matching.\r\n" + "This is a file with enough data to trigger similarity matching.\r\n"); - repo.Index.Stage("file.txt"); + repo.Stage("file.txt"); repo.Commit("Initial commit", Constants.Signature, Constants.Signature); File.Move(Path.Combine(repo.Info.WorkingDirectory, "file.txt"), @@ -218,22 +218,22 @@ public void CanDetectedVariousKindsOfRenaming() DetectRenamesInWorkDir = true }; - RepositoryStatus status = repo.Index.RetrieveStatus(opts); + RepositoryStatus status = repo.RetrieveStatus(opts); // This passes as expected Assert.Equal(FileStatus.RenamedInWorkDir, status.Single().State); - repo.Index.Stage("file.txt"); - repo.Index.Stage("renamed.txt"); + repo.Stage("file.txt"); + repo.Stage("renamed.txt"); - status = repo.Index.RetrieveStatus(opts); + status = repo.RetrieveStatus(opts); Assert.Equal(FileStatus.RenamedInIndex, status.Single().State); File.Move(Path.Combine(repo.Info.WorkingDirectory, "renamed.txt"), Path.Combine(repo.Info.WorkingDirectory, "renamed_again.txt")); - status = repo.Index.RetrieveStatus(opts); + status = repo.RetrieveStatus(opts); Assert.Equal(FileStatus.RenamedInWorkDir | FileStatus.RenamedInIndex, status.Single().State); @@ -247,7 +247,7 @@ public void CanRetrieveTheStatusOfANewRepository() using (var repo = new Repository(repoPath)) { - RepositoryStatus status = repo.Index.RetrieveStatus(); + RepositoryStatus status = repo.RetrieveStatus(); Assert.NotNull(status); Assert.Equal(0, status.Count()); Assert.False(status.IsDirty); @@ -275,10 +275,10 @@ public void RetrievingTheStatusOfARepositoryReturnNativeFilePaths() Touch(repo.Info.WorkingDirectory, relFilePath, "Anybody out there?"); // Add the file to the index - repo.Index.Stage(relFilePath); + repo.Stage(relFilePath); // Get the repository status - RepositoryStatus repoStatus = repo.Index.RetrieveStatus(); + RepositoryStatus repoStatus = repo.RetrieveStatus(); Assert.Equal(1, repoStatus.Count()); StatusEntry statusEntry = repoStatus.Single(); @@ -299,15 +299,15 @@ public void RetrievingTheStatusOfAnEmptyRepositoryHonorsTheGitIgnoreDirectives() const string relativePath = "look-ma.txt"; Touch(repo.Info.WorkingDirectory, relativePath, "I'm going to be ignored!"); - RepositoryStatus status = repo.Index.RetrieveStatus(); + RepositoryStatus status = repo.RetrieveStatus(); Assert.Equal(new[] { relativePath }, status.Untracked.Select(s => s.FilePath)); Touch(repo.Info.WorkingDirectory, ".gitignore", "*.txt" + Environment.NewLine); - RepositoryStatus newStatus = repo.Index.RetrieveStatus(); + RepositoryStatus newStatus = repo.RetrieveStatus(); Assert.Equal(".gitignore", newStatus.Untracked.Select(s => s.FilePath).Single()); - Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus(relativePath)); + Assert.Equal(FileStatus.Ignored, repo.RetrieveStatus(relativePath)); Assert.Equal(new[] { relativePath }, newStatus.Ignored.Select(s => s.FilePath)); } } @@ -352,7 +352,7 @@ public void RetrievingTheStatusOfTheRepositoryHonorsTheGitIgnoreDirectives() * # new_untracked_file.txt */ - RepositoryStatus status = repo.Index.RetrieveStatus(); + RepositoryStatus status = repo.RetrieveStatus(); Assert.Equal(new[] { relativePath, "new_untracked_file.txt" }, status.Untracked.Select(s => s.FilePath)); @@ -393,10 +393,10 @@ public void RetrievingTheStatusOfTheRepositoryHonorsTheGitIgnoreDirectives() * # new_untracked_file.txt */ - RepositoryStatus newStatus = repo.Index.RetrieveStatus(); + RepositoryStatus newStatus = repo.RetrieveStatus(); Assert.Equal(".gitignore", newStatus.Untracked.Select(s => s.FilePath).Single()); - Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus(relativePath)); + Assert.Equal(FileStatus.Ignored, repo.RetrieveStatus(relativePath)); Assert.Equal(new[] { relativePath, "new_untracked_file.txt" }, newStatus.Ignored.Select(s => s.FilePath)); } } @@ -412,7 +412,7 @@ public void RetrievingTheStatusOfAnAmbiguousFileThrows() string relativePath = Path.Combine("1", "ambiguous[1].txt"); Touch(repo.Info.WorkingDirectory, relativePath, "Brackets all the way."); - Assert.Throws(() => repo.Index.RetrieveStatus(relativePath)); + Assert.Throws(() => repo.RetrieveStatus(relativePath)); } } @@ -436,7 +436,7 @@ FileStatus expectedCamelCasedFileStatus lowerCasedPath = Touch(repo.Info.WorkingDirectory, lowercasedFilename); - repo.Index.Stage(lowercasedFilename); + repo.Stage(lowercasedFilename); repo.Commit("initial", Constants.Signature, Constants.Signature); } @@ -447,8 +447,8 @@ FileStatus expectedCamelCasedFileStatus string camelCasedPath = Path.Combine(repo.Info.WorkingDirectory, upercasedFilename); File.Move(lowerCasedPath, camelCasedPath); - Assert.Equal(expectedlowerCasedFileStatus, repo.Index.RetrieveStatus(lowercasedFilename)); - Assert.Equal(expectedCamelCasedFileStatus, repo.Index.RetrieveStatus(upercasedFilename)); + Assert.Equal(expectedlowerCasedFileStatus, repo.RetrieveStatus(lowercasedFilename)); + Assert.Equal(expectedCamelCasedFileStatus, repo.RetrieveStatus(upercasedFilename)); AssertStatus(shouldIgnoreCase, expectedlowerCasedFileStatus, repo, camelCasedPath.ToLowerInvariant()); AssertStatus(shouldIgnoreCase, expectedCamelCasedFileStatus, repo, camelCasedPath.ToUpperInvariant()); @@ -459,7 +459,7 @@ private static void AssertStatus(bool shouldIgnoreCase, FileStatus expectedFileS { try { - Assert.Equal(expectedFileStatus, repo.Index.RetrieveStatus(path)); + Assert.Equal(expectedFileStatus, repo.RetrieveStatus(path)); } catch (ArgumentException) { @@ -481,10 +481,10 @@ public void RetrievingTheStatusOfTheRepositoryHonorsTheGitIgnoreDirectivesThroug const string gitIgnore = ".gitignore"; Touch(repo.Info.WorkingDirectory, gitIgnore, "bin"); - Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus("bin/look-ma.txt")); - Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus("bin/what-about-me.txt")); + Assert.Equal(FileStatus.Ignored, repo.RetrieveStatus("bin/look-ma.txt")); + Assert.Equal(FileStatus.Ignored, repo.RetrieveStatus("bin/what-about-me.txt")); - RepositoryStatus newStatus = repo.Index.RetrieveStatus(); + RepositoryStatus newStatus = repo.RetrieveStatus(); Assert.Equal(new[] { "bin" + dirSep }, newStatus.Ignored.Select(s => s.FilePath)); var sb = new StringBuilder(); @@ -492,10 +492,10 @@ public void RetrievingTheStatusOfTheRepositoryHonorsTheGitIgnoreDirectivesThroug sb.AppendLine("!bin/w*"); Touch(repo.Info.WorkingDirectory, gitIgnore, sb.ToString()); - Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus("bin/look-ma.txt")); - Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus("bin/what-about-me.txt")); + Assert.Equal(FileStatus.Ignored, repo.RetrieveStatus("bin/look-ma.txt")); + Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus("bin/what-about-me.txt")); - newStatus = repo.Index.RetrieveStatus(); + newStatus = repo.RetrieveStatus(); Assert.Equal(new[] { "bin" + dirSep + "look-ma.txt" }, newStatus.Ignored.Select(s => s.FilePath)); Assert.True(newStatus.Untracked.Select(s => s.FilePath).Contains("bin" + dirSep + "what-about-me.txt")); @@ -517,7 +517,7 @@ public void CanRetrieveStatusOfFilesInSubmodule() "sm_missing_commits" }; - RepositoryStatus status = repo.Index.RetrieveStatus(); + RepositoryStatus status = repo.RetrieveStatus(); Assert.Equal(expected, status.Modified.Select(x => x.FilePath).ToArray()); } } @@ -532,7 +532,7 @@ public void CanExcludeStatusOfFilesInSubmodule() ".gitmodules", }; - RepositoryStatus status = repo.Index.RetrieveStatus(new StatusOptions() { ExcludeSubmodules = true }); + RepositoryStatus status = repo.RetrieveStatus(new StatusOptions() { ExcludeSubmodules = true }); Assert.Equal(expected, status.Modified.Select(x => x.FilePath).ToArray()); } } diff --git a/LibGit2Sharp.Tests/SubmoduleFixture.cs b/LibGit2Sharp.Tests/SubmoduleFixture.cs index 2463912fd..e72b7b2e5 100644 --- a/LibGit2Sharp.Tests/SubmoduleFixture.cs +++ b/LibGit2Sharp.Tests/SubmoduleFixture.cs @@ -120,7 +120,7 @@ public void CanStageChangeInSubmoduleViaIndexStage(string submodulePath, bool ap var statusBefore = submodule.RetrieveStatus(); Assert.Equal(SubmoduleStatus.WorkDirModified, statusBefore & SubmoduleStatus.WorkDirModified); - repo.Index.Stage(submodulePath); + repo.Stage(submodulePath); var statusAfter = submodule.RetrieveStatus(); Assert.Equal(SubmoduleStatus.IndexModified, statusAfter & SubmoduleStatus.IndexModified); @@ -145,7 +145,7 @@ public void CanStageChangeInSubmoduleViaIndexStageWithOtherPaths(string submodul Touch(repo.Info.WorkingDirectory, "new-file.txt"); - repo.Index.Stage(new[] { "new-file.txt", submodulePath, "does-not-exist.txt" }); + repo.Stage(new[] { "new-file.txt", submodulePath, "does-not-exist.txt" }); var statusAfter = submodule.RetrieveStatus(); Assert.Equal(SubmoduleStatus.IndexModified, statusAfter & SubmoduleStatus.IndexModified); diff --git a/LibGit2Sharp.Tests/UnstageFixture.cs b/LibGit2Sharp.Tests/UnstageFixture.cs index d58784423..a965187bf 100644 --- a/LibGit2Sharp.Tests/UnstageFixture.cs +++ b/LibGit2Sharp.Tests/UnstageFixture.cs @@ -25,12 +25,12 @@ public void StagingANewVersionOfAFileThenUnstagingItRevertsTheBlobToTheVersionOf string fullpath = Path.Combine(repo.Info.WorkingDirectory, filename); File.AppendAllText(fullpath, "Is there there anybody out there?"); - repo.Index.Stage(filename); + repo.Stage(filename); Assert.Equal(count, repo.Index.Count); Assert.NotEqual((blobId), repo.Index[posixifiedFileName].Id); - repo.Index.Unstage(posixifiedFileName); + repo.Unstage(posixifiedFileName); Assert.Equal(count, repo.Index.Count); Assert.Equal(blobId, repo.Index[posixifiedFileName].Id); @@ -48,13 +48,13 @@ public void CanStageAndUnstageAnIgnoredFile() const string relativePath = "Champa.ign"; Touch(repo.Info.WorkingDirectory, relativePath, "On stage!" + Environment.NewLine); - Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus(relativePath)); + Assert.Equal(FileStatus.Ignored, repo.RetrieveStatus(relativePath)); - repo.Index.Stage(relativePath, new StageOptions { IncludeIgnored = true }); - Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(relativePath)); + repo.Stage(relativePath, new StageOptions { IncludeIgnored = true }); + Assert.Equal(FileStatus.Added, repo.RetrieveStatus(relativePath)); - repo.Index.Unstage(relativePath); - Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus(relativePath)); + repo.Unstage(relativePath); + Assert.Equal(FileStatus.Ignored, repo.RetrieveStatus(relativePath)); } } @@ -74,13 +74,13 @@ public void CanUnstage( { int count = repo.Index.Count; Assert.Equal(doesCurrentlyExistInTheIndex, (repo.Index[relativePath] != null)); - Assert.Equal(currentStatus, repo.Index.RetrieveStatus(relativePath)); + Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath)); - repo.Index.Unstage(relativePath); + repo.Unstage(relativePath); Assert.Equal(count + expectedIndexCountVariation, repo.Index.Count); Assert.Equal(doesExistInTheIndexOnceStaged, (repo.Index[relativePath] != null)); - Assert.Equal(expectedStatusOnceStaged, repo.Index.RetrieveStatus(relativePath)); + Assert.Equal(expectedStatusOnceStaged, repo.RetrieveStatus(relativePath)); } } @@ -91,9 +91,9 @@ public void UnstagingUnknownPathsWithStrictUnmatchedExplicitPathsValidationThrow { using (var repo = new Repository(CloneStandardTestRepo())) { - Assert.Equal(currentStatus, repo.Index.RetrieveStatus(relativePath)); + Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath)); - Assert.Throws(() => repo.Index.Unstage(relativePath, new ExplicitPathsOptions())); + Assert.Throws(() => repo.Unstage(relativePath, new ExplicitPathsOptions())); } } @@ -104,10 +104,10 @@ public void CanUnstageUnknownPathsWithLaxUnmatchedExplicitPathsValidation(string { using (var repo = new Repository(CloneStandardTestRepo())) { - Assert.Equal(currentStatus, repo.Index.RetrieveStatus(relativePath)); + Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath)); - Assert.DoesNotThrow(() => repo.Index.Unstage(relativePath, new ExplicitPathsOptions() { ShouldFailOnUnmatchedPath = false })); - Assert.Equal(currentStatus, repo.Index.RetrieveStatus(relativePath)); + Assert.DoesNotThrow(() => repo.Unstage(relativePath, new ExplicitPathsOptions() { ShouldFailOnUnmatchedPath = false })); + Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath)); } } @@ -124,12 +124,12 @@ public void CanUnstageTheRemovalOfAFile() string fullPath = Path.Combine(repo.Info.WorkingDirectory, filename); Assert.False(File.Exists(fullPath)); - Assert.Equal(FileStatus.Removed, repo.Index.RetrieveStatus(filename)); + Assert.Equal(FileStatus.Removed, repo.RetrieveStatus(filename)); - repo.Index.Unstage(filename); + repo.Unstage(filename); Assert.Equal(count + 1, repo.Index.Count); - Assert.Equal(FileStatus.Missing, repo.Index.RetrieveStatus(filename)); + Assert.Equal(FileStatus.Missing, repo.RetrieveStatus(filename)); } } @@ -143,14 +143,14 @@ public void CanUnstageUntrackedFileAgainstAnOrphanedHead() const string relativePath = "a.txt"; Touch(repo.Info.WorkingDirectory, relativePath, "hello test file\n"); - repo.Index.Stage(relativePath); + repo.Stage(relativePath); - repo.Index.Unstage(relativePath); - RepositoryStatus status = repo.Index.RetrieveStatus(); + repo.Unstage(relativePath); + RepositoryStatus status = repo.RetrieveStatus(); Assert.Equal(0, status.Staged.Count()); Assert.Equal(1, status.Untracked.Count()); - Assert.Throws(() => repo.Index.Unstage("i-dont-exist", new ExplicitPathsOptions())); + Assert.Throws(() => repo.Unstage("i-dont-exist", new ExplicitPathsOptions())); } } @@ -164,9 +164,9 @@ public void UnstagingUnknownPathsAgainstAnOrphanedHeadWithStrictUnmatchedExplici repo.Refs.UpdateTarget("HEAD", "refs/heads/orphaned"); Assert.True(repo.Info.IsHeadUnborn); - Assert.Equal(currentStatus, repo.Index.RetrieveStatus(relativePath)); + Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath)); - Assert.Throws(() => repo.Index.Unstage(relativePath, new ExplicitPathsOptions())); + Assert.Throws(() => repo.Unstage(relativePath, new ExplicitPathsOptions())); } } @@ -180,11 +180,11 @@ public void CanUnstageUnknownPathsAgainstAnOrphanedHeadWithLaxUnmatchedExplicitP repo.Refs.UpdateTarget("HEAD", "refs/heads/orphaned"); Assert.True(repo.Info.IsHeadUnborn); - Assert.Equal(currentStatus, repo.Index.RetrieveStatus(relativePath)); + Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath)); - Assert.DoesNotThrow(() => repo.Index.Unstage(relativePath)); - Assert.DoesNotThrow(() => repo.Index.Unstage(relativePath, new ExplicitPathsOptions { ShouldFailOnUnmatchedPath = false })); - Assert.Equal(currentStatus, repo.Index.RetrieveStatus(relativePath)); + Assert.DoesNotThrow(() => repo.Unstage(relativePath)); + Assert.DoesNotThrow(() => repo.Unstage(relativePath, new ExplicitPathsOptions { ShouldFailOnUnmatchedPath = false })); + Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath)); } } @@ -200,7 +200,7 @@ public void UnstagingANewFileWithAFullPathWhichEscapesOutOfTheWorkingDirThrows() const string filename = "unit_test.txt"; string fullPath = Touch(di.FullName, filename, "some contents"); - Assert.Throws(() => repo.Index.Unstage(fullPath)); + Assert.Throws(() => repo.Unstage(fullPath)); } } @@ -218,7 +218,7 @@ public void UnstagingANewFileWithAFullPathWhichEscapesOutOfTheWorkingDirAgainstA const string filename = "unit_test.txt"; string fullPath = Touch(di.FullName, filename, "some contents"); - Assert.Throws(() => repo.Index.Unstage(fullPath)); + Assert.Throws(() => repo.Unstage(fullPath)); } } @@ -227,10 +227,10 @@ public void UnstagingFileWithBadParamsThrows() { using (var repo = new Repository(StandardTestRepoPath)) { - Assert.Throws(() => repo.Index.Unstage(string.Empty)); - Assert.Throws(() => repo.Index.Unstage((string)null)); - Assert.Throws(() => repo.Index.Unstage(new string[] { })); - Assert.Throws(() => repo.Index.Unstage(new string[] { null })); + Assert.Throws(() => repo.Unstage(string.Empty)); + Assert.Throws(() => repo.Unstage((string)null)); + Assert.Throws(() => repo.Unstage(new string[] { })); + Assert.Throws(() => repo.Unstage(new string[] { null })); } } @@ -239,16 +239,16 @@ public void CanUnstageSourceOfARename() { using (var repo = new Repository(CloneStandardTestRepo())) { - repo.Index.Move("branch_file.txt", "renamed_branch_file.txt"); + repo.Move("branch_file.txt", "renamed_branch_file.txt"); - RepositoryStatus oldStatus = repo.Index.RetrieveStatus(); + RepositoryStatus oldStatus = repo.RetrieveStatus(); Assert.Equal(1, oldStatus.RenamedInIndex.Count()); Assert.Equal(FileStatus.Nonexistent, oldStatus["branch_file.txt"].State); Assert.Equal(FileStatus.RenamedInIndex, oldStatus["renamed_branch_file.txt"].State); - repo.Index.Unstage(new string[] { "branch_file.txt" }); + repo.Unstage(new string[] { "branch_file.txt" }); - RepositoryStatus newStatus = repo.Index.RetrieveStatus(); + RepositoryStatus newStatus = repo.RetrieveStatus(); Assert.Equal(0, newStatus.RenamedInIndex.Count()); Assert.Equal(FileStatus.Missing, newStatus["branch_file.txt"].State); Assert.Equal(FileStatus.Added, newStatus["renamed_branch_file.txt"].State); @@ -260,15 +260,15 @@ public void CanUnstageTargetOfARename() { using (var repo = new Repository(CloneStandardTestRepo())) { - repo.Index.Move("branch_file.txt", "renamed_branch_file.txt"); + repo.Move("branch_file.txt", "renamed_branch_file.txt"); - RepositoryStatus oldStatus = repo.Index.RetrieveStatus(); + RepositoryStatus oldStatus = repo.RetrieveStatus(); Assert.Equal(1, oldStatus.RenamedInIndex.Count()); Assert.Equal(FileStatus.RenamedInIndex, oldStatus["renamed_branch_file.txt"].State); - repo.Index.Unstage(new string[] { "renamed_branch_file.txt" }); + repo.Unstage(new string[] { "renamed_branch_file.txt" }); - RepositoryStatus newStatus = repo.Index.RetrieveStatus(); + RepositoryStatus newStatus = repo.RetrieveStatus(); Assert.Equal(0, newStatus.RenamedInIndex.Count()); Assert.Equal(FileStatus.Untracked, newStatus["renamed_branch_file.txt"].State); Assert.Equal(FileStatus.Removed, newStatus["branch_file.txt"].State); @@ -280,10 +280,10 @@ public void CanUnstageBothSidesOfARename() { using (var repo = new Repository(CloneStandardTestRepo())) { - repo.Index.Move("branch_file.txt", "renamed_branch_file.txt"); - repo.Index.Unstage(new string[] { "branch_file.txt", "renamed_branch_file.txt" }); + repo.Move("branch_file.txt", "renamed_branch_file.txt"); + repo.Unstage(new string[] { "branch_file.txt", "renamed_branch_file.txt" }); - RepositoryStatus status = repo.Index.RetrieveStatus(); + RepositoryStatus status = repo.RetrieveStatus(); Assert.Equal(FileStatus.Missing, status["branch_file.txt"].State); Assert.Equal(FileStatus.Untracked, status["renamed_branch_file.txt"].State); } diff --git a/LibGit2Sharp/IRepository.cs b/LibGit2Sharp/IRepository.cs index cc9de7fef..61c8aaa40 100644 --- a/LibGit2Sharp/IRepository.cs +++ b/LibGit2Sharp/IRepository.cs @@ -254,5 +254,116 @@ public interface IRepository : IDisposable /// Specifies optional parameters; if null, the defaults are used. /// The blame for the file. BlameHunkCollection Blame(string path, BlameOptions options); + + /// + /// Promotes to the staging area the latest modifications of a file in the working directory (addition, updation or removal). + /// + /// If this path is ignored by configuration then it will not be staged unless is unset. + /// + /// The path of the file within the working directory. + /// Determines how paths will be staged. + void Stage(string path, StageOptions stageOptions); + + /// + /// Promotes to the staging area the latest modifications of a collection of files in the working directory (addition, updation or removal). + /// + /// Any paths (even those listed explicitly) that are ignored by configuration will not be staged unless is unset. + /// + /// The collection of paths of the files within the working directory. + /// Determines how paths will be staged. + void Stage(IEnumerable paths, StageOptions stageOptions); + + /// + /// Removes from the staging area all the modifications of a file since the latest commit (addition, updation or removal). + /// + /// The path of the file within the working directory. + /// + /// The passed will be treated as explicit paths. + /// Use these options to determine how unmatched explicit paths should be handled. + /// + void Unstage(string path, ExplicitPathsOptions explicitPathsOptions); + + /// + /// Removes from the staging area all the modifications of a collection of file since the latest commit (addition, updation or removal). + /// + /// The collection of paths of the files within the working directory. + /// + /// The passed will be treated as explicit paths. + /// Use these options to determine how unmatched explicit paths should be handled. + /// + void Unstage(IEnumerable paths, ExplicitPathsOptions explicitPathsOptions); + + /// + /// Moves and/or renames a file in the working directory and promotes the change to the staging area. + /// + /// The path of the file within the working directory which has to be moved/renamed. + /// The target path of the file within the working directory. + void Move(string sourcePath, string destinationPath); + /// + /// Moves and/or renames a collection of files in the working directory and promotes the changes to the staging area. + /// + /// The paths of the files within the working directory which have to be moved/renamed. + /// The target paths of the files within the working directory. + void Move(IEnumerable sourcePaths, IEnumerable destinationPaths); + + /// + /// Removes a file from the staging area, and optionally removes it from the working directory as well. + /// + /// If the file has already been deleted from the working directory, this method will only deal + /// with promoting the removal to the staging area. + /// + /// + /// The default behavior is to remove the file from the working directory as well. + /// + /// + /// When not passing a , the passed path will be treated as + /// a pathspec. You can for example use it to pass the relative path to a folder inside the working directory, + /// so that all files beneath this folders, and the folder itself, will be removed. + /// + /// + /// The path of the file within the working directory. + /// True to remove the file from the working directory, False otherwise. + /// + /// The passed will be treated as an explicit path. + /// Use these options to determine how unmatched explicit paths should be handled. + /// + void Remove(string path, bool removeFromWorkingDirectory, ExplicitPathsOptions explicitPathsOptions); + + /// + /// Removes a collection of fileS from the staging, and optionally removes them from the working directory as well. + /// + /// If a file has already been deleted from the working directory, this method will only deal + /// with promoting the removal to the staging area. + /// + /// + /// The default behavior is to remove the files from the working directory as well. + /// + /// + /// When not passing a , the passed paths will be treated as + /// a pathspec. You can for example use it to pass the relative paths to folders inside the working directory, + /// so that all files beneath these folders, and the folders themselves, will be removed. + /// + /// + /// The collection of paths of the files within the working directory. + /// True to remove the files from the working directory, False otherwise. + /// + /// The passed will be treated as explicit paths. + /// Use these options to determine how unmatched explicit paths should be handled. + /// + void Remove(IEnumerable paths, bool removeFromWorkingDirectory, ExplicitPathsOptions explicitPathsOptions); + + /// + /// Retrieves the state of a file in the working directory, comparing it against the staging area and the latest commmit. + /// + /// The relative path within the working directory to the file. + /// A representing the state of the parameter. + FileStatus RetrieveStatus(string filePath); + + /// + /// Retrieves the state of all files in the working directory, comparing them against the staging area and the latest commmit. + /// + /// If set, the options that control the status investigation. + /// A holding the state of all the files. + RepositoryStatus RetrieveStatus(StatusOptions options); } } diff --git a/LibGit2Sharp/Index.cs b/LibGit2Sharp/Index.cs index 89bd9b156..3418cea16 100644 --- a/LibGit2Sharp/Index.cs +++ b/LibGit2Sharp/Index.cs @@ -134,11 +134,10 @@ IEnumerator IEnumerable.GetEnumerator() /// /// The path of the file within the working directory. /// If set, determines how paths will be staged. + [Obsolete("This method will be removed in the next release. Use Repository.Stage instead.")] public virtual void Stage(string path, StageOptions stageOptions = null) { - Ensure.ArgumentNotNull(path, "path"); - - Stage(new[] { path }, stageOptions); + repo.Stage(path, stageOptions); } /// @@ -148,44 +147,10 @@ public virtual void Stage(string path, StageOptions stageOptions = null) /// /// The collection of paths of the files within the working directory. /// If set, determines how paths will be staged. + [Obsolete("This method will be removed in the next release. Use Repository.Stage instead.")] public virtual void Stage(IEnumerable paths, StageOptions stageOptions = null) { - Ensure.ArgumentNotNull(paths, "paths"); - - DiffModifiers diffModifiers = DiffModifiers.IncludeUntracked; - ExplicitPathsOptions explicitPathsOptions = stageOptions != null ? stageOptions.ExplicitPathsOptions : null; - - if (stageOptions != null && stageOptions.IncludeIgnored) - { - diffModifiers |= DiffModifiers.IncludeIgnored; - } - - var changes = repo.Diff.Compare(diffModifiers, paths, explicitPathsOptions); - - foreach (var treeEntryChanges in changes) - { - switch (treeEntryChanges.Status) - { - case ChangeKind.Unmodified: - continue; - - case ChangeKind.Deleted: - RemoveFromIndex(treeEntryChanges.Path); - continue; - - case ChangeKind.Added: - /* Fall through */ - case ChangeKind.Modified: - AddToIndex(treeEntryChanges.Path); - continue; - - default: - throw new InvalidOperationException( - string.Format(CultureInfo.InvariantCulture, "Entry '{0}' bears an unexpected ChangeKind '{1}'", treeEntryChanges.Path, treeEntryChanges.Status)); - } - } - - UpdatePhysicalIndex(); + repo.Stage(paths, stageOptions); } /// @@ -196,11 +161,10 @@ public virtual void Stage(IEnumerable paths, StageOptions stageOptions = /// If set, the passed will be treated as explicit paths. /// Use these options to determine how unmatched explicit paths should be handled. /// + [Obsolete("This method will be removed in the next release. Use Repository.Unstage instead.")] public virtual void Unstage(string path, ExplicitPathsOptions explicitPathsOptions = null) { - Ensure.ArgumentNotNull(path, "path"); - - Unstage(new[] { path }, explicitPathsOptions); + repo.Unstage(path, explicitPathsOptions); } /// @@ -211,20 +175,10 @@ public virtual void Unstage(string path, ExplicitPathsOptions explicitPathsOptio /// If set, the passed will be treated as explicit paths. /// Use these options to determine how unmatched explicit paths should be handled. /// + [Obsolete("This method will be removed in the next release. Use Repository.Unstage instead.")] public virtual void Unstage(IEnumerable paths, ExplicitPathsOptions explicitPathsOptions = null) { - Ensure.ArgumentNotNull(paths, "paths"); - - if (repo.Info.IsHeadUnborn) - { - var changes = repo.Diff.Compare(null, DiffTargets.Index, paths, explicitPathsOptions, new CompareOptions { Similarity = SimilarityOptions.None }); - - Reset(changes); - } - else - { - repo.Reset("HEAD", paths, explicitPathsOptions); - } + repo.Unstage(paths, explicitPathsOptions); } /// @@ -232,9 +186,10 @@ public virtual void Unstage(IEnumerable paths, ExplicitPathsOptions expl /// /// The path of the file within the working directory which has to be moved/renamed. /// The target path of the file within the working directory. + [Obsolete("This method will be removed in the next release. Use Repository.Move instead.")] public virtual void Move(string sourcePath, string destinationPath) { - Move(new[] { sourcePath }, new[] { destinationPath }); + repo.Move(new[] { sourcePath }, new[] { destinationPath }); } /// @@ -242,62 +197,10 @@ public virtual void Move(string sourcePath, string destinationPath) /// /// The paths of the files within the working directory which have to be moved/renamed. /// The target paths of the files within the working directory. + [Obsolete("This method will be removed in the next release. Use Repository.Move instead.")] public virtual void Move(IEnumerable sourcePaths, IEnumerable destinationPaths) { - Ensure.ArgumentNotNull(sourcePaths, "sourcePaths"); - Ensure.ArgumentNotNull(destinationPaths, "destinationPaths"); - - //TODO: Move() should support following use cases: - // - Moving a file under a directory ('file' and 'dir' -> 'dir/file') - // - Moving a directory (and its content) under another directory ('dir1' and 'dir2' -> 'dir2/dir1/*') - - //TODO: Move() should throw when: - // - Moving a directory under a file - - IDictionary, Tuple> batch = PrepareBatch(sourcePaths, destinationPaths); - - if (batch.Count == 0) - { - throw new ArgumentNullException("sourcePaths"); - } - - foreach (KeyValuePair, Tuple> keyValuePair in batch) - { - string sourcePath = keyValuePair.Key.Item1; - string destPath = keyValuePair.Value.Item1; - - if (Directory.Exists(sourcePath) || Directory.Exists(destPath)) - { - throw new NotImplementedException(); - } - - FileStatus sourceStatus = keyValuePair.Key.Item2; - if (sourceStatus.HasAny(new Enum[] { FileStatus.Nonexistent, FileStatus.Removed, FileStatus.Untracked, FileStatus.Missing })) - { - throw new LibGit2SharpException(string.Format(CultureInfo.InvariantCulture, "Unable to move file '{0}'. Its current status is '{1}'.", sourcePath, sourceStatus)); - } - - FileStatus desStatus = keyValuePair.Value.Item2; - if (desStatus.HasAny(new Enum[] { FileStatus.Nonexistent, FileStatus.Missing })) - { - continue; - } - - throw new LibGit2SharpException(string.Format(CultureInfo.InvariantCulture, "Unable to overwrite file '{0}'. Its current status is '{1}'.", destPath, desStatus)); - } - - string wd = repo.Info.WorkingDirectory; - foreach (KeyValuePair, Tuple> keyValuePair in batch) - { - string from = keyValuePair.Key.Item1; - string to = keyValuePair.Value.Item1; - - RemoveFromIndex(from); - File.Move(Path.Combine(wd, from), Path.Combine(wd, to)); - AddToIndex(to); - } - - UpdatePhysicalIndex(); + repo.Move(sourcePaths, destinationPaths); } /// @@ -321,11 +224,10 @@ public virtual void Move(IEnumerable sourcePaths, IEnumerable de /// If set, the passed will be treated as an explicit path. /// Use these options to determine how unmatched explicit paths should be handled. /// + [Obsolete("This method will be removed in the next release. Use Repository.Remove instead.")] public virtual void Remove(string path, bool removeFromWorkingDirectory = true, ExplicitPathsOptions explicitPathsOptions = null) { - Ensure.ArgumentNotNull(path, "path"); - - Remove(new[] { path }, removeFromWorkingDirectory, explicitPathsOptions); + repo.Remove(new[] { path }, removeFromWorkingDirectory, explicitPathsOptions); } /// @@ -349,113 +251,23 @@ public virtual void Remove(string path, bool removeFromWorkingDirectory = true, /// If set, the passed will be treated as explicit paths. /// Use these options to determine how unmatched explicit paths should be handled. /// + [Obsolete("This method will be removed in the next release. Use Repository.Remove instead.")] public virtual void Remove(IEnumerable paths, bool removeFromWorkingDirectory = true, ExplicitPathsOptions explicitPathsOptions = null) { - Ensure.ArgumentNotNullOrEmptyEnumerable(paths, "paths"); - - var pathsToDelete = paths.Where(p => Directory.Exists(Path.Combine(repo.Info.WorkingDirectory, p))).ToList(); - var notConflictedPaths = new List(); - - foreach (var path in paths) - { - Ensure.ArgumentNotNullOrEmptyString(path, "path"); - - var conflict = repo.Index.Conflicts[path]; - - if (conflict != null) - { - pathsToDelete.Add(RemoveFromIndex(path)); - } - else - { - notConflictedPaths.Add(path); - } - } - - if (notConflictedPaths.Count > 0) - { - pathsToDelete.AddRange(RemoveStagedItems(notConflictedPaths, removeFromWorkingDirectory, explicitPathsOptions)); - } - - if (removeFromWorkingDirectory) - { - RemoveFilesAndFolders(pathsToDelete); - } - - UpdatePhysicalIndex(); - } - - private IEnumerable RemoveStagedItems(IEnumerable paths, bool removeFromWorkingDirectory = true, ExplicitPathsOptions explicitPathsOptions = null) - { - var removed = new List(); - var changes = repo.Diff.Compare(DiffModifiers.IncludeUnmodified | DiffModifiers.IncludeUntracked, paths, explicitPathsOptions); - - foreach (var treeEntryChanges in changes) - { - var status = repo.Index.RetrieveStatus(treeEntryChanges.Path); - - switch (treeEntryChanges.Status) - { - case ChangeKind.Added: - case ChangeKind.Deleted: - removed.Add(RemoveFromIndex(treeEntryChanges.Path)); - break; - - case ChangeKind.Unmodified: - if (removeFromWorkingDirectory && ( - status.HasFlag(FileStatus.Staged) || - status.HasFlag(FileStatus.Added))) - { - throw new RemoveFromIndexException(string.Format(CultureInfo.InvariantCulture, "Unable to remove file '{0}', as it has changes staged in the index. You can call the Remove() method with removeFromWorkingDirectory=false if you want to remove it from the index only.", - treeEntryChanges.Path)); - } - removed.Add(RemoveFromIndex(treeEntryChanges.Path)); - continue; - - case ChangeKind.Modified: - if (status.HasFlag(FileStatus.Modified) && status.HasFlag(FileStatus.Staged)) - { - throw new RemoveFromIndexException(string.Format(CultureInfo.InvariantCulture, "Unable to remove file '{0}', as it has staged content different from both the working directory and the HEAD.", - treeEntryChanges.Path)); - } - if (removeFromWorkingDirectory) - { - throw new RemoveFromIndexException(string.Format(CultureInfo.InvariantCulture, "Unable to remove file '{0}', as it has local modifications. You can call the Remove() method with removeFromWorkingDirectory=false if you want to remove it from the index only.", - treeEntryChanges.Path)); - } - removed.Add(RemoveFromIndex(treeEntryChanges.Path)); - continue; - - default: - throw new RemoveFromIndexException(string.Format(CultureInfo.InvariantCulture, "Unable to remove file '{0}'. Its current status is '{1}'.", - treeEntryChanges.Path, treeEntryChanges.Status)); - } - } - - return removed; + repo.Remove(paths, removeFromWorkingDirectory, explicitPathsOptions); } - - private void RemoveFilesAndFolders(IEnumerable pathsList) + + /// + /// Replaces entries in the staging area with entries from the specified tree. + /// + /// This overwrites all existing state in the staging area. + /// + /// + /// The to read the entries from. + [Obsolete("This method will be removed in the next release. Use Replace instead.")] + public virtual void Reset(Tree source) { - string wd = repo.Info.WorkingDirectory; - - foreach (string path in pathsList) - { - string fileName = Path.Combine(wd, path); - - if (Directory.Exists(fileName)) - { - Directory.Delete(fileName, true); - continue; - } - - if (!File.Exists(fileName)) - { - continue; - } - - File.Delete(fileName); - } + Replace(source); } /// @@ -465,7 +277,7 @@ private void RemoveFilesAndFolders(IEnumerable pathsList) /// /// /// The to read the entries from. - public virtual void Reset(Tree source) + public virtual void Replace(Tree source) { using (var obj = new ObjectSafeWrapper(source.Id, repo.Handle)) { @@ -488,50 +300,6 @@ public virtual void Clear() UpdatePhysicalIndex(); } - private IDictionary, Tuple> PrepareBatch(IEnumerable leftPaths, IEnumerable rightPaths) - { - IDictionary, Tuple> dic = new Dictionary, Tuple>(); - - IEnumerator leftEnum = leftPaths.GetEnumerator(); - IEnumerator rightEnum = rightPaths.GetEnumerator(); - - while (Enumerate(leftEnum, rightEnum)) - { - Tuple from = BuildFrom(leftEnum.Current); - Tuple to = BuildFrom(rightEnum.Current); - dic.Add(from, to); - } - - return dic; - } - - private Tuple BuildFrom(string path) - { - string relativePath = repo.BuildRelativePathFrom(path); - return new Tuple(relativePath, RetrieveStatus(relativePath)); - } - - private static bool Enumerate(IEnumerator leftEnum, IEnumerator rightEnum) - { - bool isLeftEoF = leftEnum.MoveNext(); - bool isRightEoF = rightEnum.MoveNext(); - - if (isLeftEoF == isRightEoF) - { - return isLeftEoF; - } - - throw new ArgumentException("The collection of paths are of different lengths."); - } - - private void AddToIndex(string relativePath) - { - if (!repo.Submodules.TryStage(relativePath, true)) - { - Proxy.git_index_add_bypath(handle, relativePath); - } - } - private string RemoveFromIndex(string relativePath) { Proxy.git_index_remove_bypath(handle, relativePath); @@ -549,13 +317,10 @@ private void UpdatePhysicalIndex() /// /// The relative path within the working directory to the file. /// A representing the state of the parameter. + [Obsolete("This method will be removed in the next release. Use Repository.RetrieveStatus instead.")] public virtual FileStatus RetrieveStatus(string filePath) { - Ensure.ArgumentNotNullOrEmptyString(filePath, "filePath"); - - string relativePath = repo.BuildRelativePathFrom(filePath); - - return Proxy.git_status_file(repo.Handle, relativePath); + return repo.RetrieveStatus(filePath); } /// @@ -563,14 +328,13 @@ public virtual FileStatus RetrieveStatus(string filePath) /// /// If set, the options that control the status investigation. /// A holding the state of all the files. + [Obsolete("This method will be removed in the next release. Use Repository.RetrieveStatus instead.")] public virtual RepositoryStatus RetrieveStatus(StatusOptions options = null) { - ReloadFromDisk(); - - return new RepositoryStatus(repo, options); + return repo.RetrieveStatus(options); } - internal void Reset(TreeChanges changes) + internal void Replace(TreeChanges changes) { foreach (TreeEntryChanges treeEntryChanges in changes) { @@ -620,12 +384,7 @@ private void ReplaceIndexEntryWith(TreeEntryChanges treeEntryChanges) Proxy.git_index_add(handle, indexEntry); EncodingMarshaler.Cleanup(indexEntry.Path); } - - internal void ReloadFromDisk() - { - Proxy.git_index_read(handle); - } - + private string DebuggerDisplay { get diff --git a/LibGit2Sharp/Repository.cs b/LibGit2Sharp/Repository.cs index ab91bf3b4..df86bc221 100644 --- a/LibGit2Sharp/Repository.cs +++ b/LibGit2Sharp/Repository.cs @@ -792,7 +792,7 @@ public void Reset(Commit commit, IEnumerable paths, ExplicitPathsOptions Ensure.ArgumentNotNull(commit, "commit"); var changes = Diff.Compare(commit.Tree, DiffTargets.Index, paths, explicitPathsOptions, new CompareOptions { Similarity = SimilarityOptions.None }); - Index.Reset(changes); + Index.Replace(changes); } /// @@ -1110,7 +1110,7 @@ public RevertResult Revert(Commit commit, Signature reverter, RevertOptions opti // Check if the revert generated any changes // and set the revert status accordingly - bool anythingToRevert = Index.RetrieveStatus( + bool anythingToRevert = RetrieveStatus( new StatusOptions() { DetectRenamesInIndex = false, @@ -1444,5 +1444,423 @@ private string DebuggerDisplay Info.IsBare ? Info.Path : Info.WorkingDirectory); } } + + /// + /// Promotes to the staging area the latest modifications of a file in the working directory (addition, updation or removal). + /// + /// If this path is ignored by configuration then it will not be staged unless is unset. + /// + /// The path of the file within the working directory. + /// Determines how paths will be staged. + public void Stage(string path, StageOptions stageOptions) + { + Ensure.ArgumentNotNull(path, "path"); + + Stage(new[] { path }, stageOptions); + } + + /// + /// Promotes to the staging area the latest modifications of a collection of files in the working directory (addition, updation or removal). + /// + /// Any paths (even those listed explicitly) that are ignored by configuration will not be staged unless is unset. + /// + /// The collection of paths of the files within the working directory. + /// Determines how paths will be staged. + public void Stage(IEnumerable paths, StageOptions stageOptions) + { + Ensure.ArgumentNotNull(paths, "paths"); + + DiffModifiers diffModifiers = DiffModifiers.IncludeUntracked; + ExplicitPathsOptions explicitPathsOptions = stageOptions != null ? stageOptions.ExplicitPathsOptions : null; + + if (stageOptions != null && stageOptions.IncludeIgnored) + { + diffModifiers |= DiffModifiers.IncludeIgnored; + } + + var changes = Diff.Compare(diffModifiers, paths, explicitPathsOptions); + + foreach (var treeEntryChanges in changes) + { + switch (treeEntryChanges.Status) + { + case ChangeKind.Unmodified: + continue; + + case ChangeKind.Deleted: + RemoveFromIndex(treeEntryChanges.Path); + continue; + + case ChangeKind.Added: + /* Fall through */ + case ChangeKind.Modified: + AddToIndex(treeEntryChanges.Path); + continue; + + default: + throw new InvalidOperationException( + string.Format(CultureInfo.InvariantCulture, "Entry '{0}' bears an unexpected ChangeKind '{1}'", treeEntryChanges.Path, treeEntryChanges.Status)); + } + } + + UpdatePhysicalIndex(); + } + + /// + /// Removes from the staging area all the modifications of a file since the latest commit (addition, updation or removal). + /// + /// The path of the file within the working directory. + /// + /// The passed will be treated as explicit paths. + /// Use these options to determine how unmatched explicit paths should be handled. + /// + public void Unstage(string path, ExplicitPathsOptions explicitPathsOptions) + { + Ensure.ArgumentNotNull(path, "path"); + + Unstage(new[] { path }, explicitPathsOptions); + } + + /// + /// Removes from the staging area all the modifications of a collection of file since the latest commit (addition, updation or removal). + /// + /// The collection of paths of the files within the working directory. + /// + /// The passed will be treated as explicit paths. + /// Use these options to determine how unmatched explicit paths should be handled. + /// + public void Unstage(IEnumerable paths, ExplicitPathsOptions explicitPathsOptions) + { + Ensure.ArgumentNotNull(paths, "paths"); + + if (Info.IsHeadUnborn) + { + var changes = Diff.Compare(null, DiffTargets.Index, paths, explicitPathsOptions, new CompareOptions { Similarity = SimilarityOptions.None }); + + Index.Replace(changes); + } + else + { + this.Reset("HEAD", paths, explicitPathsOptions); + } + } + + /// + /// Moves and/or renames a file in the working directory and promotes the change to the staging area. + /// + /// The path of the file within the working directory which has to be moved/renamed. + /// The target path of the file within the working directory. + public void Move(string sourcePath, string destinationPath) + { + Move(new[] { sourcePath }, new[] { destinationPath }); + } + + /// + /// Moves and/or renames a collection of files in the working directory and promotes the changes to the staging area. + /// + /// The paths of the files within the working directory which have to be moved/renamed. + /// The target paths of the files within the working directory. + public void Move(IEnumerable sourcePaths, IEnumerable destinationPaths) + { + Ensure.ArgumentNotNull(sourcePaths, "sourcePaths"); + Ensure.ArgumentNotNull(destinationPaths, "destinationPaths"); + + //TODO: Move() should support following use cases: + // - Moving a file under a directory ('file' and 'dir' -> 'dir/file') + // - Moving a directory (and its content) under another directory ('dir1' and 'dir2' -> 'dir2/dir1/*') + + //TODO: Move() should throw when: + // - Moving a directory under a file + + IDictionary, Tuple> batch = PrepareBatch(sourcePaths, destinationPaths); + + if (batch.Count == 0) + { + throw new ArgumentNullException("sourcePaths"); + } + + foreach (KeyValuePair, Tuple> keyValuePair in batch) + { + string sourcePath = keyValuePair.Key.Item1; + string destPath = keyValuePair.Value.Item1; + + if (Directory.Exists(sourcePath) || Directory.Exists(destPath)) + { + throw new NotImplementedException(); + } + + FileStatus sourceStatus = keyValuePair.Key.Item2; + if (sourceStatus.HasAny(new Enum[] { FileStatus.Nonexistent, FileStatus.Removed, FileStatus.Untracked, FileStatus.Missing })) + { + throw new LibGit2SharpException(string.Format(CultureInfo.InvariantCulture, "Unable to move file '{0}'. Its current status is '{1}'.", sourcePath, sourceStatus)); + } + + FileStatus desStatus = keyValuePair.Value.Item2; + if (desStatus.HasAny(new Enum[] { FileStatus.Nonexistent, FileStatus.Missing })) + { + continue; + } + + throw new LibGit2SharpException(string.Format(CultureInfo.InvariantCulture, "Unable to overwrite file '{0}'. Its current status is '{1}'.", destPath, desStatus)); + } + + string wd = Info.WorkingDirectory; + foreach (KeyValuePair, Tuple> keyValuePair in batch) + { + string from = keyValuePair.Key.Item1; + string to = keyValuePair.Value.Item1; + + RemoveFromIndex(from); + File.Move(Path.Combine(wd, from), Path.Combine(wd, to)); + AddToIndex(to); + } + + UpdatePhysicalIndex(); + } + + /// + /// Removes a file from the staging area, and optionally removes it from the working directory as well. + /// + /// If the file has already been deleted from the working directory, this method will only deal + /// with promoting the removal to the staging area. + /// + /// + /// The default behavior is to remove the file from the working directory as well. + /// + /// + /// When not passing a , the passed path will be treated as + /// a pathspec. You can for example use it to pass the relative path to a folder inside the working directory, + /// so that all files beneath this folders, and the folder itself, will be removed. + /// + /// + /// The path of the file within the working directory. + /// True to remove the file from the working directory, False otherwise. + /// + /// The passed will be treated as an explicit path. + /// Use these options to determine how unmatched explicit paths should be handled. + /// + public void Remove(string path, bool removeFromWorkingDirectory, ExplicitPathsOptions explicitPathsOptions) + { + Ensure.ArgumentNotNull(path, "path"); + + Remove(new[] { path }, removeFromWorkingDirectory, explicitPathsOptions); + } + + /// + /// Removes a collection of fileS from the staging, and optionally removes them from the working directory as well. + /// + /// If a file has already been deleted from the working directory, this method will only deal + /// with promoting the removal to the staging area. + /// + /// + /// The default behavior is to remove the files from the working directory as well. + /// + /// + /// When not passing a , the passed paths will be treated as + /// a pathspec. You can for example use it to pass the relative paths to folders inside the working directory, + /// so that all files beneath these folders, and the folders themselves, will be removed. + /// + /// + /// The collection of paths of the files within the working directory. + /// True to remove the files from the working directory, False otherwise. + /// + /// The passed will be treated as explicit paths. + /// Use these options to determine how unmatched explicit paths should be handled. + /// + public void Remove(IEnumerable paths, bool removeFromWorkingDirectory, ExplicitPathsOptions explicitPathsOptions) + { + Ensure.ArgumentNotNullOrEmptyEnumerable(paths, "paths"); + + var pathsToDelete = paths.Where(p => Directory.Exists(Path.Combine(Info.WorkingDirectory, p))).ToList(); + var notConflictedPaths = new List(); + + foreach (var path in paths) + { + Ensure.ArgumentNotNullOrEmptyString(path, "path"); + + var conflict = Index.Conflicts[path]; + + if (conflict != null) + { + pathsToDelete.Add(RemoveFromIndex(path)); + } + else + { + notConflictedPaths.Add(path); + } + } + + if (notConflictedPaths.Count > 0) + { + pathsToDelete.AddRange(RemoveStagedItems(notConflictedPaths, removeFromWorkingDirectory, explicitPathsOptions)); + } + + if (removeFromWorkingDirectory) + { + RemoveFilesAndFolders(pathsToDelete); + } + + UpdatePhysicalIndex(); + } + + /// + /// Retrieves the state of a file in the working directory, comparing it against the staging area and the latest commmit. + /// + /// The relative path within the working directory to the file. + /// A representing the state of the parameter. + public FileStatus RetrieveStatus(string filePath) + { + Ensure.ArgumentNotNullOrEmptyString(filePath, "filePath"); + + string relativePath = this.BuildRelativePathFrom(filePath); + + return Proxy.git_status_file(Handle, relativePath); + } + + /// + /// Retrieves the state of all files in the working directory, comparing them against the staging area and the latest commmit. + /// + /// If set, the options that control the status investigation. + /// A holding the state of all the files. + public RepositoryStatus RetrieveStatus(StatusOptions options) + { + ReloadFromDisk(); + + return new RepositoryStatus(this, options); + } + + internal void ReloadFromDisk() + { + Proxy.git_index_read(Index.Handle); + } + + private void AddToIndex(string relativePath) + { + if (!Submodules.TryStage(relativePath, true)) + { + Proxy.git_index_add_bypath(Index.Handle, relativePath); + } + } + + private string RemoveFromIndex(string relativePath) + { + Proxy.git_index_remove_bypath(Index.Handle, relativePath); + + return relativePath; + } + + private void UpdatePhysicalIndex() + { + Proxy.git_index_write(Index.Handle); + } + + private Tuple BuildFrom(string path) + { + string relativePath = this.BuildRelativePathFrom(path); + return new Tuple(relativePath, RetrieveStatus(relativePath)); + } + + private static bool Enumerate(IEnumerator leftEnum, IEnumerator rightEnum) + { + bool isLeftEoF = leftEnum.MoveNext(); + bool isRightEoF = rightEnum.MoveNext(); + + if (isLeftEoF == isRightEoF) + { + return isLeftEoF; + } + + throw new ArgumentException("The collection of paths are of different lengths."); + } + + private IDictionary, Tuple> PrepareBatch(IEnumerable leftPaths, IEnumerable rightPaths) + { + IDictionary, Tuple> dic = new Dictionary, Tuple>(); + + IEnumerator leftEnum = leftPaths.GetEnumerator(); + IEnumerator rightEnum = rightPaths.GetEnumerator(); + + while (Enumerate(leftEnum, rightEnum)) + { + Tuple from = BuildFrom(leftEnum.Current); + Tuple to = BuildFrom(rightEnum.Current); + dic.Add(from, to); + } + + return dic; + } + + private void RemoveFilesAndFolders(IEnumerable pathsList) + { + string wd = Info.WorkingDirectory; + + foreach (string path in pathsList) + { + string fileName = Path.Combine(wd, path); + + if (Directory.Exists(fileName)) + { + Directory.Delete(fileName, true); + continue; + } + + if (!File.Exists(fileName)) + { + continue; + } + + File.Delete(fileName); + } + } + + private IEnumerable RemoveStagedItems(IEnumerable paths, bool removeFromWorkingDirectory = true, ExplicitPathsOptions explicitPathsOptions = null) + { + var removed = new List(); + var changes = Diff.Compare(DiffModifiers.IncludeUnmodified | DiffModifiers.IncludeUntracked, paths, explicitPathsOptions); + + foreach (var treeEntryChanges in changes) + { + var status = RetrieveStatus(treeEntryChanges.Path); + + switch (treeEntryChanges.Status) + { + case ChangeKind.Added: + case ChangeKind.Deleted: + removed.Add(RemoveFromIndex(treeEntryChanges.Path)); + break; + + case ChangeKind.Unmodified: + if (removeFromWorkingDirectory && ( + status.HasFlag(FileStatus.Staged) || + status.HasFlag(FileStatus.Added) )) + { + throw new RemoveFromIndexException(string.Format(CultureInfo.InvariantCulture, "Unable to remove file '{0}', as it has changes staged in the index. You can call the Remove() method with removeFromWorkingDirectory=false if you want to remove it from the index only.", + treeEntryChanges.Path)); + } + removed.Add(RemoveFromIndex(treeEntryChanges.Path)); + continue; + + case ChangeKind.Modified: + if (status.HasFlag(FileStatus.Modified) && status.HasFlag(FileStatus.Staged)) + { + throw new RemoveFromIndexException(string.Format(CultureInfo.InvariantCulture, "Unable to remove file '{0}', as it has staged content different from both the working directory and the HEAD.", + treeEntryChanges.Path)); + } + if (removeFromWorkingDirectory) + { + throw new RemoveFromIndexException(string.Format(CultureInfo.InvariantCulture, "Unable to remove file '{0}', as it has local modifications. You can call the Remove() method with removeFromWorkingDirectory=false if you want to remove it from the index only.", + treeEntryChanges.Path)); + } + removed.Add(RemoveFromIndex(treeEntryChanges.Path)); + continue; + + default: + throw new RemoveFromIndexException(string.Format(CultureInfo.InvariantCulture, "Unable to remove file '{0}'. Its current status is '{1}'.", + treeEntryChanges.Path, treeEntryChanges.Status)); + } + } + + return removed; + } } } diff --git a/LibGit2Sharp/RepositoryExtensions.cs b/LibGit2Sharp/RepositoryExtensions.cs index ab6d3e94a..a1f4338fe 100644 --- a/LibGit2Sharp/RepositoryExtensions.cs +++ b/LibGit2Sharp/RepositoryExtensions.cs @@ -617,5 +617,116 @@ public static RevertResult Revert(this IRepository repository, Commit commit, Si { return repository.Revert(commit, reverter, null); } + + /// + /// Promotes to the staging area the latest modifications of a file in the working directory (addition, updation or removal). + /// + /// The path of the file within the working directory. + public static void Stage(this IRepository repository, string path) + { + repository.Stage(path, null); + } + + /// + /// Promotes to the staging area the latest modifications of a collection of files in the working directory (addition, updation or removal). + /// + /// The collection of paths of the files within the working directory. + public static void Stage(this IRepository repository, IEnumerable paths) + { + repository.Stage(paths, null); + } + + /// + /// Removes from the staging area all the modifications of a file since the latest commit (addition, updation or removal). + /// + /// The path of the file within the working directory. + public static void Unstage(this IRepository repository, string path) + { + repository.Unstage(path, null); + } + + /// + /// Removes from the staging area all the modifications of a collection of file since the latest commit (addition, updation or removal). + /// + /// The collection of paths of the files within the working directory. + public static void Unstage(this IRepository repository, IEnumerable paths) + { + repository.Unstage(paths, null); + } + + /// + /// Removes a file from the staging area, and optionally removes it from the working directory as well. + /// + /// If the file has already been deleted from the working directory, this method will only deal + /// with promoting the removal to the staging area. + /// + /// + /// The default behavior is to remove the file from the working directory as well. + /// + /// + /// The path of the file within the working directory. + public static void Remove(this IRepository repository, string path) + { + repository.Remove(path, true, null); + } + + /// + /// Removes a file from the staging area, and optionally removes it from the working directory as well. + /// + /// If the file has already been deleted from the working directory, this method will only deal + /// with promoting the removal to the staging area. + /// + /// + /// The default behavior is to remove the file from the working directory as well. + /// + /// + /// The path of the file within the working directory. + /// True to remove the file from the working directory, False otherwise. + public static void Remove(this IRepository repository, string path, bool removeFromWorkingDirectory) + { + repository.Remove(path, removeFromWorkingDirectory, null); + } + + /// + /// Removes a collection of fileS from the staging, and optionally removes them from the working directory as well. + /// + /// If a file has already been deleted from the working directory, this method will only deal + /// with promoting the removal to the staging area. + /// + /// + /// The default behavior is to remove the files from the working directory as well. + /// + /// + public static void Remove(this IRepository repository, IEnumerable paths) + { + repository.Remove(paths, true, null); + } + + /// + /// Removes a collection of fileS from the staging, and optionally removes them from the working directory as well. + /// + /// If a file has already been deleted from the working directory, this method will only deal + /// with promoting the removal to the staging area. + /// + /// + /// The default behavior is to remove the files from the working directory as well. + /// + /// + /// The collection of paths of the files within the working directory. + /// True to remove the files from the working directory, False otherwise. + public static void Remove(this IRepository repository, IEnumerable paths, bool removeFromWorkingDirectory) + { + repository.Remove(paths, removeFromWorkingDirectory, null); + } + + /// + /// Retrieves the state of all files in the working directory, comparing them against the staging area and the latest commmit. + /// + /// A holding the state of all the files. + public static RepositoryStatus RetrieveStatus(this IRepository repository) + { + Proxy.git_index_read(repository.Index.Handle); + return new RepositoryStatus((Repository)repository, null); + } } }