From 058c74d8adcfb5ef0eed203a64b7f9ff65e87c8c Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 10 May 2012 15:56:21 -0700 Subject: Update ORIG_HEAD when resetting Write the old object id from the RefUpdate to the ORIG_HEAD file after the update completes. Add two new convenience methods to Repository to read and write the ORIG_HEAD reference similar to the methods for reading/writing CHERRY_PICK_HEAD and MERGE_HEAD. Bug: 375525 Change-Id: I120b3b2cd3b1ddae88fce435285bae15cbf96f5e --- org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java | 4 +++- org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'org.eclipse.jgit.test') diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java index 648ef6f01b..cf2dead5a4 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java @@ -293,7 +293,8 @@ public class RebaseCommandTest extends RepositoryTestCase { // change third line in topic branch writeTrashFile(FILE1, "1\n2\n3\ntopic\n"); git.add().addFilepattern(FILE1).call(); - git.commit().setMessage("change file1 in topic").call(); + RevCommit origHead = git.commit().setMessage("change file1 in topic") + .call(); RebaseResult res = git.rebase().setUpstream("refs/heads/master").call(); assertEquals(Status.OK, res.getStatus()); @@ -302,6 +303,7 @@ public class RebaseCommandTest extends RepositoryTestCase { assertEquals("refs/heads/topic", db.getFullBranch()); assertEquals(lastMasterChange, new RevWalk(db).parseCommit( db.resolve(Constants.HEAD)).getParent(0)); + assertEquals(origHead, db.readOrigHead()); } @Test diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java index f16d436d94..0806cf0dd0 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java @@ -149,6 +149,7 @@ public class ResetCommandTest extends RepositoryTestCase { assertFalse(inHead(fileInIndexPath)); assertFalse(inIndex(indexFile.getName())); assertReflog(prevHead, head); + assertEquals(prevHead, db.readOrigHead()); } @Test @@ -185,6 +186,7 @@ public class ResetCommandTest extends RepositoryTestCase { assertFalse(inHead(fileInIndexPath)); assertTrue(inIndex(indexFile.getName())); assertReflog(prevHead, head); + assertEquals(prevHead, db.readOrigHead()); } @Test @@ -206,6 +208,7 @@ public class ResetCommandTest extends RepositoryTestCase { assertFalse(inIndex(indexFile.getName())); assertReflog(prevHead, head); + assertEquals(prevHead, db.readOrigHead()); } @Test -- cgit v1.2.3