Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Stocker2013-04-27 11:30:11 +0000
committerGerrit Code Review @ Eclipse.org2013-05-03 13:18:09 +0000
commite8f720335f86198d4dc99af10ffb6f52e40ba06f (patch)
tree4b583d166641681fe5d0e2a37e8a80729d93edf2
parent9d9cdd780cf6c4b8f67c688a1efc006a17b00121 (diff)
downloadjgit-e8f720335f86198d4dc99af10ffb6f52e40ba06f.tar.gz
jgit-e8f720335f86198d4dc99af10ffb6f52e40ba06f.tar.xz
jgit-e8f720335f86198d4dc99af10ffb6f52e40ba06f.zip
Add test for RefUpdate delete without HEAD
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefUpdateTest.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefUpdateTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefUpdateTest.java
index 7388dce237..21df179ad8 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefUpdateTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefUpdateTest.java
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2008, Charles O'Farrell <charleso@charleso.org>
* Copyright (C) 2009-2010, Google Inc.
- * Copyright (C) 2008-2009, Robin Rosenberg <robin.rosenberg@dewire.com>
+ * Copyright (C) 2008-2013, Robin Rosenberg <robin.rosenberg@dewire.com>
* and other copyright owners as documented in the project's IP log.
*
* This program and the accompanying materials are made available
@@ -284,6 +284,21 @@ public class RefUpdateTest extends SampleDataRepositoryTestCase {
}
@Test
+ public void testDeleteWithoutHead() throws IOException {
+ // Prepare repository without HEAD
+ RefUpdate refUpdate = db.updateRef(Constants.HEAD, true);
+ refUpdate.setForceUpdate(true);
+ refUpdate.setNewObjectId(ObjectId.zeroId());
+ Result updateResult = refUpdate.update();
+ assertEquals(Result.FORCED, updateResult);
+ Result deleteHeadResult = db.updateRef(Constants.HEAD).delete();
+ assertEquals(Result.NO_CHANGE, deleteHeadResult);
+
+ // Any result is ok as long as it's not an NPE
+ db.updateRef(Constants.R_HEADS + "master").delete();
+ }
+
+ @Test
public void testRefKeySameAsName() {
Map<String, Ref> allRefs = db.getAllRefs();
for (Entry<String, Ref> e : allRefs.entrySet()) {

Back to the top