8000 Move higher level Index operations to IRepository · ravindp/libgit2sharp@7a31788 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7a31788

Browse files
JPaulDuncannulltoken
authored andcommitted
Move higher level Index operations to IRepository
Fix libgit2#822
1 parent a03f597 commit 7a31788

34 files changed

+1096
-686
lines changed

LibGit2Sharp.Tests/AttributesFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ private static void AssertNormalization(IRepository repo, string filename, bool
3030

3131
Touch(repo.Info.WorkingDirectory, filename, sb.ToString());
3232

33-
repo.Index.Stage(filename);
33+
repo.Stage(filename);
3434

3535
IndexEntry entry = repo.Index[filename];
3636
Assert.NotNull(entry);

LibGit2Sharp.Tests/BlobFixture.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void CanGetBlobAsTextWithVariousEncodings(string encodingName, int expect
6262
var bomPath = Touch(repo.Info.WorkingDirectory, bomFile, content, encoding);
6363
Assert.Equal(expectedContentBytes, File.ReadAllBytes(bomPath).Length);
6464

65-
repo.Index.Stage(bomFile);
65+
repo.Stage(bomFile);
6666
var commit = repo.Commit("bom", Constants.Signature, Constants.Signature);
6767

6868
var blob = (Blob)commit.Tree[bomFile].Target;
@@ -186,7 +186,7 @@ public void CanStageAFileGeneratedFromABlobContentStream()
186186
File.AppendAllText(Path.Combine(repo.Info.WorkingDirectory, "small.txt"), sb.ToString());
187187
}
188188

189-
repo.Index.Stage("small.txt");
189+
repo.Stage("small.txt");
190190
IndexEntry entry = repo.Index["small.txt"];
191191
Assert.Equal("baae1fb3760a73481ced1fa03dc15614142c19ef", entry.Id.Sha);
192192

@@ -198,7 +198,7 @@ public void CanStageAFileGeneratedFromABlobContentStream()
198198
CopyStream(stream, file);
199199
}
200200

201-
repo.Index.Stage("small.fromblob.txt");
201+
repo.Stage("small.fromblob.txt");
202202
IndexEntry newentry = repo.Index["small.fromblob.txt"];
203203

204204
Assert.Equal("baae1fb3760a73481ced1fa03dc15614142c19ef", newentry.Id.Sha);

LibGit2Sharp.Tests/BranchFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ public void TrackedBranchExistsFromDefaultConfigInEmptyClone()
10511051
Assert.Equal("origin", repo.Head.Remote.Name);
10521052

10531053
Touch(repo.Info.WorkingDirectory, "a.txt", "a");
1054-
repo.Index.Stage("a.txt");
1054+
repo.Stage("a.txt");
10551055
repo.Commit("A file", Constants.Signature, Constants.Signature);
10561056

10571057
Assert.NotNull(repo.Head.Tip);

LibGit2Sharp.Tests/CheckoutFixture.cs

Lines changed: 70 additions & 70 deletions
Large diffs are not rendered by default.

LibGit2Sharp.Tests/CherryPickFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void CanCherryPick(bool fromDetachedHead)
2828

2929
Assert.Equal(CherryPickStatus.CherryPicked, result.Status);
3030
Assert.Equal(cherryPickedCommitId, result.Commit.Id.Sha);
31-
Assert.False(repo.Index.RetrieveStatus().Any());
31+
Assert.False(repo.RetrieveStatus().Any());
3232
Assert.Equal(fromDetachedHead, repo.Info.IsHeadDetached);
3333
Assert.Equal(commitToMerge.Author, result.Commit.Author);
3434
Assert.Equal(Constants.Signature, result.Commit.Committer);
@@ -130,7 +130,7 @@ private Commit AddFileCommitToRepo(IRepository repository, string filename, stri
130130
{
131131
Touch(repository.Info.WorkingDirectory, filename, content);
132132

133-
repository.Index.Stage(filename);
133+
repository.Stage(filename);
134134

135135
return repository.Commit("New commit", Constants.Signature, Constants.Signature);
136136
}

LibGit2Sharp.Tests/CleanFixture.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ public void CanCleanWorkingDirectory()
1313
using (var repo = new Repository(path))
1414
{
1515
// Verify that there are the expected number of entries and untracked files
16-
Assert.Equal(6, repo.Index.RetrieveStatus().Count());
17-
Assert.Equal(1, repo.Index.RetrieveStatus().Untracked.Count());
16+
Assert.Equal(6, repo.RetrieveStatus().Count());
17+
Assert.Equal(1, repo.RetrieveStatus().Untracked.Count());
1818

1919
repo.RemoveUntrackedFiles();
2020

2121
// Verify that there are the expected number of entries and 0 untracked files
22-
Assert.Equal(5, repo.Index.RetrieveStatus().Count());
23-
Assert.Equal(0, repo.Index.RetrieveStatus().Untracked.Count());
22+
Assert.Equal(5, repo.RetrieveStatus().Count());
23+
Assert.Equal(0, repo.RetrieveStatus().Untracked.Count());
2424
}
2525
}
2626

