8000 Update libgit2 to 9bbc8f3 · GiTechLab/libgit2sharp@d8a04a4 · GitHub
[go: up one dir, main page]

Skip to content

Commit d8a04a4

Browse files
committed
Update libgit2 to 9bbc8f3
libgit2/libgit2@e0902fb...9bbc8f3
1 parent 964943b commit d8a04a4

40 files changed

+513
-509
lines changed
1010 KB
Binary file not shown.
5.54 MB
Binary file not shown.
-981 KB
Binary file not shown.
-5.44 MB
Binary file not shown.
757 KB
Binary file not shown.
-745 KB
Binary file not shown.

LibGit2Sharp.Tests/BranchFixture.cs

Lines changed: 58 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class BranchFixture : BaseFixture
1818
public void CanCreateBranch(string name)
1919
{
2020
string path = SandboxBareTestRepo();
21-
using (var repo = new Repository(path))
21+
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
2222
{
2323
EnableRefLog(repo);
2424

@@ -39,8 +39,10 @@ public void CanCreateBranch(string name)
3939
Assert.NotNull(repo.Branches.SingleOrDefault(p => p.Name.Normalize() == name));
4040

4141
AssertRefLogEntry(repo, newBranch.CanonicalName,
42+
"branch: Created from " + committish,
43+
null,
4244
newBranch.Tip.Id,
43-
"branch: Created from " + committish);
45+
Constants.Identity, DateTimeOffset.Now);
4446

4547
repo.Branches.Remove(newBranch.Name);
4648
Assert.Null(repo.Branches[name]);
@@ -86,7 +88,7 @@ public void CanCreateAnUnbornBranch()
8688
public void CanCreateBranchUsingAbbreviatedSha()
8789
{
8890
string path = SandboxBareTestRepo();
89-
using (var repo = new Repository(path))
91+
using (var repo = new Repository(path, new RepositoryOptions{ Identity = Constants.Identity }))
9092
{
9193
EnableRefLog(repo);
9294

@@ -98,8 +100,10 @@ public void CanCreateBranchUsingAbbreviatedSha()
98100
Assert.Equal("be3563ae3f795b2b4353bcce3a527ad0a4f7f644", newBranch.Tip.Sha);
99101

100102
AssertRefLogEntry(repo, newBranch.CanonicalName,
103+
"branch: Created from " + committish,
104+
null,
101105
newBranch.Tip.Id,
102-
"branch: Created from " + committish);
106+
Constants.Identity, DateTimeOffset.Now);
103107
}
104108
}
105109

@@ -109,7 +113,7 @@ public void CanCreateBranchUsingAbbreviatedSha()
109113
public void CanCreateBranchFromImplicitHead(string headCommitOrBranchSpec)
110114
{
111115
string path = SandboxStandardTestRepo();
112-
using (var repo = new Repository(path))
116+
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
113117
{
114118
EnableRefLog(repo);
115119

@@ -126,8 +130,10 @@ public void CanCreateBranchFromImplicitHead(string headCommitOrBranchSpec)
126130
Assert.NotNull(repo.Branches.SingleOrDefault(p => p.Name == name));
127131

128132
AssertRefLogEntry(repo, newBranch.CanonicalName,
133+
"branch: Created from " + headCommitOrBranchSpec,
134+
null,
129135
newBranch.Tip.Id,
130-
"branch: Created from " + headCommitOrBranchSpec);
136+
Constants.Identity, DateTimeOffset.Now);
131137
}
132138
}
133139

@@ -137,7 +143,7 @@ public void CanCreateBranchFromImplicitHead(string headCommitOrBranchSpec)
137143
public void CanCreateBranchFromExplicitHead(string headCommitOrBranchSpec)
138144
{
139145
string path = SandboxStandardTestRepo();
140-
using (var repo = new Repository(path))
146+
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
141147
{
142148
EnableRefLog(repo);
143149

@@ -149,16 +155,18 @@ public void CanCreateBranchFromExplicitHead(string headCommitOrBranchSpec)
149155
Assert.Equal("32eab9cb1f450b5fe7ab663462b77d7f4b703344", newBranch.Tip.Sha);
150156

151157
AssertRefLogEntry(repo, newBranch.CanonicalName,
158+
"branch: Created from HEAD",
159+
null,
152160
newBranch.Tip.Id,
153-
"branch: Created from " + headCommitOrBranchSpec);
161+
Constants.Identity, DateTimeOffset.Now);
154162
}
155163
}
156164

