Skip to content

Commit

Permalink
Ported jgit commit ddaeae3c23bc31f1cc6cd7c8ed343d836c56bed4. Seems th…
Browse files Browse the repository at this point in the history
…at portions of it have already been ported before.
  • Loading branch information
nulltoken committed Oct 5, 2009
1 parent bc2c7e1 commit 3f67e85
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions Tests/RefUpdateTest.cs
Expand Up @@ -335,6 +335,72 @@ public void testUpdateRefNoChange()
Assert.AreEqual(pid, db.Resolve("refs/heads/master")); Assert.AreEqual(pid, db.Resolve("refs/heads/master"));
} }


/**
* Test case originating from
* <a href="http://bugs.eclipse.org/285991">bug 285991</a>
*
* Make sure the in memory cache is updated properly after
* update of symref. This one did not fail because the
* ref was packed due to implementation issues.
*
* @throws Exception
*/
[Test]
public void testRefsCacheAfterUpdate()
{
// Do not use the defalt repo for this case.
Dictionary<string, Ref> allRefs = db.getAllRefs();
ObjectId oldValue = db.Resolve("HEAD");
ObjectId newValue = db.Resolve("HEAD^");
// first make HEAD refer to loose ref
RefUpdate updateRef = db.UpdateRef(Constants.HEAD);
updateRef.IsForceUpdate = true;
updateRef.NewObjectId = newValue;
RefUpdate.RefUpdateResult update = updateRef.Update();
Assert.AreEqual(RefUpdate.RefUpdateResult.Forced, update);

// now update that ref
updateRef = db.UpdateRef(Constants.HEAD);
updateRef.IsForceUpdate = true;
updateRef.NewObjectId = oldValue;
update = updateRef.Update();
Assert.AreEqual(RefUpdate.RefUpdateResult.FastForward, update);
allRefs = db.getAllRefs();
Assert.AreEqual("refs/heads/master", allRefs.GetValue("refs/heads/master").Name);
Assert.AreEqual("refs/heads/master", allRefs.GetValue("refs/heads/master").OriginalName);
Assert.AreEqual("refs/heads/master", allRefs.GetValue("HEAD").Name);
Assert.AreEqual("HEAD", allRefs.GetValue("HEAD").OriginalName);
}

/**
* Test case originating from
* <a href="http://bugs.eclipse.org/285991">bug 285991</a>
*
* Make sure the in memory cache is updated properly after
* update of symref.
*
* @throws Exception
*/

[Test]
public void testRefsCacheAfterUpdateLoosOnly()
{
// Do not use the defalt repo for this case.
Dictionary<string, Ref> allRefs = db.getAllRefs();
ObjectId oldValue = db.Resolve("HEAD");
db.WriteSymref(Constants.HEAD, "refs/heads/newref");
RefUpdate updateRef = db.UpdateRef(Constants.HEAD);
updateRef.IsForceUpdate = true;
updateRef.NewObjectId = oldValue;
RefUpdate.RefUpdateResult update = updateRef.Update();
Assert.AreEqual(RefUpdate.RefUpdateResult.New, update);
allRefs = db.getAllRefs();
Assert.AreEqual("refs/heads/newref", allRefs.GetValue("HEAD").Name);
Assert.AreEqual("HEAD", allRefs.GetValue("HEAD").OriginalName);
Assert.AreEqual("refs/heads/newref", allRefs.GetValue("refs/heads/newref").Name);
Assert.AreEqual("refs/heads/newref", allRefs.GetValue("refs/heads/newref").OriginalName);
}

/** /**
* Try modify a ref, but get wrong expected old value * Try modify a ref, but get wrong expected old value
* *
Expand Down

0 comments on commit 3f67e85

Please sign in to comment.