LibGit2Sharp.Tests/CommitFixture.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -534,10 +534,10 @@ public void CanCommitWithSignatureFromConfig()
534534

535535
const string relativeFilepath = "new.txt";
536536
string filePath = Touch(repo.Info.WorkingDirectory, relativeFilepath, "null");
537-
repo.Index.Stage(relativeFilepath);
537+
repo.Stage(relativeFilepath);
538538

539539
File.AppendAllText(filePath, "token\n");
540-
repo.Index.Stage(relativeFilepath);
540+
repo.Stage(relativeFilepath);
541541

542542
Assert.Null(repo.Head[relativeFilepath]);
543543

@@ -594,7 +594,7 @@ public void CommitCleansUpMergeMetadata()
594594

595595
const string relativeFilepath = "new.txt";
596596
Touch(repo.Info.WorkingDirectory, relativeFilepath, "this is a new file");
597-
repo.Index.Stage(relativeFilepath);
597+
repo.Stage(relativeFilepath);
598598

599599
string mergeHeadPath = Touch(repo.Info.Path, "MERGE_HEAD", "abcdefabcdefabcdefabcdefabcdefabcdefabcd");
600600
string mergeMsgPath = Touch(repo.Info.Path, "MERGE_MSG", "This is a dummy merge.\n");
@@ -629,9 +629,9 @@ public void CanCommitALittleBit()
629629

630630
const string relativeFilepath = "new.txt";
631631
string filePath = Touch(repo.Info.WorkingDirectory, relativeFilepath, "null");
632-
repo.Index.Stage(relativeFilepath);
632+
repo.Stage(relativeFilepath);
633633
File.AppendAllText(filePath, "token\n");
634-
repo.Index.Stage(relativeFilepath);
634+
repo.Stage(relativeFilepath);
635635

636636
Assert.Null(repo.Head[relativeFilepath]);
637637

@@ -662,7 +662,7 @@ public void CanCommitALittleBit()
662662
Assert.Equal(commit.Id, repo.Refs.Log(targetCanonicalName).First().To);
663663

664664
File.WriteAllText(filePath, "nulltoken commits!\n");
665-
repo.Index.Stage(relativeFilepath);
665+
repo.Stage(relativeFilepath);
666666

667667
1241 var author2 = new Signature(author.Name, author.Email, author.When.AddSeconds(5));
668668
Commit commit2 = repo.Commit("Are you trying to fork me?", author2, author2);
@@ -683,7 +683,7 @@ public void CanCommitALittleBit()
683683
File.WriteAllText(filePath, "davidfowl commits!\n");
684684

685685
var author3 = new Signature("David Fowler", "david.fowler@microsoft.com", author.When.AddSeconds(2));
686-
repo.Index.Stage(relativeFilepath);
686+
repo.Stage(relativeFilepath);
687687

688688
Commit commit3 = repo.Commit("I'm going to branch you backwards in time!", author3, author3);
689689