157165
[Fact]
158166
public void CanCreateBranchFromCommit()
159167
{
160168
string path = SandboxBareTestRepo();
161-
using (var repo = new Repository(path))
169+
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
162170
{
163171
EnableRefLog(repo);
164172

@@ -169,16 +177,18 @@ public void CanCreateBranchFromCommit()
169177
Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", newBranch.Tip.Sha);
170178

171179
AssertRefLogEntry(repo, newBranch.CanonicalName,
180+
"branch: Created from " + newBranch.Tip.Sha,
181+
null,
172182
newBranch.Tip.Id,
173-
"branch: Created from " + newBranch.Tip.Sha);
183+
Constants.Identity, DateTimeOffset.Now);
174184
}
175185
}
176186

177187
[Fact]
178188
public void CanCreateBranchFromRevparseSpec()
179189
{
180190
string path = SandboxBareTestRepo();
181-
using (var repo = new Repository(path))
191+
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
182192
{
183193
EnableRefLog(repo);
184194

@@ -190,8 +200,10 @@ public void CanCreateBranchFromRevparseSpec()
190200
Assert.Equal("9fd738e8f7967c078dceed8190330fc8648ee56a", newBranch.Tip.Sha);
191201

192202
AssertRefLogEntry(repo, newBranch.CanonicalName,
203+
"branch: Created from " + committish,
204+
null,
193205
newBranch.Tip.Id,
194-
"branch: Created from " + committish);
206+
Constants.Identity, DateTimeOffset.Now);
195207
}
196208
}
197209

@@ -201,7 +213,7 @@ public void CanCreateBranchFromRevparseSpec()
201213
public void CreatingABranchFromATagPeelsToTheCommit(string committish)
202214
{
203215
string path = SandboxBareTestRepo();
204-
using (var repo = new Repository(path))
216+
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
205217
{
206218
EnableRefLog(repo);
207219

@@ -212,8 +224,10 @@ public void CreatingABranchFromATagPeelsToTheCommit(string committish)
212224
Assert.Equal("e90810b8df3e80c413d903f631643c716887138d", newBranch.Tip.Sha);
213225

214226
AssertRefLogEntry(repo, newBranch.CanonicalName,
227+
"branch: Created from " + committish,
228+
null,
215229
newBranch.Tip.Id,
216-
"branch: Created from " + committish);
230+
Constants.Identity, DateTimeOffset.Now);
217231
}
218232
}
219233

@@ -559,7 +573,7 @@ public void CanGetTrackingInformationFromBranchSharingNoHistoryWithItsTrackedBra
559573
{
560574
Branch master = repo.Branches["master"];
561575
const string logMessage = "update target message";
562-
repo.Refs.UpdateTarget("refs/remotes/origin/master", "origin/test", Constants.Signature, logMessage);
576+
repo.Refs.UpdateTarget("refs/remotes/origin/master", "origin/test", logMessage);
563577

564578
Assert.True(master.IsTracking);
565579
Assert.NotNull(master.TrackedBranch);
@@ -964,7 +978,7 @@ public void TwoBranchesPointingAtTheSameCommitAreNotBothCurrent()
964978
public void CanRenameABranch()
965979
{
966980
string path = SandboxBareTestRepo();
967-
using (var repo = new Repository(path))
981+
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
968982
{
969983
EnableRefLog(repo);
970984

@@ -980,8 +994,10 @@ public void CanRenameABranch()
980994
Assert.NotNull(repo.Branches["br3"]);
981995

982996
AssertRefLogEntry(repo, newBranch.CanonicalName,
997+
string.Format("branch: renamed {0} to {1}", br2.CanonicalName, newBranch.CanonicalName),
998+
br2.Tip.Id,
983999
newBranch.Tip.Id,
984-
string.Format("branch: renamed {0} to {1}", br2.CanonicalName, newBranch.CanonicalName));
1000+
Constants.Identity, DateTimeOffset.Now);
9851001
}
9861002
}
9871003

@@ -999,7 +1015,7 @@ public void BlindlyRenamingABranchOverAnExistingOneThrows()
9991015
public void CanRenameABranchWhileOverwritingAnExistingOne()
10001016
{
10011017
string path = SandboxBareTestRepo();
1002-
using (var repo = new Repository(path))
1018+
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
10031019
{
10041020
EnableRefLog(repo);
10051021

@@ -1021,9 +1037,10 @@ public void CanRenameABranchWhileOverwritingAnExistingOne()
10211037
Assert.Equal(br2.Tip, newTest.Tip);
10221038

10231039
AssertRefLogEntry(repo, newBranch.CanonicalName,
1024-
newBranch.Tip.Id,
10251040
string.Format("branch: renamed {0} to {1}", br2.CanonicalName, newBranch.CanonicalName),
1026-
test.Tip.Id);
1041+
br2.Tip.Id,
1042+
newTest.Tip.Id,
1043+
Constants.Identity, DateTimeOffset.Now);
10271044
}
10281045
}
10291046

