|
|
@@ -42,6 +42,7 @@ |
|
|
|
*/ |
|
|
|
package org.eclipse.jgit.api; |
|
|
|
|
|
|
|
import static org.eclipse.jgit.api.ResetCommand.ResetType.HARD; |
|
|
|
import static org.junit.Assert.assertEquals; |
|
|
|
import static org.junit.Assert.assertFalse; |
|
|
|
import static org.junit.Assert.assertNotNull; |
|
|
@@ -305,6 +306,25 @@ public class ResetCommandTest extends RepositoryTestCase { |
|
|
|
assertFalse(inIndex(untrackedFile.getName())); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testHardResetOnTag() throws Exception { |
|
|
|
setupRepository(); |
|
|
|
String tagName = "initialtag"; |
|
|
|
git.tag().setName(tagName).setObjectId(secondCommit) |
|
|
|
.setMessage("message").call(); |
|
|
|
|
|
|
|
DirCacheEntry preReset = DirCache.read(db.getIndexFile(), db.getFS()) |
|
|
|
.getEntry(indexFile.getName()); |
|
|
|
assertNotNull(preReset); |
|
|
|
|
|
|
|
git.add().addFilepattern(untrackedFile.getName()).call(); |
|
|
|
|
|
|
|
git.reset().setRef(tagName).setMode(HARD).call(); |
|
|
|
|
|
|
|
ObjectId head = db.resolve(Constants.HEAD); |
|
|
|
assertTrue(head.equals(secondCommit)); |
|
|
|
} |
|
|
|
|
|
|
|
private void assertReflog(ObjectId prevHead, ObjectId head) |
|
|
|
throws IOException { |
|
|
|
// Check the reflog for HEAD |