e0902fb...9bbc8f3
This commit is contained in:
nulltoken 2015-03-16 20:50:16 +01:00
Родитель 964943bf9b
Коммит d8a04a467b
40 изменённых файлов: 514 добавлений и 510 удалений

Двоичные данные
Lib/NativeBinaries/amd64/git2-9bbc8f3.dll Normal file

Двоичный файл не отображается.

Двоичные данные
Lib/NativeBinaries/amd64/git2-9bbc8f3.pdb Normal file

Двоичный файл не отображается.

Двоичные данные
Lib/NativeBinaries/amd64/git2-e0902fb.dll

Двоичный файл не отображается.

Двоичные данные
Lib/NativeBinaries/amd64/git2-e0902fb.pdb

Двоичный файл не отображается.

Двоичные данные
Lib/NativeBinaries/x86/git2-9bbc8f3.dll Normal file

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичные данные
Lib/NativeBinaries/x86/git2-e0902fb.dll

Двоичный файл не отображается.

Просмотреть файл

@ -18,7 +18,7 @@ namespace LibGit2Sharp.Tests
public void CanCreateBranch(string name)
{
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
@ -39,8 +39,10 @@ namespace LibGit2Sharp.Tests
Assert.NotNull(repo.Branches.SingleOrDefault(p => p.Name.Normalize() == name));
AssertRefLogEntry(repo, newBranch.CanonicalName,
"branch: Created from " + committish,
null,
newBranch.Tip.Id,
"branch: Created from " + committish);
Constants.Identity, DateTimeOffset.Now);
repo.Branches.Remove(newBranch.Name);
Assert.Null(repo.Branches[name]);
@ -86,7 +88,7 @@ namespace LibGit2Sharp.Tests
public void CanCreateBranchUsingAbbreviatedSha()
{
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
using (var repo = new Repository(path, new RepositoryOptions{ Identity = Constants.Identity }))
{
EnableRefLog(repo);
@ -98,8 +100,10 @@ namespace LibGit2Sharp.Tests
Assert.Equal("be3563ae3f795b2b4353bcce3a527ad0a4f7f644", newBranch.Tip.Sha);
AssertRefLogEntry(repo, newBranch.CanonicalName,
"branch: Created from " + committish,
null,
newBranch.Tip.Id,
"branch: Created from " + committish);
Constants.Identity, DateTimeOffset.Now);
}
}
@ -109,7 +113,7 @@ namespace LibGit2Sharp.Tests
public void CanCreateBranchFromImplicitHead(string headCommitOrBranchSpec)
{
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
@ -126,8 +130,10 @@ namespace LibGit2Sharp.Tests
Assert.NotNull(repo.Branches.SingleOrDefault(p => p.Name == name));
AssertRefLogEntry(repo, newBranch.CanonicalName,
"branch: Created from " + headCommitOrBranchSpec,
null,
newBranch.Tip.Id,
"branch: Created from " + headCommitOrBranchSpec);
Constants.Identity, DateTimeOffset.Now);
}
}
@ -137,7 +143,7 @@ namespace LibGit2Sharp.Tests
public void CanCreateBranchFromExplicitHead(string headCommitOrBranchSpec)
{
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
@ -149,8 +155,10 @@ namespace LibGit2Sharp.Tests
Assert.Equal("32eab9cb1f450b5fe7ab663462b77d7f4b703344", newBranch.Tip.Sha);
AssertRefLogEntry(repo, newBranch.CanonicalName,
"branch: Created from HEAD",
null,
newBranch.Tip.Id,
"branch: Created from " + headCommitOrBranchSpec);
Constants.Identity, DateTimeOffset.Now);
}
}
@ -158,7 +166,7 @@ namespace LibGit2Sharp.Tests
public void CanCreateBranchFromCommit()
{
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
@ -169,8 +177,10 @@ namespace LibGit2Sharp.Tests
Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", newBranch.Tip.Sha);
AssertRefLogEntry(repo, newBranch.CanonicalName,
"branch: Created from " + newBranch.Tip.Sha,
null,
newBranch.Tip.Id,
"branch: Created from " + newBranch.Tip.Sha);
Constants.Identity, DateTimeOffset.Now);
}
}
@ -178,7 +188,7 @@ namespace LibGit2Sharp.Tests
public void CanCreateBranchFromRevparseSpec()
{
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
@ -190,8 +200,10 @@ namespace LibGit2Sharp.Tests
Assert.Equal("9fd738e8f7967c078dceed8190330fc8648ee56a", newBranch.Tip.Sha);
AssertRefLogEntry(repo, newBranch.CanonicalName,
"branch: Created from " + committish,
null,
newBranch.Tip.Id,
"branch: Created from " + committish);
Constants.Identity, DateTimeOffset.Now);
}
}
@ -201,7 +213,7 @@ namespace LibGit2Sharp.Tests
public void CreatingABranchFromATagPeelsToTheCommit(string committish)
{
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
@ -212,8 +224,10 @@ namespace LibGit2Sharp.Tests
Assert.Equal("e90810b8df3e80c413d903f631643c716887138d", newBranch.Tip.Sha);
AssertRefLogEntry(repo, newBranch.CanonicalName,
"branch: Created from " + committish,
null,
newBranch.Tip.Id,
"branch: Created from " + committish);
Constants.Identity, DateTimeOffset.Now);
}
}
@ -559,7 +573,7 @@ namespace LibGit2Sharp.Tests
{
Branch master = repo.Branches["master"];
const string logMessage = "update target message";
repo.Refs.UpdateTarget("refs/remotes/origin/master", "origin/test", Constants.Signature, logMessage);
repo.Refs.UpdateTarget("refs/remotes/origin/master", "origin/test", logMessage);
Assert.True(master.IsTracking);
Assert.NotNull(master.TrackedBranch);
@ -964,7 +978,7 @@ namespace LibGit2Sharp.Tests
public void CanRenameABranch()
{
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
@ -980,8 +994,10 @@ namespace LibGit2Sharp.Tests
Assert.NotNull(repo.Branches["br3"]);
AssertRefLogEntry(repo, newBranch.CanonicalName,
string.Format("branch: renamed {0} to {1}", br2.CanonicalName, newBranch.CanonicalName),
br2.Tip.Id,
newBranch.Tip.Id,
string.Format("branch: renamed {0} to {1}", br2.CanonicalName, newBranch.CanonicalName));
Constants.Identity, DateTimeOffset.Now);
}
}
@ -999,7 +1015,7 @@ namespace LibGit2Sharp.Tests
public void CanRenameABranchWhileOverwritingAnExistingOne()
{
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
@ -1021,9 +1037,10 @@ namespace LibGit2Sharp.Tests
Assert.Equal(br2.Tip, newTest.Tip);
AssertRefLogEntry(repo, newBranch.CanonicalName,
newBranch.Tip.Id,
string.Format("branch: renamed {0} to {1}", br2.CanonicalName, newBranch.CanonicalName),
test.Tip.Id);
br2.Tip.Id,
newTest.Tip.Id,
Constants.Identity, DateTimeOffset.Now);
}
}
@ -1129,15 +1146,22 @@ namespace LibGit2Sharp.Tests
public void CreatingABranchIncludesTheCorrectReflogEntries()
{
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
var branch = repo.Branches.Add("foo", repo.Head.Tip);
AssertRefLogEntry(repo, branch.CanonicalName, branch.Tip.Id,
string.Format("branch: Created from {0}", repo.Head.Tip.Sha));
branch = repo.Branches.Add("bar", repo.Head.Tip, null, "BAR");
AssertRefLogEntry(repo, branch.CanonicalName, repo.Head.Tip.Id, "BAR");
AssertRefLogEntry(repo, branch.CanonicalName,
string.Format("branch: Created from {0}", repo.Head.Tip.Sha),
null, branch.Tip.Id,
Constants.Identity, DateTimeOffset.Now);
branch = repo.Branches.Add("bar", repo.Head.Tip);
AssertRefLogEntry(repo, branch.CanonicalName,
"branch: Created from " + repo.Head.Tip.Sha,
null, repo.Head.Tip.Id,
Constants.Identity, DateTimeOffset.Now);
}
}
@ -1145,16 +1169,19 @@ namespace LibGit2Sharp.Tests
public void RenamingABranchIncludesTheCorrectReflogEntries()
{
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
var master = repo.Branches["master"];
var newMaster = repo.Branches.Rename(master, "new-master");
AssertRefLogEntry(repo, newMaster.CanonicalName, newMaster.Tip.Id,
"branch: renamed refs/heads/master to refs/heads/new-master");
AssertRefLogEntry(repo, newMaster.CanonicalName, "branch: renamed refs/heads/master to refs/heads/new-master",
newMaster.Tip.Id, newMaster.Tip.Id,
Constants.Identity, DateTimeOffset.Now);
newMaster = repo.Branches.Rename(newMaster, "new-master2", null, "MOVE");
AssertRefLogEntry(repo, newMaster.CanonicalName, newMaster.Tip.Id, "MOVE");
var newMaster2 = repo.Branches.Rename(newMaster, "new-master2");
AssertRefLogEntry(repo, newMaster2.CanonicalName, "branch: renamed refs/heads/new-master to refs/heads/new-master2",
newMaster.Tip.Id, newMaster2.Tip.Id,
Constants.Identity, DateTimeOffset.Now);
}
}
}

Просмотреть файл

@ -779,7 +779,7 @@ namespace LibGit2Sharp.Tests
public void CheckoutBranchFromDetachedHead()
{
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
using (var repo = new Repository(path, new RepositoryOptions{ Identity = Constants.Identity }))
{
// Set the working directory to the current head
ResetAndCleanWorkingDirectory(repo);
@ -789,12 +789,12 @@ namespace LibGit2Sharp.Tests
Assert.True(repo.Info.IsHeadDetached);
Branch newHead = repo.Checkout(repo.Branches["master"], Constants.Signature);
Branch newHead = repo.Checkout(repo.Branches["master"]);
// Assert reflog entry is created
AssertRefLogEntry(repo, "HEAD", newHead.Tip.Id,
AssertRefLogEntry(repo, "HEAD",
string.Format("checkout: moving from {0} to {1}", initialHead.Tip.Sha, newHead.Name),
initialHead.Tip.Id, Constants.Signature);
initialHead.Tip.Id, newHead.Tip.Id, Constants.Identity, DateTimeOffset.Now);
}
}
@ -847,7 +847,7 @@ namespace LibGit2Sharp.Tests
public void CheckoutCurrentReference()
{
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
Branch master = repo.Branches["master"];
Assert.True(master.IsCurrentRepositoryHead);
@ -866,8 +866,8 @@ namespace LibGit2Sharp.Tests
repo.Checkout(master.Tip.Sha);
Assert.True(repo.Info.IsHeadDetached);
AssertRefLogEntry(repo, "HEAD", master.Tip.Id,
string.Format("checkout: moving from master to {0}", master.Tip.Sha), master.Tip.Id);
AssertRefLogEntry(repo, "HEAD",
string.Format("checkout: moving from master to {0}", master.Tip.Sha), master.Tip.Id, master.Tip.Id, Constants.Identity, DateTimeOffset.Now);
// Checkout detached "HEAD" => nothing should happen
reflogEntriesCount = repo.Refs.Log(repo.Refs.Head).Count();

Просмотреть файл

@ -661,7 +661,9 @@ namespace LibGit2Sharp.Tests
{
string repoPath = InitNewRepository();
using (var repo = new Repository(repoPath))
var identity = Constants.Identity;
using (var repo = new Repository(repoPath, new RepositoryOptions { Identity = identity }))
{
string dir = repo.Info.Path;
Assert.True(Path.IsPathRooted(dir));
@ -691,7 +693,13 @@ namespace LibGit2Sharp.Tests
// Assert a reflog entry is created on HEAD
Assert.Equal(1, repo.Refs.Log("HEAD").Count());
var reflogEntry = repo.Refs.Log("HEAD").First();
Assert.Equal(author, reflogEntry.Committer);
Assert.Equal(identity.Name, reflogEntry.Committer.Name);
Assert.Equal(identity.Email, reflogEntry.Committer.Email);
var now = DateTimeOffset.Now;
Assert.InRange(reflogEntry.Committer.When, now - TimeSpan.FromSeconds(1), now);
Assert.Equal(commit.Id, reflogEntry.To);
Assert.Equal(ObjectId.Zero, reflogEntry.From);
Assert.Equal(string.Format("commit (initial): {0}", shortMessage), reflogEntry.Message);
@ -805,7 +813,7 @@ namespace LibGit2Sharp.Tests
public void CanAmendACommitWithMoreThanOneParent()
{
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
var mergedCommit = repo.Lookup<Commit>("be3563a");
Assert.NotNull(mergedCommit);
@ -822,10 +830,10 @@ namespace LibGit2Sharp.Tests
AssertCommitHasBeenAmended(repo, amendedCommit, mergedCommit);
AssertRefLogEntry(repo, "HEAD",
amendedCommit.Id,
string.Format("commit (amend): {0}", commitMessage),
mergedCommit.Id,
amendedCommit.Committer);
amendedCommit.Id,
Constants.Identity, DateTimeOffset.Now);
}
}

Просмотреть файл

@ -98,7 +98,7 @@ namespace LibGit2Sharp.Tests
// Create a new repository
string localRepoPath = InitNewRepository();
using (var localRepo = new Repository(localRepoPath))
using (var localRepo = new Repository(localRepoPath, new RepositoryOptions { Identity = Constants.Identity }))
{
// Add a commit
Commit first = AddCommitToRepo(localRepo);
@ -129,8 +129,9 @@ namespace LibGit2Sharp.Tests
AssertRemoteHeadTipEquals(localRepo, second.Sha);
AssertRefLogEntry(localRepo, "refs/remotes/origin/master",
localRepo.Head.Tip.Id, "update by push",
oldId);
"update by push",
oldId, localRepo.Head.Tip.Id,
Constants.Identity, DateTimeOffset.Now);
}
}