@@ -1129,32 +1146,42 @@ private static T[] SortedBranches<T>(IEnumerable<Branch> branches, Func<Branch,
11291146
public void CreatingABranchIncludesTheCorrectReflogEntries()
11301147
{
11311148
string path = SandboxStandardTestRepo();
1132-
using (var repo = new Repository(path))
1149+
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
11331150
{
11341151
EnableRefLog(repo);
11351152
var branch = repo.Branches.Add("foo", repo.Head.Tip);
1136-
AssertRefLogEntry(repo, branch.CanonicalName, branch.Tip.Id,
1137-
string.Format("branch: Created from {0}", repo.Head.Tip.Sha));
11381153

1139-
branch = repo.Branches.Add("bar", repo.Head.Tip, null, "BAR");
1140-
AssertRefLogEntry(repo, branch.CanonicalName, repo.Head.Tip.Id, "BAR");
1154+
AssertRefLogEntry(repo, branch.CanonicalName,
1155+
string.Format("branch: Created from {0}", repo.Head.Tip.Sha),
1156+
null, branch.Tip.Id,
1157+
Constants.Identity, DateTimeOffset.Now);
1158+
1159+
branch = repo.Branches.Add("bar", repo.Head.Tip);
1160+
1161+
AssertRefLogEntry(repo, branch.CanonicalName,
1162+
"branch: Created from " + repo.Head.Tip.Sha,
1163+
null, repo.Head.Tip.Id,
1164+
Constants.Identity, DateTimeOffset.Now);
11411165
}
11421166
}
11431167

11441168
[Fact]
11451169
public void RenamingABranchIncludesTheCorrectReflogEntries()
11461170
{
11471171
string path = SandboxStandardTestRepo();
1148-
using (var repo = new Repository(path))
1172+
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
11491173
{
11501174
EnableRefLog(repo);
11511175
var master = repo.Branches["master"];
11521176
var newMaster = repo.Branches.Rename(master, "new-master");
1153-
AssertRefLogEntry(repo, newMaster.CanonicalName, newMaster.Tip.Id,
1154-
"branch: renamed refs/heads/master to refs/heads/new-master");
1155-
1156-
newMaster = repo.Branches.Rename(newMaster, "new-master2", null, "MOVE");
1157-
AssertRefLogEntry(repo, newMaster.CanonicalName, newMaster.Tip.Id, "MOVE");
1177+
AssertRefLogEntry(repo, newMaster.CanonicalName, "branch: renamed refs/heads/master to refs/heads/new-master",
1178+
newMaster.Tip.Id, newMaster.Tip.Id,
1179+
Constants.Identity, DateTimeOffset.Now);
1180+
1181+
var newMaster2 = repo.Branches.Rename(newMaster, "new-master2");
1182+
AssertRefLogEntry(repo, newMaster2.CanonicalName, "branch: renamed refs/heads/new-master to refs/heads/new-master2",
1183+
newMaster.Tip.Id, newMaster2.Tip.Id,
1184+
Constants.Identity, DateTimeOffset.Now);
11581185
}
11591186
}
11601187
}

LibGit2Sharp.Tests/CheckoutFixture.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ public void CheckoutFromDetachedHead(string commitPointer)
779779
public void CheckoutBranchFromDetachedHead()
780780
{
781781
string path = SandboxStandardTestRepo();
782-
using (var repo = new Repository(path))
782+
using (var repo = new Repository(path, new RepositoryOptions{ Identity = Constants.Identity }))
783783
{
784784
// Set the working directory to the current head
785785
ResetAndCleanWorkingDirectory(repo);
@@ -789,12 +789,12 @@ public void CheckoutBranchFromDetachedHead()
789789

790790
Assert.True(repo.Info.IsHeadDetached);
791791

792-
Branch newHead = repo.Checkout(repo.Branches["master"], Constants.Signature);
792+
Branch newHead = repo.Checkout(repo.Branches["master"]);
793793

794794
// Assert reflog entry is created
795-
AssertRefLogEntry(repo, "HEAD", newHead.Tip.Id,
795+
AssertRefLogEntry(repo, "HEAD",
796796
string.Format("checkout: moving from {0} to {1}", initialHead.Tip.Sha, newHead.Name),
797-
initialHead.Tip.Id, Constants.Signature);
797+
initialHead.Tip.Id, newHead.Tip.Id, Constants.Identity, DateTimeOffset.Now);
798798
48DA }
799799
}
800800

