Permalink
Browse files

Updated from JGit

----------------------------------------------------
JGit commit 770c733687d9f2f71f30822f9691427bf83b7577
PullCommand: Use short ref name in merge message

Add a test case for PullCommand for the successful merge case and test
that the short ref name is used.

Change-Id: I16cbbc88595f73e5512f984e67f93f87ee0fe242
Signed-off-by: Robin Stocker <robin@nibor.org>
  • Loading branch information...
1 parent 9ab4d09 commit 7cf5227411bdd13cbe47a7ea2fd32a3800e98976 @slluis slluis committed Mar 23, 2011
Showing with 48 additions and 7 deletions.
  1. +34 −3 NGit.Test/NGit.Api/PullCommandTest.cs
  2. +3 −2 NGit/NGit.Api/PullCommand.cs
  3. +10 −1 gen/cs.patch
  4. +1 −1 gen/lastrev
@@ -43,6 +43,7 @@ written permission.
using NGit;
using NGit.Api;
+using NGit.Revwalk;
using NGit.Storage.File;
using NGit.Transport;
using Sharpen;
@@ -93,6 +94,36 @@ public virtual void TestPullFastForward()
/// <exception cref="System.Exception"></exception>
[NUnit.Framework.Test]
+ public virtual void TestPullMerge()
+ {
+ PullResult res = target.Pull().Call();
+ // nothing to update since we don't have different data yet
+ NUnit.Framework.Assert.IsTrue(res.GetFetchResult().GetTrackingRefUpdates().IsEmpty
+ ());
+ NUnit.Framework.Assert.IsTrue(res.GetMergeResult().GetMergeStatus().Equals(MergeStatus
+ .ALREADY_UP_TO_DATE));
+ WriteToFile(sourceFile, "Source change");
+ source.Add().AddFilepattern("SomeFile.txt");
+ RevCommit sourceCommit = source.Commit().SetMessage("Source change in remote").Call
+ ();
+ FilePath targetFile2 = new FilePath(dbTarget.WorkTree, "OtherFile.txt");
+ WriteToFile(targetFile2, "Unconflicting change");
+ target.Add().AddFilepattern("OtherFile.txt").Call();
+ RevCommit targetCommit = target.Commit().SetMessage("Unconflicting change in local"
+ ).Call();
+ res = target.Pull().Call();
+ MergeCommandResult mergeResult = res.GetMergeResult();
+ ObjectId[] mergedCommits = mergeResult.GetMergedCommits();
+ NUnit.Framework.Assert.AreEqual(targetCommit.Id, mergedCommits[0]);
+ NUnit.Framework.Assert.AreEqual(sourceCommit.Id, mergedCommits[1]);
+ RevCommit mergeCommit = new RevWalk(dbTarget).ParseCommit(mergeResult.GetNewHead(
+ ));
+ string message = "Merge branch 'master' of " + db.WorkTree;
+ NUnit.Framework.Assert.AreEqual(message, mergeCommit.GetShortMessage());
+ }
+
+ /// <exception cref="System.Exception"></exception>
+ [NUnit.Framework.Test]
public virtual void TestPullConflict()
{
PullResult res = target.Pull().Call();
@@ -111,8 +142,8 @@ public virtual void TestPullConflict()
target.Add().AddFilepattern("SomeFile.txt").Call();
target.Commit().SetMessage("Target change in local").Call();
res = target.Pull().Call();
- string sourceChangeString = "Source change\n>>>>>>> branch 'refs/heads/master' of "
- + target.GetRepository().GetConfig().GetString("remote", "origin", "url");
+ string sourceChangeString = "Source change\n>>>>>>> branch 'master' of " + target
+ .GetRepository().GetConfig().GetString("remote", "origin", "url");
NUnit.Framework.Assert.IsFalse(res.GetFetchResult().GetTrackingRefUpdates().IsEmpty
());
NUnit.Framework.Assert.AreEqual(res.GetMergeResult().GetMergeStatus(), MergeStatus
@@ -147,7 +178,7 @@ public virtual void TestPullLocalConflict()
target.Add().AddFilepattern("SomeFile.txt").Call();
target.Commit().SetMessage("Source change in based on master").Call();
res = target.Pull().Call();
- string sourceChangeString = "Master change\n>>>>>>> branch 'refs/heads/master' of local repository";
+ string sourceChangeString = "Master change\n>>>>>>> branch 'master' of local repository";
NUnit.Framework.Assert.IsNull(res.GetFetchResult());
NUnit.Framework.Assert.AreEqual(res.GetMergeResult().GetMergeStatus(), MergeStatus
.CONFLICTING);
@@ -277,8 +277,9 @@ public override PullResult Call()
else
{
MergeCommand merge = new MergeCommand(repo);
- merge.Include("branch \'" + remoteBranchName + "\' of " + remoteUri, commitToMerge
- );
+ string name = "branch \'" + Repository.ShortenRefName(remoteBranchName) + "\' of "
+ + remoteUri;
+ merge.Include(name, commitToMerge);
MergeCommandResult mergeRes;
try
{
View
@@ -931,9 +931,18 @@ index 3ba79a5..96758c2 100644
if (merger is ResolveMerger)
{
diff --git a/NGit/NGit.Api/MergeCommandResult.cs b/NGit/NGit.Api/MergeCommandResult.cs
-index a24aef5..df27a4c 100644
+index a24aef5..6352029 100644
--- a/NGit/NGit.Api/MergeCommandResult.cs
+++ b/NGit/NGit.Api/MergeCommandResult.cs
+@@ -92,7 +92,7 @@ namespace NGit.Api
+ /// <see cref="NGit.Merge.MergeStrategy">NGit.Merge.MergeStrategy</see>
+ /// </param>
+ public MergeCommandResult(ObjectId newHead, ObjectId @base, ObjectId[] mergedCommits
+- , MergeStatus mergeStatus, IDictionary<string, NGit.Merge.MergeResult<object>> lowLevelResults
++ , MergeStatus mergeStatus, IDictionary<string, NGit.Merge.MergeResult<Sequence>> lowLevelResults
+ , MergeStrategy mergeStrategy) : this(newHead, @base, mergedCommits, mergeStatus
+ , mergeStrategy, lowLevelResults, null)
+ {
@@ -118,7 +118,7 @@ namespace NGit.Api
/// <param name="description">a user friendly description of the merge result</param>
public MergeCommandResult(ObjectId newHead, ObjectId @base, ObjectId[] mergedCommits
View
@@ -1 +1 @@
-dcf7bd9a8f7acafbd1461dc0414aded2db030983
+770c733687d9f2f71f30822f9691427bf83b7577

0 comments on commit 7cf5227

Please sign in to comment.