Просмотреть файл

@ -22,7 +22,7 @@ namespace LibGit2Sharp.Tests
const string name = "refs/heads/unit_test";
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
@ -35,8 +35,9 @@ namespace LibGit2Sharp.Tests
Assert.NotNull(repo.Refs[name]);
AssertRefLogEntry(repo, name,
newRef.ResolveToDirectReference().Target.Id,
"branch: Created from be3563ae3f795b2b4353bcce3a527ad0a4f7f644");
"branch: Created from be3563ae3f795b2b4353bcce3a527ad0a4f7f644",
null, newRef.ResolveToDirectReference().Target.Id, Constants.Identity, DateTimeOffset.Now
);
}
}
@ -47,11 +48,11 @@ namespace LibGit2Sharp.Tests
const string logMessage = "Create new ref";
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
var newRef = (DirectReference)repo.Refs.Add(name, "master^1^2", Constants.Signature, logMessage);
var newRef = (DirectReference)repo.Refs.Add(name, "master^1^2", logMessage);
Assert.NotNull(newRef);
Assert.Equal(name, newRef.CanonicalName);
Assert.NotNull(newRef.Target);
@ -59,9 +60,9 @@ namespace LibGit2Sharp.Tests
Assert.Equal(newRef.Target.Sha, newRef.TargetIdentifier);
Assert.NotNull(repo.Refs[name]);
AssertRefLogEntry(repo, name,
newRef.ResolveToDirectReference().Target.Id,
logMessage, committer: Constants.Signature);
AssertRefLogEntry(repo, name, logMessage,
null, newRef.ResolveToDirectReference().Target.Id,
Constants.Identity, DateTimeOffset.Now);
}
}
@ -106,7 +107,7 @@ namespace LibGit2Sharp.Tests
var targetRef = repo.Refs[target];
var newRef = repo.Refs.Add(name, targetRef, Constants.Signature, logMessage);
var newRef = repo.Refs.Add(name, targetRef, logMessage);
AssertSymbolicRef(newRef, repo, target, name);
Assert.Empty(repo.Refs.Log(newRef));
@ -151,12 +152,12 @@ namespace LibGit2Sharp.Tests
const string logMessage = "Create new ref";
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
var oldRef = repo.Refs[name];
var newRef = (DirectReference)repo.Refs.Add(name, target, Constants.Signature, logMessage, true);
var newRef = (DirectReference)repo.Refs.Add(name, target, logMessage, true);
Assert.NotNull(newRef);
Assert.Equal(name, newRef.CanonicalName);
Assert.NotNull(newRef.Target);
@ -164,9 +165,9 @@ namespace LibGit2Sharp.Tests
Assert.Equal(target, ((DirectReference)repo.Refs[name]).Target.Sha);
AssertRefLogEntry(repo, name,
newRef.ResolveToDirectReference().Target.Id,
logMessage, ((DirectReference)oldRef).Target.Id,
Constants.Signature);
newRef.ResolveToDirectReference().Target.Id,
Constants.Identity, DateTimeOffset.Now);
}
}
@ -178,22 +179,22 @@ namespace LibGit2Sharp.Tests
const string logMessage = "Create new ref";
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
var oldtarget = repo.Refs[name].ResolveToDirectReference().Target.Id;
var newRef = (SymbolicReference)repo.Refs.Add(name, target, Constants.Signature, logMessage, true);
var newRef = (SymbolicReference)repo.Refs.Add(name, target, logMessage, true);
Assert.NotNull(newRef);
Assert.Equal(name, newRef.CanonicalName);
Assert.NotNull(newRef.Target);
Assert.Equal("a4a7dce85cf63874e984719f4fdd239f5145052f", newRef.ResolveToDirectReference().Target.Sha);
Assert.Equal(target, ((SymbolicReference)repo.Refs.Head).Target.CanonicalName);
AssertRefLogEntry(repo, name,
AssertRefLogEntry(repo, name, logMessage,
oldtarget,
newRef.ResolveToDirectReference().Target.Id,
logMessage, oldtarget,
Constants.Signature);
Constants.Identity, DateTimeOffset.Now);
}
}
@ -498,36 +499,35 @@ namespace LibGit2Sharp.Tests
public void CanUpdateHeadWithEitherAnObjectIdOrAReference()
{
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
Reference head = repo.Refs.Head;
Reference test = repo.Refs["refs/heads/test"];
Reference direct = repo.Refs.UpdateTarget(head, new ObjectId(test.TargetIdentifier), Constants.Signature, null);
Reference direct = repo.Refs.UpdateTarget(head, new ObjectId(test.TargetIdentifier), null);
Assert.True((direct is DirectReference));
Assert.Equal(test.TargetIdentifier, direct.TargetIdentifier);
Assert.Equal(repo.Refs.Head, direct);
var testTargetId = test.ResolveToDirectReference().Target.Id;
AssertRefLogEntry(repo, "HEAD",
testTargetId,
null,
AssertRefLogEntry(repo, "HEAD", null,
head.ResolveToDirectReference().Target.Id,
Constants.Signature);
testTargetId,
Constants.Identity, DateTimeOffset.Now);
const string secondLogMessage = "second update target message";
Reference symref = repo.Refs.UpdateTarget(head, test, Constants.Signature, secondLogMessage);
Reference symref = repo.Refs.UpdateTarget(head, test, secondLogMessage);
Assert.True((symref is SymbolicReference));
Assert.Equal(test.CanonicalName, symref.TargetIdentifier);
Assert.Equal(repo.Refs.Head, symref);
AssertRefLogEntry(repo, "HEAD",
testTargetId,
secondLogMessage,
testTargetId,
Constants.Signature);
testTargetId,
Constants.Identity, DateTimeOffset.Now);
}
}
@ -535,7 +535,7 @@ namespace LibGit2Sharp.Tests
public void CanUpdateTargetOfADirectReferenceWithARevparseSpec()
{
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
@ -545,7 +545,7 @@ namespace LibGit2Sharp.Tests
var @from = master.Target.Id;
const string logMessage = "update target message";
var newRef = (DirectReference)repo.Refs.UpdateTarget(master, "master^1^2", Constants.Signature, logMessage);
var newRef = (DirectReference)repo.Refs.UpdateTarget(master, "master^1^2", logMessage);
Assert.NotNull(newRef);
Assert.Equal(name, newRef.CanonicalName);
Assert.NotNull(newRef.Target);
@ -554,10 +554,10 @@ namespace LibGit2Sharp.Tests
Assert.NotNull(repo.Refs[name]);
AssertRefLogEntry(repo, name,
newRef.Target.Id,
logMessage,
@from,
Constants.Signature);
newRef.Target.Id,
Constants.Identity, DateTimeOffset.Now);
}
}
@ -648,7 +648,7 @@ namespace LibGit2Sharp.Tests
public void CanRenameAReferenceToADifferentReferenceHierarchy()
{
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
const string oldName = "refs/tags/test";
const string newName = "refs/atic/tagtest";
@ -662,8 +662,11 @@ namespace LibGit2Sharp.Tests
Assert.Equal(newName, renamed.CanonicalName);
Assert.Equal(oldId, renamed.ResolveToDirectReference().Target.Id);
AssertRefLogEntry(repo, newName, renamed.ResolveToDirectReference().Target.Id,
string.Format("reference: renamed {0} to {1}", oldName, newName));
AssertRefLogEntry(repo, newName,
string.Format("reference: renamed {0} to {1}", oldName, newName),
oldId,
renamed.ResolveToDirectReference().Target.Id,
Constants.Identity, DateTimeOffset.Now);
}
}

Просмотреть файл

@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
using System.Linq;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
@ -56,7 +57,9 @@ namespace LibGit2Sharp.Tests
{
string repoPath = InitNewRepository();
using (var repo = new Repository(repoPath))
var identity = Constants.Identity;
using (var repo = new Repository(repoPath, new RepositoryOptions{ Identity = identity }))
{
// setup refs as HEAD => unit_test => master
var newRef = repo.Refs.Add("refs/heads/unit_test", "refs/heads/master");
@ -74,14 +77,26 @@ namespace LibGit2Sharp.Tests
// Assert a reflog entry is created on HEAD
Assert.Equal(1, repo.Refs.Log("HEAD").Count());
var reflogEntry = repo.Refs.Log("HEAD").First();
Assert.Equal(author, reflogEntry.Committer);
Assert.Equal(identity.Name, reflogEntry.Committer.Name);
Assert.Equal(identity.Email, reflogEntry.Committer.Email);
var now = DateTimeOffset.Now;
Assert.InRange(reflogEntry.Committer.When, now - TimeSpan.FromSeconds(1), now);
Assert.Equal(commit.Id, reflogEntry.To);
Assert.Equal(ObjectId.Zero, reflogEntry.From);
// Assert the same reflog entry is created on refs/heads/master
Assert.Equal(1, repo.Refs.Log("refs/heads/master").Count());
reflogEntry = repo.Refs.Log("HEAD").First();
Assert.Equal(author, reflogEntry.Committer);
Assert.Equal(identity.Name, reflogEntry.Committer.Name);
Assert.Equal(identity.Email, reflogEntry.Committer.Email);
now = DateTimeOffset.Now;
Assert.InRange(reflogEntry.Committer.When, now - TimeSpan.FromSeconds(1), now);
Assert.Equal(commit.Id, reflogEntry.To);
Assert.Equal(ObjectId.Zero, reflogEntry.From);
@ -116,7 +131,9 @@ namespace LibGit2Sharp.Tests
{
string repoPath = SandboxStandardTestRepo();
using (var repo = new Repository(repoPath))
var identity = Constants.Identity;
using (var repo = new Repository(repoPath, new RepositoryOptions { Identity = identity }))
{
Assert.False(repo.Info.IsHeadDetached);
@ -134,7 +151,13 @@ namespace LibGit2Sharp.Tests
// Assert a reflog entry is created on HEAD
var reflogEntry = repo.Refs.Log("HEAD").First();
Assert.Equal(author, reflogEntry.Committer);
Assert.Equal(identity.Name, reflogEntry.Committer.Name);
Assert.Equal(identity.Email, reflogEntry.Committer.Email);
var now = DateTimeOffset.Now;
Assert.InRange(reflogEntry.Committer.When, now - TimeSpan.FromSeconds(1), now);
Assert.Equal(commit.Id, reflogEntry.To);
Assert.Equal(string.Format("commit: {0}", commitMessage), repo.Refs.Log("HEAD").First().Message);
}
@ -174,7 +197,7 @@ namespace LibGit2Sharp.Tests
public void UnsignedMethodsWriteCorrectlyToTheReflog()
{
var repoPath = InitNewRepository(true);
using (var repo = new Repository(repoPath))
using (var repo = new Repository(repoPath, new RepositoryOptions{ Identity = Constants.Identity }))
{
EnableRefLog(repo);
@ -184,7 +207,7 @@ namespace LibGit2Sharp.Tests
tree, Enumerable.Empty<Commit>(), false);
var direct = repo.Refs.Add("refs/heads/direct", commit.Id);
AssertRefLogEntry(repo, direct.CanonicalName, direct.ResolveToDirectReference().Target.Id, null);
AssertRefLogEntry(repo, direct.CanonicalName, null, null, direct.ResolveToDirectReference().Target.Id, Constants.Identity, DateTimeOffset.Now);
var symbolic = repo.Refs.Add("refs/heads/symbolic", direct);
Assert.Empty(repo.Refs.Log(symbolic)); // creation of symbolic refs doesn't update the reflog

Просмотреть файл

@ -94,7 +94,7 @@ namespace LibGit2Sharp.Tests
{
string repoPath = InitNewRepository();
using (var repo = new Repository(repoPath))
using (var repo = new Repository(repoPath, new RepositoryOptions{ Identity = Constants.Identity }))
{
FeedTheRepository(repo);
@ -118,38 +118,40 @@ namespace LibGit2Sharp.Tests
Assert.Equal(FileStatus.Staged, repo.RetrieveStatus("a.txt"));
AssertRefLogEntry(repo, "HEAD",
tag.Target.Id,
string.Format("reset: moving to {0}", tag.Target.Sha),
oldHeadId);
oldHeadId,
tag.Target.Id,
Constants.Identity, DateTimeOffset.Now);
if (!shouldHeadBeDetached)
{
AssertRefLogEntry(repo, branch.CanonicalName,
tag.Target.Id,
string.Format("reset: moving to {0}", tag.Target.Sha),
oldHeadId);
oldHeadId,
tag.Target.Id,
Constants.Identity, DateTimeOffset.Now);
}
/* Reset --soft the Head to a commit through its sha */
repo.Reset(ResetMode.Soft, branch.Tip.Sha, Constants.Signature, "FOO");
repo.Reset(ResetMode.Soft, branch.Tip.Sha);
Assert.Equal(expectedHeadName, repo.Head.Name);
Assert.Equal(branch.Tip.Sha, repo.Head.Tip.Sha);
Assert.Equal(FileStatus.Unaltered, repo.RetrieveStatus("a.txt"));
AssertRefLogEntry(repo, "HEAD",
branch.Tip.Id,
"FOO",
string.Format("reset: moving to {0}", branch.Tip.Sha),
tag.Target.Id,
Constants.Signature);
branch.Tip.Id,
Constants.Identity, DateTimeOffset.Now);
if (!shouldHeadBeDetached)
{
AssertRefLogEntry(repo, branch.CanonicalName,
branch.Tip.Id,
"FOO",
string.Format("reset: moving to {0}", branch.Tip.Sha),
tag.Target.Id,
Constants.Signature);
branch.Tip.Id,
Constants.Identity, DateTimeOffset.Now);
}
}
}
@ -178,7 +180,7 @@ namespace LibGit2Sharp.Tests
{
string repoPath = InitNewRepository();
using (var repo = new Repository(repoPath))
using (var repo = new Repository(repoPath, new RepositoryOptions { Identity = Constants.Identity }))
{
FeedTheRepository(repo);
@ -191,14 +193,16 @@ namespace LibGit2Sharp.Tests
Assert.Equal(FileStatus.Modified, repo.RetrieveStatus("a.txt"));
AssertRefLogEntry(repo, "HEAD",
tag.Target.Id,
string.Format("reset: moving to {0}", tag.Target.Sha),
oldHeadId);
oldHeadId,
tag.Target.Id,
Constants.Identity, DateTimeOffset.Now);
AssertRefLogEntry(repo, "refs/heads/mybranch",
tag.Target.Id,
string.Format("reset: moving to {0}", tag.Target.Sha),
oldHeadId);
oldHeadId,
tag.Target.Id,
Constants.Identity, DateTimeOffset.Now);
}
}