@@ -847,7 +847,7 @@ public void CheckoutPreviousCheckedOutBranch()
847847
public void CheckoutCurrentReference()
848848
{
849849
string path = SandboxStandardTestRepo();
850-
using (var repo = new Repository(path))
850+
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
851851
{
852852
Branch master = repo.Branches["master"];
853853
Assert.True(master.IsCurrentRepositoryHead);
@@ -866,8 +866,8 @@ public void CheckoutCurrentReference()
866866
repo.Checkout(master.Tip.Sha);
867867

868868
Assert.True(repo.Info.IsHeadDetached);
869-
AssertRefLogEntry(repo, "HEAD", master.Tip.Id,
870-
string.Format("checkout: moving from master to {0}", master.Tip.Sha), master.Tip.Id);
869+
AssertRefLogEntry(repo, "HEAD",
870+
string.Format("checkout: moving from master to {0}", master.Tip.Sha), master.Tip.Id, master.Tip.Id, Constants.Identity, DateTimeOffset.Now);
871871

872872
// Checkout detached "HEAD" => nothing should happen
873873
reflogEntriesCount = repo.Refs.Log(repo.Refs.Head).Count();

LibGit2Sharp.Tests/CommitFixture.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,9 @@ public void CanCommitALittleBit()
661661
{
662662
string repoPath = InitNewRepository();
663663

664-
using (var repo = new Repository(repoPath))
664+
var identity = Constants.Identity;
665+
666+
using (var repo = new Repository(repoPath, new RepositoryOptions { Identity = identity }))
665667
{
666668
string dir = repo.Info.Path;
667669
Assert.True(Path.IsPathRooted(dir));
@@ -691,7 +693,13 @@ public void CanCommitALittleBit()
691693
// Assert a reflog entry is created on HEAD
692694
Assert.Equal(1, repo.Refs.Log("HEAD").Count());
693695
var reflogEntry = repo.Refs.Log("HEAD").First();
694-
Assert.Equal(author, reflogEntry.Committer);
696+
697+
Assert.Equal(identity.Name, reflogEntry.Committer.Name);
698+
Assert.Equal(identity.Email, reflogEntry.Committer.Email);
699+
700+
var now = DateTimeOffset.Now;
701+
Assert.InRange(reflogEntry.Committer.When, now - TimeSpan.FromSeconds(1), now);
702+
695703
Assert.Equal(commit.Id, reflogEntry.To);
696704
Assert.Equal(ObjectId.Zero, reflogEntry.From);
697705
Assert.Equal(string.Format("commit (initial): {0}", shortMessage), reflogEntry.Message);
@@ -805,7 +813,7 @@ public void CanAmendARootCommit()
805813
public void CanAmendACommitWithMoreThanOneParent()
806814
{
807815
string path = SandboxStandardTestRepo();
808-
using (var repo = new Repository(path))
816+
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
809817
{
810818
var mergedCommit = repo.Lookup<Commit>("be3563a");
811819
Assert.NotNull(mergedCommit);
@@ -822,10 +830,10 @@ public void CanAmendACommitWithMoreThanOneParent()
822830
AssertCommitHasBeenAmended(repo, amendedCommit, mergedCommit);
823831

824832
AssertRefLogEntry(repo, "HEAD",
825-
amendedCommit.Id,
826833
string.Format("commit (amend): {0}", commitMessage),
827834
mergedCommit.Id,
828-
amendedCommit.Committer);
835+
amendedCommit.Id,
836+
Constants.Identity, DateTimeOffset.Now);
829837
}
830838
}
831839

LibGit2Sharp.Tests/PushFixture.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void CanForcePush()
9898

9999
// Create a new repository
100100
string localRepoPath = InitNewRepository();
101-
using (var localRepo = new Repository(localRepoPath))
101+
using (var localRepo = new Repository(localRepoPath, new RepositoryOptions { Identity = Constants.Identity }))
102102
{
103103
// Add a commit
104104
Commit first = AddCommitToRepo(localRepo);
@@ -129,8 +129,9 @@ public void CanForcePush()
129129
AssertRemoteHeadTipEquals(localRepo, second.Sha);
130130

131131
AssertRefLogEntry(localRepo, "refs/remotes/origin/master",
132-
localRepo.Head.Tip.Id, "update by push",
133-
oldId);
132+
"update by push",
133+
oldId, localRepo.Head.Tip.Id,
134+
Constants.Identity, DateTimeOffset.Now);
134135
}
135136
}
136137

0 commit comments

Comments
 (0)
0