@@ -709,7 +709,7 @@ private static void AddCommitToRepo(string path)
709709
{
710710
const string relativeFilepath = "test.txt";
711711
Touch(repo.Info.WorkingDirectory, relativeFilepath, "test\n");
712-
repo.Index.Stage(relativeFilepath);
712+
repo.Stage(relativeFilepath);
713713

714714
var author = new Signature("nulltoken", "emeric.fermas@gmail.com", DateTimeOffset.Parse("Wed, Dec 14 2011 08:29:03 +0100"));
715715
repo.Commit("Initial commit", author, author);
@@ -793,7 +793,7 @@ private static void CreateAndStageANewFile(IRepository repo)
793793
{
794794
string relativeFilepath = string.Format("new-file-{0}.txt", Guid.NewGuid());
795795
Touch(repo.Info.WorkingDirectory, relativeFilepath, "brand new content\n");
796-
repo.Index.Stage(relativeFilepath);
796+
repo.Stage(relativeFilepath);
797797
}
798798

799799
private static void AssertCommitHasBeenAmended(IRepository repo, Commit amendedCommit, Commit originalCommit)
@@ -882,7 +882,7 @@ public void CanCommitOnOrphanedBranch()
882882

883883
const string relativeFilepath = "test.txt";
884884
Touch(repo.Info.WorkingDirectory, relativeFilepath, "test\n");
885-
repo.Index.Stage(relativeFilepath);
885+
repo.Stage(relativeFilepath);
886886

887887
repo.Commit("Initial commit", Constants.Signature, Constants.Signature);
888888
Assert.Equal(1, repo.Head.Commits.Count());
@@ -998,16 +998,16 @@ public void CanNotAmendACommitInAWayThatWouldLeadTheNewCommitToBecomeEmpty()
998998
using (var repo = new Repository(repoPath))
999999
{
10001000
Touch(repo.Info.WorkingDirectory, "test.txt", "test\n");
1001-
repo.Index.Stage("test.txt");
1001+
repo.Stage("test.txt");
10021002

10031003
repo.Commit("Initial commit", Constants.Signature, Constants.Signature);
10041004

10051005
Touch(repo.Info.WorkingDirectory, "new.txt", "content\n");
1006-
repo.Index.Stage("new.txt");
1006+
repo.Stage("new.txt");
10071007

10081008
repo.Commit("One commit", Constants.Signature, Constants.Signature);
10091009

1010-
repo.Index.Remove("new.txt");
1010+
repo.Remove("new.txt");
10111011

10121012
Assert.Throws<EmptyCommitException>(() => repo.Commit("Oops", Constants.Signature, Constants.Signature,
10131013
new CommitOptions { AmendPreviousCommit = true }));

LibGit2Sharp.Tests/ConflictFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ public void CanResolveConflictsByRemovingFromTheIndex(
7777
Assert.NotNull(repo.Index.Conflicts[filename]);
7878
Assert.Equal(0, repo.Index.Conflicts.ResolvedConflicts.Count());
7979

80-
repo.Index.Remove(filename, removeFromWorkdir);
80+
repo.Remove(filename, removeFromWorkdir);
8181

8282
Assert.Null(repo.Index.Conflicts[filename]);
8383
Assert.Equal(count - removedIndexEntries, repo.Index.Count);
8484
Assert.Equal(existsAfterRemove, File.Exists(fullpath));
85-
Assert.Equal(lastStatus, repo.Index.RetrieveStatus(filename));
85+
Assert.Equal(lastStatus, repo.RetrieveStatus(filename));
8686

8787
Assert.Equal(1, repo.Index.Conflicts.ResolvedConflicts.Count());
8888
Assert.NotNull(repo.Index.Conflicts.ResolvedConflicts[filename]);

LibGit2Sharp.Tests/DiffTreeToTargetFixture.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ private static void SetUpSimpleDiffContext(IRepository repo)
1212
{
1313
var fullpath = Touch(repo.Info.WorkingDirectory, "file.txt", "hello\n");
1414

15-
repo.Index.Stage(fullpath);
15+
repo.Stage(fullpath);
1616
repo.Commit("Initial commit", Constants.Signature, Constants.Signature);
1717

1818
File.AppendAllText(fullpath, "world\n");
1919

20-
repo.Index.Stage(fullpath);
20+
repo.Stage(fullpath);
2121

2222
File.AppendAllText(fullpath, "!!!\n");
2323
}
@@ -158,10 +158,10 @@ public void ShowcaseTheDifferenceBetweenTheTwoKindOfComparison()
158158

159159
var fullpath = Path.Combine(repo.Info.WorkingDirectory, "file.txt");
160160
File.Move(fullpath, fullpath + ".bak");
161-
repo.Index.Stage(fullpath);
161+
repo.Stage(fullpath);
162162
File.Move(fullpath + ".bak", fullpath);
163163

164-
FileStatus state = repo.Index.RetrieveStatus("file.txt");
164+
FileStatus state = repo.RetrieveStatus("file.txt");
165165
Assert.Equal(FileStatus.Removed | FileStatus.Untracked, state);
166166

167167
var wrkDirToIdxToTree = repo.Diff.Compare<TreeChanges>(repo.Head.Tip.Tree,
@@ -373,11 +373,11 @@ public void CanCopeWithEndOfFileNewlineChanges()
373373
{
374374
var fullpath = Touch(repo.Info.WorkingDirectory, "file.txt", "a");
375375

376-
repo.Index.Stage("file.txt");
376+
repo.Stage("file.txt");
377377
repo.Commit("Add file without line ending", Constants.Signature, Constants.Signature);
378378

379379
File.AppendAllText(fullpath, "\n");
380-
repo.Index.Stage("file.txt");
380+
repo.Stage("file.txt");
381381

382382
var changes = repo.Diff.Compare<TreeChanges>(repo.Head.Tip.Tree, DiffTargets.Index);
383383
Assert.Equal(1, changes.Modified.Count());

0 commit comments

Comments
 (0)
0