Просмотреть файл

@ -405,8 +405,8 @@ namespace LibGit2Sharp.Tests.TestHelpers
}
protected static void AssertRefLogEntry(IRepository repo, string canonicalName,
ObjectId to, string message, ObjectId @from = null,
Signature committer = null)
string message, ObjectId @from, ObjectId to,
Identity committer, DateTimeOffset when)
{
var reflogEntry = repo.Refs.Log(canonicalName).First();
@ -414,9 +414,8 @@ namespace LibGit2Sharp.Tests.TestHelpers
Assert.Equal(message, reflogEntry.Message);
Assert.Equal(@from ?? ObjectId.Zero, reflogEntry.From);
committer = committer ?? repo.Config.BuildSignature(DateTimeOffset.Now);
Assert.Equal(committer.Email, reflogEntry.Committer.Email);
Assert.InRange(reflogEntry.Committer.When, committer.When - TimeSpan.FromSeconds(5), committer.When);
Assert.InRange(reflogEntry.Committer.When, when - TimeSpan.FromSeconds(5), when);
}
protected static void EnableRefLog(IRepository repository, bool enable = true)

Просмотреть файл

@ -110,39 +110,20 @@ namespace LibGit2Sharp
/// Create a new local branch with the specified name
/// </summary>
/// <param name="name">The name of the branch.</param>
/// <param name="commit">The target commit.</param>
/// <param name="signature">Identity used for updating the reflog</param>
/// <param name="logMessage">Message added to the reflog. If null, the default is "branch: Created from [sha]".</param>
/// <param name="committish">Revparse spec for the target commit.</param>
/// <param name="allowOverwrite">True to allow silent overwriting a potentially existing branch, false otherwise.</param>
/// <returns>A new <see cref="Branch"/>.</returns>
public virtual Branch Add(string name, Commit commit, Signature signature, string logMessage = null, bool allowOverwrite = false)
public virtual Branch Add(string name, string committish, bool allowOverwrite = false)
{
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(commit, "commit");
Ensure.ArgumentNotNullOrEmptyString(committish, "committish");
if (logMessage == null)
{
logMessage = "branch: Created from " + commit.Id;
}
using (Proxy.git_branch_create(repo.Handle, name, commit.Id, allowOverwrite, signature.OrDefault(repo.Config), logMessage)) {}
using (Proxy.git_branch_create_from_annotated(repo.Handle, name, committish, allowOverwrite)) { }
var branch = this[ShortToLocalName(name)];
return branch;
}
/// <summary>
/// Create a new local branch with the specified name, using the default reflog message
/// </summary>
/// <param name="name">The name of the branch.</param>
/// <param name="commit">The target commit.</param>
/// <param name="allowOverwrite">True to allow silent overwriting a potentially existing branch, false otherwise.</param>
/// <returns>A new <see cref="Branch"/>.</returns>
public virtual Branch Add(string name, Commit commit, bool allowOverwrite = false)
{
return Add(name, commit, null, null, allowOverwrite);
}
/// <summary>
/// Deletes the specified branch.
/// </summary>
@ -162,11 +143,9 @@ namespace LibGit2Sharp
/// </summary>
/// <param name="branch">The current local branch.</param>
/// <param name="newName">The new name the existing branch should bear.</param>
/// <param name="signature">Identity used for updating the reflog</param>
/// <param name="logMessage">Message added to the reflog. If null, the default is "branch: renamed [old] to [new]".</param>
/// <param name="allowOverwrite">True to allow silent overwriting a potentially existing branch, false otherwise.</param>
/// <returns>A new <see cref="Branch"/>.</returns>
public virtual Branch Rename(Branch branch, string newName, Signature signature, string logMessage = null, bool allowOverwrite = false)
public virtual Branch Rename(Branch branch, string newName, bool allowOverwrite = false)
{
Ensure.ArgumentNotNull(branch, "branch");
Ensure.ArgumentNotNullOrEmptyString(newName, "newName");
@ -178,15 +157,9 @@ namespace LibGit2Sharp
"Cannot rename branch '{0}'. It's a remote tracking branch.", branch.Name));
}
if (logMessage == null)
{
logMessage = string.Format(CultureInfo.InvariantCulture,
"branch: renamed {0} to {1}", branch.CanonicalName, Reference.LocalBranchPrefix + newName);
}
using (ReferenceSafeHandle referencePtr = repo.Refs.RetrieveReferencePtr(Reference.LocalBranchPrefix + branch.Name))
{
using (Proxy.git_branch_move(referencePtr, newName, allowOverwrite, signature.OrDefault(repo.Config), logMessage))
using (Proxy.git_branch_move(referencePtr, newName, allowOverwrite))
{
}
}
@ -195,18 +168,6 @@ namespace LibGit2Sharp
return newBranch;
}
/// <summary>
/// Rename an existing local branch, using the default reflog message
/// </summary>
/// <param name="branch">The current local branch.</param>
/// <param name="newName">The new name the existing branch should bear.</param>
/// <param name="allowOverwrite">True to allow silent overwriting a potentially existing branch, false otherwise.</param>
/// <returns>A new <see cref="Branch"/>.</returns>
public virtual Branch Rename(Branch branch, string newName, bool allowOverwrite = false)
{
return Rename(branch, newName, null, null, allowOverwrite);
}
/// <summary>
/// Update properties of a branch.
/// </summary>

Просмотреть файл

@ -7,51 +7,22 @@ namespace LibGit2Sharp
/// </summary>
public static class BranchCollectionExtensions
{
/// <summary>
/// Create a new local branch with the specified name, using the default reflog message
/// </summary>
/// <param name="name">The name of the branch.</param>
/// <param name="committish">Revparse spec for the target commit.</param>
/// <param name="allowOverwrite">True to allow silent overwriting a potentially existing branch, false otherwise.</param>
/// <param name="branches">The <see cref="BranchCollection"/> being worked with.</param>
/// <returns>A new <see cref="Branch"/>.</returns>
public static Branch Add(this BranchCollection branches, string name, string committish, bool allowOverwrite = false)
{
return Add(branches, name, committish, null, null, allowOverwrite);
}
/// <summary>
/// Create a new local branch with the specified name
/// </summary>
/// <param name="branches">The <see cref="BranchCollection"/> being worked with.</param>
/// <param name="name">The name of the branch.</param>
/// <param name="committish">Revparse spec for the target commit.</param>
/// <param name="signature">The identity used for updating the reflog</param>
/// <param name="logMessage">The optional message to log in the <see cref="ReflogCollection"/></param>
/// <param name="commit">The target commit.</param>
/// <param name="allowOverwrite">True to allow silent overwriting a potentially existing branch, false otherwise.</param>
/// <returns>A new <see cref="Branch"/>.</returns>
public static Branch Add(this BranchCollection branches, string name, string committish, Signature signature,
string logMessage = null, bool allowOverwrite = false)
public static Branch Add(this BranchCollection branches, string name, Commit commit, bool allowOverwrite = false)
{
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNullOrEmptyString(committish, "committish");
Ensure.ArgumentNotNull(commit, "commit");
var commit = branches.repo.LookupCommit(committish);
if (logMessage == null)
{
var createdFrom = committish != "HEAD"
? committish
: branches.repo.Info.IsHeadDetached
? commit.Sha
: branches.repo.Head.Name;
logMessage = "branch: Created from " + createdFrom;
}
return branches.Add(name, commit, signature, logMessage, allowOverwrite);
return branches.Add(name, commit.Sha, allowOverwrite);
}
/// <summary>
/// Deletes the branch with the specified name.
/// </summary>

Просмотреть файл

@ -50,7 +50,7 @@ namespace LibGit2Sharp
get
{
return this.Checkout ?
CheckoutStrategy.GIT_CHECKOUT_SAFE_CREATE :
CheckoutStrategy.GIT_CHECKOUT_SAFE :
CheckoutStrategy.GIT_CHECKOUT_NONE;
}
}

Просмотреть файл

@ -16,15 +16,15 @@ namespace LibGit2Sharp.Core
/// </summary>
GIT_CHECKOUT_SAFE = (1 << 0),
/// <summary>
/// Allow safe updates plus creation of missing files.
/// </summary>
GIT_CHECKOUT_SAFE_CREATE = (1 << 1),
/// <summary>
/// Allow update of entries in working dir that are modified from HEAD.
/// </summary>
GIT_CHECKOUT_FORCE = (1 << 2),
GIT_CHECKOUT_FORCE = (1 << 1),
/// <summary>
/// Allow checkout to recreate missing files.
/// </summary>
GIT_CHECKOUT_RECREATE_MISSING = (1 << 2),
/// <summary>
/// Allow checkout to make safe updates even if conflicts are found
@ -48,6 +48,7 @@ namespace LibGit2Sharp.Core
/// <summary>
/// Normally checkout updates index entries as it goes; this stops that
/// Implies `GIT_CHECKOUT_DONT_WRITE_INDEX`.
/// </summary>
GIT_CHECKOUT_DONT_UPDATE_INDEX = (1 << 8),
@ -94,6 +95,18 @@ namespace LibGit2Sharp.Core
/// </summary>
GIT_CHECKOUT_CONFLICT_STYLE_DIFF3 = (1 << 21),
/// <summary>
/// Don't overwrite existing files or folders
/// </summary>
GIT_CHECKOUT_DONT_REMOVE_EXISTING = (1 << 22),
/// <summary>
/// Normally checkout writes the index upon completion; this prevents that.
/// </summary>
GIT_CHECKOUT_DONT_WRITE_INDEX = (1 << 23),
// THE FOLLOWING OPTIONS ARE NOT YET IMPLEMENTED
/// <summary>
/// Recursively checkout submodules with same options (NOT IMPLEMENTED)
/// </summary>

Просмотреть файл

@ -9,5 +9,7 @@ namespace LibGit2Sharp.Core
public IntPtr namePtr;
public IntPtr valuePtr;
public uint level;
public IntPtr freePtr;
public IntPtr payloadPtr;
}
}

Просмотреть файл

@ -1,5 +1,4 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices;
namespace LibGit2Sharp.Core
{
@ -13,7 +12,5 @@ namespace LibGit2Sharp.Core
public GitRemoteCallbacks RemoteCallbacks;
public CheckoutStrategy CloneCheckoutStrategy;
public IntPtr Signature;
}
}

Просмотреть файл

@ -1,10 +1,16 @@
namespace LibGit2Sharp.Core.Handles
{
internal class GitConfigEntryHandle : NotOwnedSafeHandleBase
internal class GitConfigEntryHandle : SafeHandleBase
{
public GitConfigEntry MarshalAsGitConfigEntry()
{
return handle.MarshalAs<GitConfigEntry>();
}
protected override bool ReleaseHandleImpl()
{
Proxy.git_config_entry_free(handle);
return true;
}
}
}

Просмотреть файл

@ -108,7 +108,7 @@ namespace LibGit2Sharp.Core
{
return RewriteReference(
sref, old => old.Target, RewriteReference,
(refs, old, target, sig, logMessage) => refs.UpdateTarget(old, target, sig, logMessage));
(refs, old, target, logMessage) => refs.UpdateTarget(old, target, logMessage));
}
var dref = reference as DirectReference;
@ -116,14 +116,14 @@ namespace LibGit2Sharp.Core
{
return RewriteReference(
dref, old => old.Target, RewriteTarget,
(refs, old, target, sig, logMessage) => refs.UpdateTarget(old, target.Id, sig, logMessage));
(refs, old, target, logMessage) => refs.UpdateTarget(old, target.Id, logMessage));
}
return reference;
}
private delegate Reference ReferenceUpdater<in TRef, in TTarget>(
ReferenceCollection refs, TRef origRef, TTarget origTarget, Signature signature, string logMessage)
ReferenceCollection refs, TRef origRef, TTarget origTarget, string logMessage)
where TRef : Reference
where TTarget : class;
@ -135,7 +135,6 @@ namespace LibGit2Sharp.Core
where TTarget : class
{
var oldRefTarget = selectTarget(oldRef);
var signature = repo.Config.BuildSignature(DateTimeOffset.Now);
string newRefName = oldRef.CanonicalName;
if (oldRef.IsTag() && options.TagNameRewriter != null)
@ -163,26 +162,26 @@ namespace LibGit2Sharp.Core
oldRef.CanonicalName, backupName));
}
repo.Refs.Add(backupName, oldRef.TargetIdentifier, signature, "filter-branch: backup");
repo.Refs.Add(backupName, oldRef.TargetIdentifier, "filter-branch: backup");
rollbackActions.Enqueue(() => repo.Refs.Remove(backupName));
if (newTarget == null)
{
repo.Refs.Remove(oldRef);
rollbackActions.Enqueue(() => repo.Refs.Add(oldRef.CanonicalName, oldRef, signature, "filter-branch: abort", true));
rollbackActions.Enqueue(() => repo.Refs.Add(oldRef.CanonicalName, oldRef, "filter-branch: abort", true));
return refMap[oldRef] = null;
}
Reference newRef = updateTarget(repo.Refs, oldRef, newTarget, signature, "filter-branch: rewrite");
rollbackActions.Enqueue(() => updateTarget(repo.Refs, oldRef, oldRefTarget, signature, "filter-branch: abort"));
Reference newRef = updateTarget(repo.Refs, oldRef, newTarget, "filter-branch: rewrite");
rollbackActions.Enqueue(() => updateTarget(repo.Refs, oldRef, oldRefTarget, "filter-branch: abort"));
if (newRef.CanonicalName == newRefName)
{
return refMap[oldRef] = newRef;
}
var movedRef = repo.Refs.Rename(newRef, newRefName);
rollbackActions.Enqueue(() => repo.Refs.Rename(newRef, oldRef.CanonicalName));
var movedRef = repo.Refs.Rename(newRef, newRefName, false);
rollbackActions.Enqueue(() => repo.Refs.Rename(newRef, oldRef.CanonicalName, false));
return refMap[oldRef] = movedRef;
}

Просмотреть файл

@ -2,6 +2,6 @@ namespace LibGit2Sharp.Core
{
internal static class NativeDllName
{
public const string Name = "git2-e0902fb";
public const string Name = "git2-9bbc8f3";
}
}

Просмотреть файл

@ -146,14 +146,12 @@ namespace LibGit2Sharp.Core
internal static extern Int64 git_blob_rawsize(GitObjectSafeHandle blob);
[DllImport(libgit2)]
internal static extern int git_branch_create(
internal static extern int git_branch_create_from_annotated(
out ReferenceSafeHandle ref_out,
RepositorySafeHandle repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string branch_name,
GitObjectSafeHandle target, // TODO: GitCommitSafeHandle?
[MarshalAs(UnmanagedType.Bool)] bool force,
SignatureSafeHandle signature,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string log_message);
GitAnnotatedCommitHandle target,
[MarshalAs(UnmanagedType.Bool)] bool force);
[DllImport(libgit2)]
internal static extern int git_branch_delete(
@ -179,9 +177,7 @@ namespace LibGit2Sharp.Core
out ReferenceSafeHandle ref_out,
ReferenceSafeHandle reference,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string new_branch_name,
[MarshalAs(UnmanagedType.Bool)] bool force,
SignatureSafeHandle signature,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string log_message);
[MarshalAs(UnmanagedType.Bool)] bool force);
[DllImport(libgit2)]
internal static extern int git_branch_next(
@ -290,6 +286,9 @@ namespace LibGit2Sharp.Core
[DllImport(libgit2)]
internal static extern void git_config_free(IntPtr cfg);
[DllImport(libgit2)]
internal static extern void git_config_entry_free(IntPtr entry);
[DllImport(libgit2)]
internal static extern int git_config_get_entry(
out GitConfigEntryHandle entry,
@ -637,6 +636,12 @@ namespace LibGit2Sharp.Core
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string remote_url,
ref GitOid oid);
[DllImport(libgit2)]
internal static extern int git_annotated_commit_from_revspec(
out GitAnnotatedCommitHandle annotatedCommit,
RepositorySafeHandle repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string revspec);
[DllImport(libgit2)]
internal static extern int git_annotated_commit_lookup(
out GitAnnotatedCommitHandle annotatedCommit,
@ -823,7 +828,6 @@ namespace LibGit2Sharp.Core
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string name,
ref GitOid oid,
[MarshalAs(UnmanagedType.Bool)] bool force,
SignatureSafeHandle signature,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string log_message);
[DllImport(libgit2)]
@ -833,7 +837,6 @@ namespace LibGit2Sharp.Core
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string name,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string target,
[MarshalAs(UnmanagedType.Bool)] bool force,
SignatureSafeHandle signature,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string log_message);
internal delegate int ref_glob_callback(
@ -881,7 +884,6 @@ namespace LibGit2Sharp.Core
ReferenceSafeHandle reference,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string newName,
[MarshalAs(UnmanagedType.Bool)] bool force,
SignatureSafeHandle signature,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string log_message);
[DllImport(libgit2)]
@ -889,7 +891,6 @@ namespace LibGit2Sharp.Core
out ReferenceSafeHandle ref_out,
ReferenceSafeHandle reference,
ref GitOid id,
SignatureSafeHandle signature,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string log_message);
[DllImport(libgit2)]
@ -897,7 +898,6 @@ namespace LibGit2Sharp.Core
out ReferenceSafeHandle ref_out,
ReferenceSafeHandle reference,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string target,
SignatureSafeHandle signature,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string log_message);
[DllImport(libgit2)]
@ -1015,7 +1015,6 @@ namespace LibGit2Sharp.Core
internal static extern int git_remote_fetch(
RemoteSafeHandle remote,
ref GitStrArray refspecs,
SignatureSafeHandle signature,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string log_message);
[DllImport(libgit2)]
@ -1034,9 +1033,7 @@ namespace LibGit2Sharp.Core
internal static extern int git_remote_push(
RemoteSafeHandle remote,
ref GitStrArray refSpecs,
GitPushOptions opts,
SignatureSafeHandle signature,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string reflogMessage);
GitPushOptions opts);
[DllImport(libgit2)]
internal static extern UIntPtr git_remote_refspec_count(RemoteSafeHandle remote);
@ -1143,6 +1140,12 @@ namespace LibGit2Sharp.Core
[DllImport(libgit2)]
internal static extern int git_repository_head_unborn(RepositorySafeHandle repo);
[DllImport(libgit2)]
internal static extern int git_repository_ident(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(LaxUtf8NoCleanupMarshaler))] out string name,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(LaxUtf8NoCleanupMarshaler))] out string email,
RepositorySafeHandle repo);
[DllImport(libgit2)]
internal static extern int git_repository_index(out IndexSafeHandle index, RepositorySafeHandle repo);
@ -1200,6 +1203,13 @@ namespace LibGit2Sharp.Core
RepositorySafeHandle repository,
ConfigurationSafeHandle config);
[DllImport(libgit2)]
internal static extern int git_repository_set_ident(
RepositorySafeHandle repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string name,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string email);
[DllImport(libgit2)]
internal static extern void git_repository_set_index(
RepositorySafeHandle repository,
@ -1214,16 +1224,17 @@ namespace LibGit2Sharp.Core
[DllImport(libgit2)]
internal static extern int git_repository_set_head_detached(
RepositorySafeHandle repo,
ref GitOid commitish,
SignatureSafeHandle signature,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string log_message);
ref GitOid commitish);
[DllImport(libgit2)]
internal static extern int git_repository_set_head_detached_from_annotated(
RepositorySafeHandle repo,
GitAnnotatedCommitHandle commit);
[DllImport(libgit2)]
internal static extern int git_repository_set_head(
RepositorySafeHandle repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string refname,
SignatureSafeHandle signature,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string log_message);
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string refname);
[DllImport(libgit2)]
internal static extern int git_repository_state(
@ -1238,9 +1249,7 @@ namespace LibGit2Sharp.Core
RepositorySafeHandle repo,
GitObjectSafeHandle target,
ResetMode reset_type,
ref GitCheckoutOpts opts,
SignatureSafeHandle signature,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string log_message);
ref GitCheckoutOpts opts);
[DllImport(libgit2)]
internal static extern int git_revert(

Просмотреть файл

@ -143,16 +143,18 @@ namespace LibGit2Sharp.Core
#region git_branch_
public static ReferenceSafeHandle git_branch_create(RepositorySafeHandle repo, string branch_name, ObjectId targetId, bool force,
Signature signature, string logMessage)
public static ReferenceSafeHandle git_branch_create_from_annotated(RepositorySafeHandle repo, string branch_name, string targetIdentifier, bool force)
{
using (ThreadAffinity())
using (var osw = new ObjectSafeWrapper(targetId, repo))
using (var sigHandle = signature.BuildHandle())
{
ReferenceSafeHandle reference;
int res = NativeMethods.git_branch_create(out reference, repo, branch_name, osw.ObjectPtr, force, sigHandle, logMessage);
Ensure.ZeroResult(res);
using (var annotatedCommit = git_annotated_commit_from_revspec(repo, targetIdentifier))
{
int res = NativeMethods.git_branch_create_from_annotated(out reference, repo, branch_name, annotatedCommit, force);
Ensure.ZeroResult(res);
}
return reference;
}
}
@ -190,14 +192,12 @@ namespace LibGit2Sharp.Core
NativeMethods.git_branch_iterator_free(iter);
}
public static ReferenceSafeHandle git_branch_move(ReferenceSafeHandle reference, string new_branch_name, bool force,
Signature signature, string logMessage)
public static ReferenceSafeHandle git_branch_move(ReferenceSafeHandle reference, string new_branch_name, bool force)
{
using (ThreadAffinity())
using (var sigHandle = signature.BuildHandle())
{
ReferenceSafeHandle ref_out;
int res = NativeMethods.git_branch_move(out ref_out, reference, new_branch_name, force, sigHandle, logMessage);
int res = NativeMethods.git_branch_move(out ref_out, reference, new_branch_name, force);
Ensure.ZeroResult(res);
return ref_out;
}
@ -433,27 +433,41 @@ namespace LibGit2Sharp.Core
NativeMethods.git_config_free(config);
}
public static void git_config_entry_free(IntPtr entry)
{
NativeMethods.git_config_entry_free(entry);
}
public static ConfigurationEntry<T> git_config_get_entry<T>(ConfigurationSafeHandle config, string key)
{
GitConfigEntryHandle handle;
GitConfigEntryHandle handle = null;
if (!configurationParser.ContainsKey(typeof(T)))
{
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Generic Argument of type '{0}' is not supported.", typeof(T).FullName));
}
using (ThreadAffinity())
GitConfigEntry entry;
try
{
var res = NativeMethods.git_config_get_entry(out handle, config, key);
if (res == (int)GitErrorCode.NotFound)
using (ThreadAffinity())
{
return null;
var res = NativeMethods.git_config_get_entry(out handle, config, key);
if (res == (int)GitErrorCode.NotFound)
{
return null;
}
Ensure.ZeroResult(res);
entry = handle.MarshalAsGitConfigEntry();
}
Ensure.ZeroResult(res);
}
GitConfigEntry entry = handle.MarshalAsGitConfigEntry();
finally
{
handle.SafeDispose();
}
return new ConfigurationEntry<T>(LaxUtf8Marshaler.FromNative(entry.namePtr),
(T)configurationParser[typeof(T)](LaxUtf8Marshaler.FromNative(entry.valuePtr)),
@ -1165,6 +1179,20 @@ namespace LibGit2Sharp.Core
}
}
public static GitAnnotatedCommitHandle git_annotated_commit_from_revspec(RepositorySafeHandle repo, string revspec)
{
using (ThreadAffinity())
{
GitAnnotatedCommitHandle their_head;
int res = NativeMethods.git_annotated_commit_from_revspec(out their_head, repo, revspec);
Ensure.ZeroResult(res);
return their_head;
}
}
public static ObjectId git_annotated_commit_id(GitAnnotatedCommitHandle mergeHead)
{
return NativeMethods.git_annotated_commit_id(mergeHead).MarshalAsObjectId();
@ -1576,15 +1604,14 @@ namespace LibGit2Sharp.Core
#region git_reference_
public static ReferenceSafeHandle git_reference_create(RepositorySafeHandle repo, string name, ObjectId targetId, bool allowOverwrite,
Signature signature, string logMessage)
string logMessage)
{
using (ThreadAffinity())
using (var sigHandle = signature.BuildHandle())
{
GitOid oid = targetId.Oid;
ReferenceSafeHandle handle;
int res = NativeMethods.git_reference_create(out handle, repo, name, ref oid, allowOverwrite, sigHandle, logMessage);
int res = NativeMethods.git_reference_create(out handle, repo, name, ref oid, allowOverwrite, logMessage);
Ensure.ZeroResult(res);
return handle;
@ -1592,13 +1619,12 @@ namespace LibGit2Sharp.Core
}
public static ReferenceSafeHandle git_reference_symbolic_create(RepositorySafeHandle repo, string name, string target, bool allowOverwrite,
Signature signature, string logMessage)
string logMessage)
{
using (ThreadAffinity())
using (var sigHandle = signature.BuildHandle())
{
ReferenceSafeHandle handle;
int res = NativeMethods.git_reference_symbolic_create(out handle, repo, name, target, allowOverwrite, sigHandle, logMessage);
int res = NativeMethods.git_reference_symbolic_create(out handle, repo, name, target, allowOverwrite, logMessage);
Ensure.ZeroResult(res);
return handle;
@ -1684,43 +1710,40 @@ namespace LibGit2Sharp.Core
}
public static ReferenceSafeHandle git_reference_rename(ReferenceSafeHandle reference, string newName, bool allowOverwrite,
Signature signature, string logMessage)
string logMessage)
{
using (ThreadAffinity())
using (var sigHandle = signature.BuildHandle())
{
ReferenceSafeHandle ref_out;
int res = NativeMethods.git_reference_rename(out ref_out, reference, newName, allowOverwrite, sigHandle, logMessage);
int res = NativeMethods.git_reference_rename(out ref_out, reference, newName, allowOverwrite, logMessage);
Ensure.ZeroResult(res);
return ref_out;
}
}
public static ReferenceSafeHandle git_reference_set_target(ReferenceSafeHandle reference, ObjectId id, Signature signature, string logMessage)
public static ReferenceSafeHandle git_reference_set_target(ReferenceSafeHandle reference, ObjectId id, string logMessage)
{
using (ThreadAffinity())
using (SignatureSafeHandle sigHandle = signature.BuildHandle())
{
GitOid oid = id.Oid;
ReferenceSafeHandle ref_out;
int res = NativeMethods.git_reference_set_target(out ref_out, reference, ref oid, sigHandle, logMessage);
int res = NativeMethods.git_reference_set_target(out ref_out, reference, ref oid, logMessage);
Ensure.ZeroResult(res);
return ref_out;
}
}
public static ReferenceSafeHandle git_reference_symbolic_set_target(ReferenceSafeHandle reference, string target, Signature signature, string logMessage)
public static ReferenceSafeHandle git_reference_symbolic_set_target(ReferenceSafeHandle reference, string target, string logMessage)
{
using (ThreadAffinity())
using (SignatureSafeHandle sigHandle = signature.BuildHandle())
{
ReferenceSafeHandle ref_out;
int res = NativeMethods.git_reference_symbolic_set_target(out ref_out, reference, target, sigHandle, logMessage);
int res = NativeMethods.git_reference_symbolic_set_target(out ref_out, reference, target, logMessage);
Ensure.ZeroResult(res);
return ref_out;
@ -1966,25 +1989,22 @@ namespace LibGit2Sharp.Core
}
}
public static void git_remote_push(RemoteSafeHandle remote, IEnumerable<string> refSpecs, GitPushOptions opts, Signature signature, string reflogMessage)
public static void git_remote_push(RemoteSafeHandle remote, IEnumerable<string> refSpecs, GitPushOptions opts)
{
using (ThreadAffinity())
{
using (var sigHandle = signature.BuildHandle())
var array = new GitStrArrayManaged();
try
{
var array = new GitStrArrayManaged();
array = GitStrArrayManaged.BuildFrom(refSpecs.ToArray());
try
{
array = GitStrArrayManaged.BuildFrom(refSpecs.ToArray());
int res = NativeMethods.git_remote_push(remote, ref array.Array, opts, sigHandle, reflogMessage);
Ensure.ZeroResult(res);
}
finally
{
array.Dispose();
}
int res = NativeMethods.git_remote_push(remote, ref array.Array, opts);
Ensure.ZeroResult(res);
}
finally
{
array.Dispose();
}
}
}
@ -2037,7 +2057,7 @@ namespace LibGit2Sharp.Core
Ensure.ZeroResult(res);
}
}
public static void git_remote_set_pushurl(RemoteSafeHandle remote, string url)
{
using (ThreadAffinity())
@ -2047,16 +2067,15 @@ namespace LibGit2Sharp.Core
}
}
public static void git_remote_fetch(RemoteSafeHandle remote, Signature signature, string logMessage)
public static void git_remote_fetch(RemoteSafeHandle remote, string logMessage)
{
using (ThreadAffinity())
using (var sigHandle = signature.BuildHandle())
{
var array = new GitStrArrayNative();
try
{
int res = NativeMethods.git_remote_fetch(remote, ref array.Array, sigHandle, logMessage);
int res = NativeMethods.git_remote_fetch(remote, ref array.Array, logMessage);
Ensure.ZeroResult(res);
}
finally
@ -2405,6 +2424,15 @@ namespace LibGit2Sharp.Core
NativeMethods.git_repository_set_config(repo, config);
}
public static void git_repository_set_ident(RepositorySafeHandle repo, string name, string email)
{
using (ThreadAffinity())
{
int res = NativeMethods.git_repository_set_ident(repo, name, email);
Ensure.ZeroResult(res);
}
}
public static void git_repository_set_index(RepositorySafeHandle repo, IndexSafeHandle index)
{
NativeMethods.git_repository_set_index(repo, index);
@ -2434,25 +2462,30 @@ namespace LibGit2Sharp.Core
return NativeMethods.git_repository_workdir(repo);
}
public static void git_repository_set_head_detached(RepositorySafeHandle repo, ObjectId commitish,
Signature signature, string logMessage)
public static void git_repository_set_head_detached(RepositorySafeHandle repo, ObjectId commitish)
{
using (ThreadAffinity())
using (var sigHandle = signature.BuildHandle())
{
GitOid oid = commitish.Oid;
int res = NativeMethods.git_repository_set_head_detached(repo, ref oid, sigHandle, logMessage);
int res = NativeMethods.git_repository_set_head_detached(repo, ref oid);
Ensure.ZeroResult(res);
}
}
public static void git_repository_set_head(RepositorySafeHandle repo, string refname,
Signature signature, string logMessage)
public static void git_repository_set_head_detached_from_annotated(RepositorySafeHandle repo, GitAnnotatedCommitHandle commit)
{
using (ThreadAffinity())
using (var sigHandle = signature.BuildHandle())
{
int res = NativeMethods.git_repository_set_head(repo, refname, sigHandle, logMessage);
int res = NativeMethods.git_repository_set_head_detached_from_annotated(repo, commit);
Ensure.ZeroResult(res);
}
}
public static void git_repository_set_head(RepositorySafeHandle repo, string refname)
{
using (ThreadAffinity())
{
int res = NativeMethods.git_repository_set_head(repo, refname);
Ensure.ZeroResult(res);
}
}
@ -2465,15 +2498,12 @@ namespace LibGit2Sharp.Core
RepositorySafeHandle repo,
ObjectId committishId,
ResetMode resetKind,
ref GitCheckoutOpts checkoutOptions,
Signature signature,
string logMessage)
ref GitCheckoutOpts checkoutOptions)
{
using (ThreadAffinity())
using (var osw = new ObjectSafeWrapper(committishId, repo))
using (var sigHandle = signature.BuildHandle())
{
int res = NativeMethods.git_reset(repo, osw.ObjectPtr, resetKind, ref checkoutOptions, sigHandle, logMessage);
int res = NativeMethods.git_reset(repo, osw.ObjectPtr, resetKind, ref checkoutOptions);
Ensure.ZeroResult(res);
}
}

Просмотреть файл

@ -78,9 +78,8 @@ namespace LibGit2Sharp
/// </summary>
/// <param name="branch">The <see cref="Branch"/> to check out.</param>
/// <param name="options"><see cref="CheckoutOptions"/> controlling checkout behavior.</param>
/// <param name="signature">Identity for use when updating the reflog.</param>
/// <returns>The <see cref="Branch"/> that was checked out.</returns>
Branch Checkout(Branch branch, CheckoutOptions options, Signature signature);
Branch Checkout(Branch branch, CheckoutOptions options);
/// <summary>
/// Checkout the specified branch, reference or SHA.
@ -91,9 +90,8 @@ namespace LibGit2Sharp
/// </summary>
/// <param name="committishOrBranchSpec">A revparse spec for the commit or branch to checkout.</param>
/// <param name="options"><see cref="CheckoutOptions"/> controlling checkout behavior.</param>
/// <param name="signature">Identity for use when updating the reflog.</param>
/// <returns>The <see cref="Branch"/> that was checked out.</returns>
Branch Checkout(string committishOrBranchSpec, CheckoutOptions options, Signature signature);
Branch Checkout(string committishOrBranchSpec, CheckoutOptions options);
/// <summary>
/// Checkout the specified <see cref="LibGit2Sharp.Commit"/>.
@ -103,9 +101,8 @@ namespace LibGit2Sharp
/// </summary>
/// <param name="commit">The <see cref="LibGit2Sharp.Commit"/> to check out.</param>
/// <param name="options"><see cref="CheckoutOptions"/> controlling checkout behavior.</param>
/// <param name="signature">Identity for use when updating the reflog.</param>
/// <returns>The <see cref="Branch"/> that was checked out.</returns>
Branch Checkout(Commit commit, CheckoutOptions options, Signature signature);
Branch Checkout(Commit commit, CheckoutOptions options);
/// <summary>
/// Updates specifed paths in the index and working directory with the versions from the specified branch, reference, or SHA.
@ -166,9 +163,7 @@ namespace LibGit2Sharp
/// </summary>
/// <param name="resetMode">Flavor of reset operation to perform.</param>
/// <param name="commit">The target commit object.</param>
/// <param name="signature">Identity for use when updating the reflog.</param>
/// <param name="logMessage">Message to use when updating the reflog.</param>
void Reset(ResetMode resetMode, Commit commit, Signature signature, string logMessage);
void Reset(ResetMode resetMode, Commit commit);
/// <summary>
/// Replaces entries in the <see cref="Repository.Index"/> with entries from the specified commit.

Просмотреть файл

@ -132,7 +132,6 @@
<Compile Include="Core\Handles\StatusListSafeHandle.cs" />
<Compile Include="RenameDetails.cs" />
<Compile Include="RevertResult.cs" />
<Compile Include="SignatureExtensions.cs" />
<Compile Include="RevertOptions.cs" />
<Compile Include="StageOptions.cs" />
<Compile Include="StatusOptions.cs" />

Просмотреть файл

@ -88,7 +88,7 @@ namespace LibGit2Sharp
}
}
static void DoFetch(RemoteSafeHandle remoteHandle, FetchOptions options, Signature signature, string logMessage)
static void DoFetch(RemoteSafeHandle remoteHandle, FetchOptions options, string logMessage)
{
if (options == null)
{
@ -113,7 +113,7 @@ namespace LibGit2Sharp
// GC occuring in between setting the remote callbacks and actual usage in one of the functions afterwords.
Proxy.git_remote_set_callbacks(remoteHandle, ref gitCallbacks);
Proxy.git_remote_fetch(remoteHandle, signature, logMessage);
Proxy.git_remote_fetch(remoteHandle, logMessage);
}
/// <summary>
@ -121,17 +121,15 @@ namespace LibGit2Sharp
/// </summary>
/// <param name="remote">The remote to fetch</param>
/// <param name="options"><see cref="FetchOptions"/> controlling fetch behavior</param>
/// <param name="signature">Identity for use when updating the reflog.</param>
/// <param name="logMessage">Message to use when updating the reflog.</param>
public virtual void Fetch(Remote remote, FetchOptions options = null,
Signature signature = null,
string logMessage = null)
{
Ensure.ArgumentNotNull(remote, "remote");
using (RemoteSafeHandle remoteHandle = Proxy.git_remote_lookup(repository.Handle, remote.Name, true))
{
DoFetch(remoteHandle, options, signature.OrDefault(repository.Config), logMessage);
DoFetch(remoteHandle, options, logMessage);
}
}
@ -141,10 +139,8 @@ namespace LibGit2Sharp
/// <param name="remote">The remote to fetch</param>
/// <param name="refspecs">Refspecs to use, replacing the remote's fetch refspecs</param>
/// <param name="options"><see cref="FetchOptions"/> controlling fetch behavior</param>
/// <param name="signature">Identity for use when updating the reflog.</param>
/// <param name="logMessage">Message to use when updating the reflog.</param>
public virtual void Fetch(Remote remote, IEnumerable<string> refspecs, FetchOptions options = null,
Signature signature = null,
string logMessage = null)
{
Ensure.ArgumentNotNull(remote, "remote");
@ -154,7 +150,7 @@ namespace LibGit2Sharp
{
Proxy.git_remote_set_fetch_refspecs(remoteHandle, refspecs);
DoFetch(remoteHandle, options, signature.OrDefault(repository.Config), logMessage);
DoFetch(remoteHandle, options, logMessage);
}
}
@ -164,13 +160,11 @@ namespace LibGit2Sharp
/// <param name="url">The url to fetch from</param>
/// <param name="refspecs">The list of resfpecs to use</param>
/// <param name="options"><see cref="FetchOptions"/> controlling fetch behavior</param>
/// <param name="signature">Identity for use when updating the reflog.</param>
/// <param name="logMessage">Message to use when updating the reflog.</param>
public virtual void Fetch(
string url,
IEnumerable<string> refspecs,
FetchOptions options = null,
Signature signature = null,
string logMessage = null)
{
Ensure.ArgumentNotNull(url, "url");
@ -180,7 +174,7 @@ namespace LibGit2Sharp
{
Proxy.git_remote_set_fetch_refspecs(remoteHandle, refspecs);
DoFetch(remoteHandle, options, signature.OrDefault(repository.Config), logMessage);
DoFetch(remoteHandle, options, logMessage);
}
}
@ -191,22 +185,18 @@ namespace LibGit2Sharp
/// <param name="objectish">The source objectish to push.</param>
/// <param name="destinationSpec">The reference to update on the remote.</param>
/// <param name="pushOptions"><see cref="PushOptions"/> controlling push behavior</param>
/// <param name="signature">Identity for use when updating the reflog.</param>
/// <param name="logMessage">Message to use when updating the reflog.</param>
public virtual void Push(
Remote remote,
string objectish,
string destinationSpec,
PushOptions pushOptions = null,
Signature signature = null,
string logMessage = null)
PushOptions pushOptions = null)
{
Ensure.ArgumentNotNull(remote, "remote");
Ensure.ArgumentNotNull(objectish, "objectish");
Ensure.ArgumentNotNullOrEmptyString(destinationSpec, destinationSpec);
Push(remote, string.Format(CultureInfo.InvariantCulture,
"{0}:{1}", objectish, destinationSpec), pushOptions, signature, logMessage);
"{0}:{1}", objectish, destinationSpec), pushOptions);
}
/// <summary>
@ -215,19 +205,15 @@ namespace LibGit2Sharp
/// <param name="remote">The <see cref="Remote"/> to push to.</param>
/// <param name="pushRefSpec">The pushRefSpec to push.</param>
/// <param name="pushOptions"><see cref="PushOptions"/> controlling push behavior</param>
/// <param name="signature">Identity for use when updating the reflog.</param>
/// <param name="logMessage">Message to use when updating the reflog.</param>
public virtual void Push(
Remote remote,
string pushRefSpec,
PushOptions pushOptions = null,
Signature signature = null,
string logMessage = null)
PushOptions pushOptions = null)
{
Ensure.ArgumentNotNull(remote, "remote");
Ensure.ArgumentNotNullOrEmptyString(pushRefSpec, "pushRefSpec");
Push(remote, new[] { pushRefSpec }, pushOptions, signature, logMessage);
Push(remote, new[] { pushRefSpec }, pushOptions);
}
/// <summary>
@ -236,14 +222,10 @@ namespace LibGit2Sharp
/// <param name="remote">The <see cref="Remote"/> to push to.</param>
/// <param name="pushRefSpecs">The pushRefSpecs to push.</param>
/// <param name="pushOptions"><see cref="PushOptions"/> controlling push behavior</param>
/// <param name="signature">Identity for use when updating the reflog.</param>
/// <param name="logMessage">Message to use when updating the reflog.</param>
public virtual void Push(
Remote remote,
IEnumerable<string> pushRefSpecs,
PushOptions pushOptions = null,
Signature signature = null,
string logMessage = null)
PushOptions pushOptions = null)
{
Ensure.ArgumentNotNull(remote, "remote");
Ensure.ArgumentNotNull(pushRefSpecs, "pushRefSpecs");
@ -269,12 +251,11 @@ namespace LibGit2Sharp
try
{
Proxy.git_remote_connect(remoteHandle, GitDirection.Push);
Proxy.git_remote_push(remoteHandle, pushRefSpecs,
Proxy.git_remote_push(remoteHandle, pushRefSpecs,
new GitPushOptions()
{
PackbuilderDegreeOfParallelism = pushOptions.PackbuilderDegreeOfParallelism
},
signature.OrDefault(repository.Config), logMessage);
});
}
finally
{

Просмотреть файл

@ -71,16 +71,15 @@ namespace LibGit2Sharp
/// </summary>
/// <param name="name">The canonical name of the reference to create.</param>
/// <param name="targetId">Id of the target object.</param>
/// <param name="signature">Identity used for updating the reflog.</param>
/// <param name="logMessage">The optional message to log in the <see cref="ReflogCollection"/> when adding the <see cref="DirectReference"/></param>
/// <param name="allowOverwrite">True to allow silent overwriting a potentially existing reference, false otherwise.</param>
/// <returns>A new <see cref="Reference"/>.</returns>
public virtual DirectReference Add(string name, ObjectId targetId, Signature signature, string logMessage, bool allowOverwrite = false)
public virtual DirectReference Add(string name, ObjectId targetId, string logMessage, bool allowOverwrite = false)
{
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(targetId, "targetId");
using (ReferenceSafeHandle handle = Proxy.git_reference_create(repo.Handle, name, targetId, allowOverwrite, signature.OrDefault(repo.Config), logMessage))
using (ReferenceSafeHandle handle = Proxy.git_reference_create(repo.Handle, name, targetId, allowOverwrite, logMessage))
{
return (DirectReference)Reference.BuildFromPtr<Reference>(handle, repo);
}
@ -95,7 +94,7 @@ namespace LibGit2Sharp
/// <returns>A new <see cref="Reference"/>.</returns>
public virtual DirectReference Add(string name, ObjectId targetId, bool allowOverwrite = false)
{
return Add(name, targetId, null, null, allowOverwrite);
return Add(name, targetId, null, allowOverwrite);
}
/// <summary>
@ -103,17 +102,16 @@ namespace LibGit2Sharp
/// </summary>
/// <param name="name">The canonical name of the reference to create.</param>
/// <param name="targetRef">The target reference.</param>
/// <param name="signature">Identity used for updating the reflog.</param>
/// <param name="logMessage">The optional message to log in the <see cref="ReflogCollection"/> when adding the <see cref="SymbolicReference"/></param>
/// <param name="allowOverwrite">True to allow silent overwriting a potentially existing reference, false otherwise.</param>
/// <returns>A new <see cref="Reference"/>.</returns>
public virtual SymbolicReference Add(string name, Reference targetRef, Signature signature, string logMessage, bool allowOverwrite = false)
public virtual SymbolicReference Add(string name, Reference targetRef, string logMessage, bool allowOverwrite = false)
{
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(targetRef, "targetRef");
using (ReferenceSafeHandle handle = Proxy.git_reference_symbolic_create(repo.Handle, name, targetRef.CanonicalName,
allowOverwrite, signature.OrDefault(repo.Config), logMessage))
allowOverwrite, logMessage))
{
return (SymbolicReference)Reference.BuildFromPtr<Reference>(handle, repo);
}
@ -128,7 +126,7 @@ namespace LibGit2Sharp
/// <returns>A new <see cref="Reference"/>.</returns>
public virtual SymbolicReference Add(string name, Reference targetRef, bool allowOverwrite = false)
{
return Add(name, targetRef, null, null, allowOverwrite);
return Add(name, targetRef, null, allowOverwrite);
}
/// <summary>
@ -147,11 +145,10 @@ namespace LibGit2Sharp
/// </summary>
/// <param name="reference">The reference to rename.</param>
/// <param name="newName">The new canonical name.</param>
/// <param name="signature">Identity used for updating the reflog.</param>
/// <param name="logMessage">Message added to the reflog.</param>
/// <param name="allowOverwrite">True to allow silent overwriting a potentially existing reference, false otherwise.</param>
/// <returns>A new <see cref="Reference"/>.</returns>
public virtual Reference Rename(Reference reference, string newName, Signature signature, string logMessage = null, bool allowOverwrite = false)
public virtual Reference Rename(Reference reference, string newName, string logMessage = null, bool allowOverwrite = false)
{
Ensure.ArgumentNotNull(reference, "reference");
Ensure.ArgumentNotNullOrEmptyString(newName, "newName");
@ -163,7 +160,7 @@ namespace LibGit2Sharp
}
using (ReferenceSafeHandle referencePtr = RetrieveReferencePtr(reference.CanonicalName))
using (ReferenceSafeHandle handle = Proxy.git_reference_rename(referencePtr, newName, allowOverwrite, signature.OrDefault(repo.Config), logMessage))
using (ReferenceSafeHandle handle = Proxy.git_reference_rename(referencePtr, newName, allowOverwrite, logMessage))
{
return Reference.BuildFromPtr<Reference>(handle, repo);
}
@ -178,7 +175,7 @@ namespace LibGit2Sharp
/// <returns>A new <see cref="Reference"/>.</returns>
public virtual Reference Rename(Reference reference, string newName, bool allowOverwrite = false)
{
return Rename(reference, newName, null, null, allowOverwrite);
return Rename(reference, newName, null, allowOverwrite);
}
internal T Resolve<T>(string name) where T : Reference
@ -196,23 +193,25 @@ namespace LibGit2Sharp
/// </summary>
/// <param name="directRef">The direct reference which target should be updated.</param>
/// <param name="targetId">The new target.</param>
/// <param name="signature">The identity used for updating the reflog.</param>
/// <param name="logMessage">The optional message to log in the <see cref="ReflogCollection"/> of the <paramref name="directRef"/> reference</param>
/// <returns>A new <see cref="Reference"/>.</returns>
public virtual Reference UpdateTarget(Reference directRef, ObjectId targetId, Signature signature, string logMessage)
public virtual Reference UpdateTarget(Reference directRef, ObjectId targetId, string logMessage)
{
Ensure.ArgumentNotNull(directRef, "directRef");
Ensure.ArgumentNotNull(targetId, "targetId");
signature = signature.OrDefault(repo.Config);
if (directRef.CanonicalName == "HEAD")
{
return UpdateHeadTarget(targetId, signature, logMessage);
return UpdateHeadTarget(targetId, logMessage);
}
return UpdateDirectReferenceTarget(directRef, targetId, logMessage);
}
private Reference UpdateDirectReferenceTarget(Reference directRef, ObjectId targetId, string logMessage)
{
using (ReferenceSafeHandle referencePtr = RetrieveReferencePtr(directRef.CanonicalName))
using (ReferenceSafeHandle handle = Proxy.git_reference_set_target(referencePtr, targetId, signature, logMessage))
using (ReferenceSafeHandle handle = Proxy.git_reference_set_target(referencePtr, targetId, logMessage))
{
return Reference.BuildFromPtr<Reference>(handle, repo);
}
@ -226,7 +225,7 @@ namespace LibGit2Sharp
/// <returns>A new <see cref="Reference"/>.</returns>
public virtual Reference UpdateTarget(Reference directRef, ObjectId targetId)
{
return UpdateTarget(directRef, targetId, null, null);
return UpdateTarget(directRef, targetId, null);
}
/// <summary>
@ -234,23 +233,25 @@ namespace LibGit2Sharp
/// </summary>
/// <param name="symbolicRef">The symbolic reference which target should be updated.</param>
/// <param name="targetRef">The new target.</param>
/// <param name="signature">The identity used for updating the reflog.</param>
/// <param name="logMessage">The optional message to log in the <see cref="ReflogCollection"/> of the <paramref name="symbolicRef"/> reference.</param>
/// <returns>A new <see cref="Reference"/>.</returns>
public virtual Reference UpdateTarget(Reference symbolicRef, Reference targetRef, Signature signature, string logMessage)
public virtual Reference UpdateTarget(Reference symbolicRef, Reference targetRef, string logMessage)
{
Ensure.ArgumentNotNull(symbolicRef, "symbolicRef");
Ensure.ArgumentNotNull(targetRef, "targetRef");
signature = signature.OrDefault(repo.Config);
if (symbolicRef.CanonicalName == "HEAD")
{
return UpdateHeadTarget(targetRef, signature, logMessage);
return UpdateHeadTarget(targetRef, logMessage);
}
return UpdateSymbolicRefenceTarget(symbolicRef, targetRef, logMessage);
}
private Reference UpdateSymbolicRefenceTarget(Reference symbolicRef, Reference targetRef, string logMessage)
{
using (ReferenceSafeHandle referencePtr = RetrieveReferencePtr(symbolicRef.CanonicalName))
using (ReferenceSafeHandle handle = Proxy.git_reference_symbolic_set_target(referencePtr, targetRef.CanonicalName, signature, logMessage))
using (ReferenceSafeHandle handle = Proxy.git_reference_symbolic_set_target(referencePtr, targetRef.CanonicalName, logMessage))
{
return Reference.BuildFromPtr<Reference>(handle, repo);
}
@ -264,49 +265,67 @@ namespace LibGit2Sharp
/// <returns>A new <see cref="Reference"/>.</returns>
public virtual Reference UpdateTarget(Reference symbolicRef, Reference targetRef)
{
return UpdateTarget(symbolicRef, targetRef, null, null);
return UpdateTarget(symbolicRef, targetRef, null);
}
internal Reference UpdateHeadTarget<T>(T target, Signature signature, string logMessage)
internal Reference MoveHeadTarget<T>(T target)
{
Debug.Assert(signature != null);
if (target is ObjectId)
{
Proxy.git_repository_set_head_detached(repo.Handle, target as ObjectId, signature, logMessage);
Proxy.git_repository_set_head_detached(repo.Handle, target as ObjectId);
}
else if (target is DirectReference || target is SymbolicReference)
{
Proxy.git_repository_set_head(repo.Handle, (target as Reference).CanonicalName, signature, logMessage);
Proxy.git_repository_set_head(repo.Handle, (target as Reference).CanonicalName);
}
else if (target is string)
{
var targetIdentifier = target as string;
if (Reference.IsValidName(targetIdentifier))
if (Reference.IsValidName(targetIdentifier) && targetIdentifier.LooksLikeLocalBranch())
{
Proxy.git_repository_set_head(repo.Handle, targetIdentifier, signature, logMessage);
Proxy.git_repository_set_head(repo.Handle, targetIdentifier);
}
else
{
GitObject commit = repo.Lookup(targetIdentifier,
GitObjectType.Any,
LookUpOptions.ThrowWhenNoGitObjectHasBeenFound |
LookUpOptions.DereferenceResultToCommit |
LookUpOptions.ThrowWhenCanNotBeDereferencedToACommit);
Proxy.git_repository_set_head_detached(repo.Handle, commit.Id, signature, logMessage);
using (var annotatedCommit = Proxy.git_annotated_commit_from_revspec(repo.Handle, targetIdentifier))
{
Proxy.git_repository_set_head_detached_from_annotated(repo.Handle, annotatedCommit);
}
}
}
else
{
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
"'{0}' is not a valid target type.", typeof (T)));
"'{0}' is not a valid target type.", typeof(T)));
}
return repo.Refs.Head;
}
internal Reference UpdateHeadTarget(ObjectId target, string logMessage)
{
Add("HEAD", target, logMessage, true);
return repo.Refs.Head;
}
internal Reference UpdateHeadTarget(Reference target, string logMessage)
{
Ensure.ArgumentConformsTo(target, r => (r is DirectReference || r is SymbolicReference), "target");
Add("HEAD", target, logMessage, true);
return repo.Refs.Head;
}
internal Reference UpdateHeadTarget(string target, string logMessage)
{
this.Add("HEAD", target, logMessage, true);
return repo.Refs.Head;
}
internal ReferenceSafeHandle RetrieveReferencePtr(string referenceName, bool shouldThrowIfNotFound = true)
{
ReferenceSafeHandle reference = Proxy.git_reference_lookup(repo.Handle, referenceName, shouldThrowIfNotFound);

Просмотреть файл

@ -38,11 +38,10 @@ namespace LibGit2Sharp
/// <param name="refsColl">The <see cref="ReferenceCollection"/> being worked with.</param>
/// <param name="name">The name of the reference to create.</param>
/// <param name="canonicalRefNameOrObjectish">The target which can be either the canonical name of a reference or a revparse spec.</param>
/// <param name="signature">The identity used for updating the reflog</param>
/// <param name="logMessage">The optional message to log in the <see cref="ReflogCollection"/> when adding the <see cref="Reference"/></param>
/// <param name="allowOverwrite">True to allow silent overwriting a potentially existing reference, false otherwise.</param>
/// <returns>A new <see cref="Reference"/>.</returns>
public static Reference Add(this ReferenceCollection refsColl, string name, string canonicalRefNameOrObjectish, Signature signature, string logMessage, bool allowOverwrite = false)
public static Reference Add(this ReferenceCollection refsColl, string name, string canonicalRefNameOrObjectish, string logMessage, bool allowOverwrite = false)
{
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNullOrEmptyString(canonicalRefNameOrObjectish, "canonicalRefNameOrObjectish");
@ -54,13 +53,13 @@ namespace LibGit2Sharp
if (refState == RefState.Exists)
{
return refsColl.Add(name, reference, signature, logMessage, allowOverwrite);
return refsColl.Add(name, reference, logMessage, allowOverwrite);
}
if (refState == RefState.DoesNotExistButLooksValid && gitObject == null)
{
using (ReferenceSafeHandle handle = Proxy.git_reference_symbolic_create(refsColl.repo.Handle, name, canonicalRefNameOrObjectish, allowOverwrite,
signature.OrDefault(refsColl.repo.Config), logMessage))
logMessage))
{
return Reference.BuildFromPtr<Reference>(handle, refsColl.repo);
}
@ -75,7 +74,7 @@ namespace LibGit2Sharp
}
refsColl.EnsureHasLog(name);
return refsColl.Add(name, gitObject.Id, signature, logMessage, allowOverwrite);
return refsColl.Add(name, gitObject.Id, logMessage, allowOverwrite);
}
/// <summary>
@ -88,7 +87,7 @@ namespace LibGit2Sharp
/// <returns>A new <see cref="Reference"/>.</returns>
public static Reference Add(this ReferenceCollection refsColl, string name, string canonicalRefNameOrObjectish, bool allowOverwrite = false)
{
return Add(refsColl, name, canonicalRefNameOrObjectish, null, null, allowOverwrite);
return Add(refsColl, name, canonicalRefNameOrObjectish, null, allowOverwrite);
}
/// <summary>
@ -97,10 +96,9 @@ namespace LibGit2Sharp
/// <param name="refsColl">The <see cref="ReferenceCollection"/> being worked with.</param>
/// <param name="directRef">The direct reference which target should be updated.</param>
/// <param name="objectish">The revparse spec of the target.</param>
/// <param name="signature">The identity used for updating the reflog</param>
/// <param name="logMessage">The optional message to log in the <see cref="ReflogCollection"/></param>
/// <returns>A new <see cref="Reference"/>.</returns>
public static Reference UpdateTarget(this ReferenceCollection refsColl, Reference directRef, string objectish, Signature signature, string logMessage)
public static Reference UpdateTarget(this ReferenceCollection refsColl, Reference directRef, string objectish, string logMessage)
{
Ensure.ArgumentNotNull(directRef, "directRef");
Ensure.ArgumentNotNull(objectish, "objectish");
@ -109,7 +107,7 @@ namespace LibGit2Sharp
Ensure.GitObjectIsNotNull(target, objectish);
return refsColl.UpdateTarget(directRef, target.Id, signature, logMessage);
return refsColl.UpdateTarget(directRef, target.Id, logMessage);
}
/// <summary>
@ -121,7 +119,7 @@ namespace LibGit2Sharp
/// <returns>A new <see cref="Reference"/>.</returns>
public static Reference UpdateTarget(this ReferenceCollection refsColl, Reference directRef, string objectish)
{
return UpdateTarget(refsColl, directRef, objectish, null, null);
return UpdateTarget(refsColl, directRef, objectish, null);
}
/// <summary>
@ -129,13 +127,12 @@ namespace LibGit2Sharp
/// </summary>
/// <param name="currentName">The canonical name of the reference to rename.</param>
/// <param name="newName">The new canonical name.</param>
/// <param name="signature">The identity used for updating the reflog</param>
/// <param name="logMessage">The optional message to log in the <see cref="ReflogCollection"/></param>
/// <param name="allowOverwrite">True to allow silent overwriting a potentially existing reference, false otherwise.</param>
/// <param name="refsColl">The <see cref="ReferenceCollection"/> being worked with.</param>
/// <returns>A new <see cref="Reference"/>.</returns>
public static Reference Rename(this ReferenceCollection refsColl, string currentName, string newName,
Signature signature = null, string logMessage = null, bool allowOverwrite = false)
string logMessage = null, bool allowOverwrite = false)
{
Ensure.ArgumentNotNullOrEmptyString(currentName, "currentName");
@ -148,7 +145,7 @@ namespace LibGit2Sharp
"Reference '{0}' doesn't exist. One cannot move a non existing reference.", currentName));
}
return refsColl.Rename(reference, newName, signature, logMessage, allowOverwrite);
return refsColl.Rename(reference, newName, logMessage, allowOverwrite);
}
/// <summary>
@ -157,19 +154,16 @@ namespace LibGit2Sharp
/// <param name="refsColl">The <see cref="ReferenceCollection"/> being worked with.</param>
/// <param name="name">The canonical name of the reference.</param>
/// <param name="canonicalRefNameOrObjectish">The target which can be either the canonical name of a reference or a revparse spec.</param>
/// <param name="signature">The identity used for updating the reflog</param>
/// <param name="logMessage">The optional message to log in the <see cref="ReflogCollection"/> of the <paramref name="name"/> reference.</param>
/// <returns>A new <see cref="Reference"/>.</returns>
public static Reference UpdateTarget(this ReferenceCollection refsColl, string name, string canonicalRefNameOrObjectish, Signature signature, string logMessage)
public static Reference UpdateTarget(this ReferenceCollection refsColl, string name, string canonicalRefNameOrObjectish, string logMessage)
{
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNullOrEmptyString(canonicalRefNameOrObjectish, "canonicalRefNameOrObjectish");
signature = signature.OrDefault(refsColl.repo.Config);
if (name == "HEAD")
{
return refsColl.UpdateHeadTarget(canonicalRefNameOrObjectish, signature, logMessage);
return refsColl.UpdateHeadTarget(canonicalRefNameOrObjectish, logMessage);
}
Reference reference = refsColl[name];
@ -177,7 +171,7 @@ namespace LibGit2Sharp
var directReference = reference as DirectReference;
if (directReference != null)
{
return refsColl.UpdateTarget(directReference, canonicalRefNameOrObjectish, signature, logMessage);
return refsColl.UpdateTarget(directReference, canonicalRefNameOrObjectish, logMessage);
}
var symbolicReference = reference as SymbolicReference;
@ -192,7 +186,7 @@ namespace LibGit2Sharp
throw new ArgumentException(String.Format(CultureInfo.InvariantCulture, "The reference specified by {0} is a Symbolic reference, you must provide a reference canonical name as the target.", name), "canonicalRefNameOrObjectish");
}
return refsColl.UpdateTarget(symbolicReference, targetRef, signature, logMessage);
return refsColl.UpdateTarget(symbolicReference, targetRef, logMessage);
}
throw new LibGit2SharpException(string.Format(CultureInfo.InvariantCulture, "Reference '{0}' has an unexpected type ('{1}').", name, reference.GetType()));
@ -207,7 +201,7 @@ namespace LibGit2Sharp
/// <returns>A new <see cref="Reference"/>.</returns>
public static Reference UpdateTarget(this ReferenceCollection refsColl, string name, string canonicalRefNameOrObjectish)
{
return UpdateTarget(refsColl, name, canonicalRefNameOrObjectish, null, null);
return UpdateTarget(refsColl, name, canonicalRefNameOrObjectish, null);
}
/// <summary>

Просмотреть файл

@ -92,6 +92,11 @@ namespace LibGit2Sharp
configurationGlobalFilePath = options.GlobalConfigurationLocation;
configurationXDGFilePath = options.XdgConfigurationLocation;
configurationSystemFilePath = options.SystemConfigurationLocation;
if (options.Identity != null)
{
Proxy.git_repository_set_ident(handle, options.Identity.Name, options.Identity.Email);
}
}
if (!isBare)
@ -602,9 +607,8 @@ namespace LibGit2Sharp
/// </summary>
/// <param name="committishOrBranchSpec">A revparse spec for the commit or branch to checkout.</param>
/// <param name="options"><see cref="CheckoutOptions"/> controlling checkout behavior.</param>
/// <param name="signature">Identity for use when updating the reflog.</param>
/// <returns>The <see cref="Branch"/> that was checked out.</returns>
public Branch Checkout(string committishOrBranchSpec, CheckoutOptions options, Signature signature)
public Branch Checkout(string committishOrBranchSpec, CheckoutOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(committishOrBranchSpec, "committishOrBranchSpec");
Ensure.ArgumentNotNull(options, "options");
@ -626,7 +630,7 @@ namespace LibGit2Sharp
if (reference.IsLocalBranch())
{
Branch branch = Branches[reference.CanonicalName];
return Checkout(branch, options, signature);
return Checkout(branch, options);
}
}
@ -640,7 +644,7 @@ namespace LibGit2Sharp
}
Commit commit = obj.DereferenceToCommit(true);
Checkout(commit.Tree, options, commit.Id.Sha, committishOrBranchSpec, signature);
Checkout(commit.Tree, options, committishOrBranchSpec);
return Head;
}
@ -652,9 +656,8 @@ namespace LibGit2Sharp
/// </summary>
/// <param name="branch">The <see cref="Branch"/> to check out.</param>
/// <param name="options"><see cref="CheckoutOptions"/> controlling checkout behavior.</param>
/// <param name="signature">Identity for use when updating the reflog.</param>
/// <returns>The <see cref="Branch"/> that was checked out.</returns>
public Branch Checkout(Branch branch, CheckoutOptions options, Signature signature)
public Branch Checkout(Branch branch, CheckoutOptions options)
{
Ensure.ArgumentNotNull(branch, "branch");
Ensure.ArgumentNotNull(options, "options");
@ -671,11 +674,11 @@ namespace LibGit2Sharp
string.Equals(Refs[branch.CanonicalName].TargetIdentifier, branch.Tip.Id.Sha,
StringComparison.OrdinalIgnoreCase))
{
Checkout(branch.Tip.Tree, options, branch.CanonicalName, branch.Name, signature);
Checkout(branch.Tip.Tree, options, branch.CanonicalName);
}
else
{
Checkout(branch.Tip.Tree, options, branch.Tip.Id.Sha, branch.Name, signature);
Checkout(branch.Tip.Tree, options, branch.Tip.Id.Sha);
}
return Head;
@ -689,14 +692,13 @@ namespace LibGit2Sharp
/// </summary>
/// <param name="commit">The <see cref="LibGit2Sharp.Commit"/> to check out.</param>
/// <param name="options"><see cref="CheckoutOptions"/> controlling checkout behavior.</param>
/// <param name="signature">Identity for use when updating the reflog.</param>
/// <returns>The <see cref="Branch"/> that was checked out.</returns>
public Branch Checkout(Commit commit, CheckoutOptions options, Signature signature)
public Branch Checkout(Commit commit, CheckoutOptions options)
{
Ensure.ArgumentNotNull(commit, "commit");
Ensure.ArgumentNotNull(options, "options");
Checkout(commit.Tree, options, commit.Id.Sha, commit.Id.Sha, signature);
Checkout(commit.Tree, options, commit.Id.Sha);
return Head;
}
@ -707,22 +709,15 @@ namespace LibGit2Sharp
/// </summary>
/// <param name="tree">The <see cref="Tree"/> to checkout.</param>
/// <param name="checkoutOptions"><see cref="CheckoutOptions"/> controlling checkout behavior.</param>
/// <param name="headTarget">Target for the new HEAD.</param>
/// <param name="refLogHeadSpec">The spec which will be written as target in the reflog.</param>
/// <param name="signature">Identity for use when updating the reflog.</param>
private void Checkout(
Tree tree,
CheckoutOptions checkoutOptions,
string headTarget, string refLogHeadSpec, Signature signature)
string refLogHeadSpec)
{
var previousHeadName = Info.IsHeadDetached ? Head.Tip.Sha : Head.Name;
CheckoutTree(tree, null, checkoutOptions);
Refs.UpdateTarget("HEAD", headTarget, signature,
string.Format(
CultureInfo.InvariantCulture,
"checkout: moving from {0} to {1}", previousHeadName, refLogHeadSpec));
Refs.MoveHeadTarget(refLogHeadSpec);
}
/// <summary>
@ -750,11 +745,9 @@ namespace LibGit2Sharp
/// </summary>
/// <param name="resetMode">Flavor of reset operation to perform.</param>
/// <param name="commit">The target commit object.</param>
/// <param name="signature">Identity for use when updating the reflog.</param>
/// <param name="logMessage">Message to use when updating the reflog.</param>
public void Reset(ResetMode resetMode, Commit commit, Signature signature, string logMessage)
public void Reset(ResetMode resetMode, Commit commit)
{
Reset(resetMode, commit, new CheckoutOptions(), signature, logMessage);
Reset(resetMode, commit, new CheckoutOptions());
}
/// <summary>
@ -764,23 +757,14 @@ namespace LibGit2Sharp
/// <param name="resetMode">Flavor of reset operation to perform.</param>
/// <param name="commit">The target commit object.</param>
/// <param name="opts">Collection of parameters controlling checkout behavior.</param>
/// <param name="signature">Identity for use when updating the reflog.</param>
/// <param name="logMessage">Message to use when updating the reflog.</param>
private void Reset(ResetMode resetMode, Commit commit, IConvertableToGitCheckoutOpts opts, Signature signature, string logMessage)
private void Reset(ResetMode resetMode, Commit commit, IConvertableToGitCheckoutOpts opts)
{
Ensure.ArgumentNotNull(commit, "commit");
if (logMessage == null)
{
logMessage = string.Format(
CultureInfo.InvariantCulture,
"reset: moving to {0}", commit.Sha);
}
using (GitCheckoutOptsWrapper checkoutOptionsWrapper = new GitCheckoutOptsWrapper(opts))
{
var options = checkoutOptionsWrapper.Options;
Proxy.git_reset(handle, commit.Id, resetMode, ref options, signature.OrDefault(Config), logMessage);
Proxy.git_reset(handle, commit.Id, resetMode, ref options);
}
}
@ -904,7 +888,7 @@ namespace LibGit2Sharp
{
if (reference is DirectReference)
{
Refs.UpdateTarget(reference, commit.Id, commit.Committer, reflogMessage);
Refs.UpdateTarget(reference, commit.Id, reflogMessage);
return;
}
@ -914,7 +898,7 @@ namespace LibGit2Sharp
if (reference == null)
{
Refs.Add(symRef.TargetIdentifier, commit.Id, commit.Committer, reflogMessage);
Refs.Add(symRef.TargetIdentifier, commit.Id, reflogMessage);
return;
}
}
@ -1278,7 +1262,7 @@ namespace LibGit2Sharp
throw new LibGit2SharpException("Unable to perform Fast-Forward merge with mith multiple merge heads.");
}
mergeResult = FastForwardMerge(annotatedCommits[0], merger, options);
mergeResult = FastForwardMerge(annotatedCommits[0], options);
}
else if (mergeAnalysis.HasFlag(GitMergeAnalysis.GIT_MERGE_ANALYSIS_NORMAL))
{
@ -1294,7 +1278,7 @@ namespace LibGit2Sharp
throw new LibGit2SharpException("Unable to perform Fast-Forward merge with mith multiple merge heads.");
}
mergeResult = FastForwardMerge(annotatedCommits[0], merger, options);
mergeResult = FastForwardMerge(annotatedCommits[0], options);
}
else
{
@ -1374,10 +1358,9 @@ namespace LibGit2Sharp
/// Perform a fast-forward merge.
/// </summary>
/// <param name="annotatedCommit">The merge head handle to fast-forward merge.</param>
/// <param name="merger">The <see cref="Signature"/> of who is performing the merge.</param>
/// <param name="options">Options controlling merge behavior.</param>
/// <returns>The <see cref="MergeResult"/> of the merge.</returns>
private MergeResult FastForwardMerge(GitAnnotatedCommitHandle annotatedCommit, Signature merger, MergeOptions options)
private MergeResult FastForwardMerge(GitAnnotatedCommitHandle annotatedCommit, MergeOptions options)
{
ObjectId id = Proxy.git_annotated_commit_id(annotatedCommit);
Commit fastForwardCommit = (Commit) Lookup(id, ObjectType.Commit);
@ -1394,12 +1377,12 @@ namespace LibGit2Sharp
if (reference == null)
{
// Reference does not exist, create it.
Refs.Add(Refs.Head.TargetIdentifier, fastForwardCommit.Id, merger, refLogEntry);
Refs.Add(Refs.Head.TargetIdentifier, fastForwardCommit.Id, refLogEntry);
}
else
{
// Update target reference.
Refs.UpdateTarget(reference, fastForwardCommit.Id.Sha, merger, refLogEntry);
Refs.UpdateTarget(reference, fastForwardCommit.Id.Sha, refLogEntry);
}
return new MergeResult(MergeStatus.FastForward, fastForwardCommit);

Просмотреть файл

@ -121,11 +121,12 @@ namespace LibGit2Sharp
/// </summary>
/// <param name="repository">The <see cref="Repository"/> being worked with.</param>
/// <param name="branchName">The name of the branch to create.</param>
/// <param name="signature">Identification for use when updating the reflog</param>
/// <param name="logMessage">Message to append to the reflog</param>
public static Branch CreateBranch(this IRepository repository, string branchName, Signature signature = null, string logMessage = null)
public static Branch CreateBranch(this IRepository repository, string branchName)
{
return CreateBranch(repository, branchName, "HEAD", signature, logMessage);
var head = repository.Head;
var reflogName = head is DetachedHead ? head.Tip.Sha : head.Name;
return CreateBranch(repository, branchName, reflogName);
}
/// <summary>
@ -134,11 +135,9 @@ namespace LibGit2Sharp
/// <param name="repository">The <see cref="Repository"/> being worked with.</param>
/// <param name="branchName">The name of the branch to create.</param>
/// <param name="target">The commit which should be pointed at by the Branch.</param>
/// <param name="signature">Identification for use when updating the reflog</param>
/// <param name="logMessage">Message to append to the reflog</param>
public static Branch CreateBranch(this IRepository repository, string branchName, Commit target, Signature signature = null, string logMessage = null)
public static Branch CreateBranch(this IRepository repository, string branchName, Commit target)
{
return repository.Branches.Add(branchName, target, signature, logMessage);
return repository.Branches.Add(branchName, target);
}
/// <summary>
@ -147,11 +146,9 @@ namespace LibGit2Sharp
/// <param name="repository">The <see cref="Repository"/> being worked with.</param>
/// <param name="branchName">The name of the branch to create.</param>
/// <param name="committish">The revparse spec for the target commit.</param>
/// <param name="signature">Identification for use when updating the reflog</param>
/// <param name="logMessage">Message to append to the reflog</param>
public static Branch CreateBranch(this IRepository repository, string branchName, string committish, Signature signature = null, string logMessage = null)
public static Branch CreateBranch(this IRepository repository, string branchName, string committish)
{
return repository.Branches.Add(branchName, committish, signature, logMessage);
return repository.Branches.Add(branchName, committish);
}
/// <summary>
@ -161,16 +158,13 @@ namespace LibGit2Sharp
/// <param name="repository">The <see cref="Repository"/> being worked with.</param>
/// <param name="resetMode">Flavor of reset operation to perform.</param>
/// <param name="committish">A revparse spec for the target commit object.</param>
/// <param name="signature">Identification for use when updating the reflog</param>
/// <param name="logMessage">Message to append to the reflog</param>
public static void Reset(this IRepository repository, ResetMode resetMode, string committish = "HEAD",
Signature signature = null, string logMessage = null)
public static void Reset(this IRepository repository, ResetMode resetMode, string committish = "HEAD")
{
Ensure.ArgumentNotNullOrEmptyString(committish, "committish");
Commit commit = LookUpCommit(repository, committish);
repository.Reset(resetMode, commit, signature, logMessage);
repository.Reset(resetMode, commit);
}
/// <summary>
@ -260,12 +254,11 @@ namespace LibGit2Sharp
/// </summary>
/// <param name="repository">The <see cref="Repository"/> being worked with.</param>
/// <param name="commitOrBranchSpec">A revparse spec for the commit or branch to checkout.</param>
/// <param name="signature">The identity used for updating the reflog</param>
/// <returns>The <see cref="Branch"/> that was checked out.</returns>
public static Branch Checkout(this IRepository repository, string commitOrBranchSpec, Signature signature = null)
public static Branch Checkout(this IRepository repository, string commitOrBranchSpec)
{
CheckoutOptions options = new CheckoutOptions();
return repository.Checkout(commitOrBranchSpec, options, signature);
return repository.Checkout(commitOrBranchSpec, options);
}
/// <summary>
@ -277,12 +270,11 @@ namespace LibGit2Sharp
/// </summary>
/// <param name="repository">The <see cref="Repository"/> being worked with.</param>
/// <param name="branch">The <see cref="Branch"/> to check out.</param>
/// <param name="signature">The identity used for updating the reflog</param>
/// <returns>The <see cref="Branch"/> that was checked out.</returns>
public static Branch Checkout(this IRepository repository, Branch branch, Signature signature = null)
public static Branch Checkout(this IRepository repository, Branch branch)
{
CheckoutOptions options = new CheckoutOptions();
return repository.Checkout(branch, options, signature);
return repository.Checkout(branch, options);
}
/// <summary>
@ -293,12 +285,11 @@ namespace LibGit2Sharp
/// </summary>
/// <param name="repository">The <see cref="Repository"/> being worked with.</param>
/// <param name="commit">The <see cref="LibGit2Sharp.Commit"/> to check out.</param>
/// <param name="signature">The identity used for updating the reflog</param>
/// <returns>The <see cref="Branch"/> that was checked out.</returns>
public static Branch Checkout(this IRepository repository, Commit commit, Signature signature = null)
public static Branch Checkout(this IRepository repository, Commit commit)
{
CheckoutOptions options = new CheckoutOptions();
return repository.Checkout(commit, options, signature);
return repository.Checkout(commit, options);
}
internal static string BuildRelativePathFrom(this Repository repo, string path)
@ -476,7 +467,7 @@ namespace LibGit2Sharp
/// <returns>The <see cref="Branch"/> that was checked out.</returns>
public static Branch Checkout(this IRepository repository, Branch branch, CheckoutOptions options)
{
return repository.Checkout(branch, options, null);
return repository.Checkout(branch, options);
}
/// <summary>
@ -491,7 +482,7 @@ namespace LibGit2Sharp
/// <returns>The <see cref="Branch"/> that was checked out.</returns>
public static Branch Checkout(this IRepository repository, Commit commit, CheckoutOptions options)
{
return repository.Checkout(commit, options, null);
return repository.Checkout(commit, options);
}
/// <summary>
@ -507,7 +498,7 @@ namespace LibGit2Sharp
/// <returns>The <see cref="Branch"/> that was checked out.</returns>
public static Branch Checkout(this IRepository repository, string committishOrBranchSpec, CheckoutOptions options)
{
return repository.Checkout(committishOrBranchSpec, options, null);
return repository.Checkout(committishOrBranchSpec, options);
}
/// <summary>
@ -533,7 +524,7 @@ namespace LibGit2Sharp
/// <param name="commit">The target commit object.</param>
public static void Reset(this IRepository repository, ResetMode resetMode, Commit commit)
{
repository.Reset(resetMode, commit, null, null);
repository.Reset(resetMode, commit);
}
/// <summary>

Просмотреть файл

@ -52,5 +52,15 @@
/// </para>
/// </summary>
public string SystemConfigurationLocation { get; set; }
/// <summary>
/// Overrides the default identity to be used when creating reflog entries.
/// <para>
/// When unset the identity will be retreived from the repository's configuration.
/// When no identity can be found in the repository configuration stores, a fake
/// identity ("unknown" as both name and email), will be used.
/// </para>
/// </summary>
public Identity Identity { get; set; }
}
}

Просмотреть файл

@ -1,7 +1,7 @@
namespace LibGit2Sharp
{
/// <summary>
/// Specifies the kind of operation that <see cref="IRepository.Reset(LibGit2Sharp.ResetMode, Commit, Signature, string)"/> should perform.
/// Specifies the kind of operation that <see cref="IRepository.Reset(LibGit2Sharp.ResetMode, Commit)"/> should perform.
/// </summary>
public enum ResetMode
{

Просмотреть файл

@ -1,21 +0,0 @@
using System;
namespace LibGit2Sharp
{
/// <summary>
/// Provides helper overloads for a <see cref="Signature"/>
/// </summary>
internal static class SignatureExtensions
{
/// <summary>
/// If the signature is null, return the default using configuration values.
/// </summary>
/// <param name="signature">The signature to test</param>
/// <param name="config">The configuration to query for default values</param>
/// <returns>A valid <see cref="Signature"/></returns>
public static Signature OrDefault(this Signature signature, Configuration config)
{
return signature ?? config.BuildSignature(DateTimeOffset.Now);
}
}
}

Просмотреть файл

@ -108,7 +108,7 @@ namespace LibGit2Sharp
Version = 1,
CheckoutOptions = gitCheckoutOptions,
RemoteCallbacks = gitRemoteCallbacks,
CloneCheckoutStrategy = CheckoutStrategy.GIT_CHECKOUT_SAFE_CREATE
CloneCheckoutStrategy = CheckoutStrategy.GIT_CHECKOUT_SAFE
};
Proxy.git_submodule_update(handle, options.Init, ref gitSubmoduleUpdateOpts);

Просмотреть файл

@ -1 +1 @@
e0902fbce7d14631bd02091c1c70cde3e68f78ab
9bbc8f350b80a5a6e94651ec667cf9e5d545b317

@ -1 +1 @@
Subproject commit e0902fbce7d14631bd02091c1c70cde3e68f78ab
Subproject commit 9bbc8f350b80a5a6e94651ec667cf9e5d545b317

Просмотреть файл

@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Condition=" '$(OS)' == 'Windows_NT' ">
<None Include="$(MSBuildThisFileDirectory)\..\..\lib\net40\NativeBinaries\amd64\git2-e0902fb.dll">
<Link>NativeBinaries\amd64\git2-e0902fb.dll</Link>
<None Include="$(MSBuildThisFileDirectory)\..\..\lib\net40\NativeBinaries\amd64\git2-9bbc8f3.dll">
<Link>NativeBinaries\amd64\git2-9bbc8f3.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)\..\..\lib\net40\NativeBinaries\amd64\git2-e0902fb.pdb">
<Link>NativeBinaries\amd64\git2-e0902fb.pdb</Link>
<None Include="$(MSBuildThisFileDirectory)\..\..\lib\net40\NativeBinaries\amd64\git2-9bbc8f3.pdb">
<Link>NativeBinaries\amd64\git2-9bbc8f3.pdb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)\..\..\lib\net40\NativeBinaries\x86\git2-e0902fb.dll">
<Link>NativeBinaries\x86\git2-e0902fb.dll</Link>
<None Include="$(MSBuildThisFileDirectory)\..\..\lib\net40\NativeBinaries\x86\git2-9bbc8f3.dll">
<Link>NativeBinaries\x86\git2-9bbc8f3.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)\..\..\lib\net40\NativeBinaries\x86\git2-e0902fb.pdb">
<Link>NativeBinaries\x86\git2-e0902fb.pdb</Link>
<None Include="$(MSBuildThisFileDirectory)\..\..\lib\net40\NativeBinaries\x86\git2-9bbc8f3.pdb">
<Link>NativeBinaries\x86\git2-9bbc8f3.pdb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>