{"thread":{"id":"15174","subject":"[JGIT PATCH 0/4] Branch deletion testing and bug fixes","startedAt":"2008-08-22T22:45:43Z","lastAt":"2008-08-22T23:31:49Z","messageCount":9,"participants":["Charles O'Farrell","Shawn O. Pearce","Robin Rosenberg"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"88217","messageId":"1219445147-6801-1-git-send-email-charleso@charleso.org","threadId":"15174","inReplyTo":null,"subject":"[JGIT PATCH 0/4] Branch deletion testing and bug fixes","fromName":"Charles O'Farrell","fromEmail":"charleso@charleso.org","sentAt":"2008-08-22T22:45:43Z","receivedAt":"2008-08-22T22:45:43Z","isPatch":true,"sender":{"key":"charleso@charleso.org","avatar":"https://gravatar.com/avatar/ce96d531daa37646a38a81e48113865af86a6d290ad92931f3b217896bdf86ea?d=mp&s=160"},"body":"Added a few tests for the RefUpdate delete method, which in turn\nexposed two minor bugs. Previously you couldn't delete a ref\npointing to the current branch. Fixing that would also then allow\nthe current branch to be deleted too.\n\n*** BLURB HERE ***\n\nCharles O'Farrell (4):\n  Ensured that RefUpdate cannot delete current branch\n  Fixed bug where RefUpdate didn't delete identical HEAD branch\n  Added test for RefUpdate branch deletion\n  Added extra javadoc for delete to significant RefUpdate results\n\n .../tst/org/spearce/jgit/lib/RefUpdateTest.java    |  106 ++++++++++++++++++++\n .../src/org/spearce/jgit/lib/RefUpdate.java        |   30 ++++--\n 2 files changed, 127 insertions(+), 9 deletions(-)\n create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/lib/RefUpdateTest.java\n"},{"id":"88218","messageId":"1219445147-6801-2-git-send-email-charleso@charleso.org","threadId":"15174","inReplyTo":"1219445147-6801-1-git-send-email-charleso@charleso.org","subject":"[JGIT PATCH 1/4] Ensured that RefUpdate cannot delete current branch","fromName":"Charles O'Farrell","fromEmail":"charleso@charleso.org","sentAt":"2008-08-22T22:45:44Z","receivedAt":"2008-08-22T22:45:44Z","isPatch":true,"sender":{"key":"charleso@charleso.org","avatar":"https://gravatar.com/avatar/ce96d531daa37646a38a81e48113865af86a6d290ad92931f3b217896bdf86ea?d=mp&s=160"},"body":"If attempted it will return a REJECTED_CURRENT_BRANCH Result.\n\nSigned-off-by: Charles O'Farrell <charleso@charleso.org>\n---\n .../src/org/spearce/jgit/lib/RefUpdate.java        |   10 ++++++++++\n 1 files changed, 10 insertions(+), 0 deletions(-)\n\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java b/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java\nindex ca77b75..aa2cecb 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java\n@@ -110,6 +110,13 @@\n \t\tREJECTED,\n \n \t\t/**\n+\t\t * Rejected because trying to delete the current branch.\n+\t\t * <p>\n+\t\t * Has no meaning for update.\n+\t\t */\n+\t\tREJECTED_CURRENT_BRANCH,\n+\n+\t\t/**\n \t\t * The ref was probably not updated because of I/O error.\n \t\t * <p>\n \t\t * Unexpected I/O error occurred when writing new ref. Such error may\n@@ -323,6 +330,9 @@ public Result update(final RevWalk walk) throws IOException {\n \t * @throws IOException\n \t */\n \tpublic Result delete() throws IOException {\n+\t\tif (name.substring(Constants.R_HEADS.length()).equals(\n+\t\t\t\tdb.getRepository().getBranch()))\n+\t\t\treturn Result.REJECTED_CURRENT_BRANCH;\n \t\ttry {\n \t\t\treturn updateImpl(new RevWalk(db.getRepository()),\n \t\t\t\t\tnew DeleteStore());\n-- \n1.6.0.49.gea35\n"},{"id":"88219","messageId":"1219445147-6801-3-git-send-email-charleso@charleso.org","threadId":"15174","inReplyTo":"1219445147-6801-2-git-send-email-charleso@charleso.org","subject":"[JGIT PATCH 2/4] Fixed bug where RefUpdate didn't delete identical HEAD branch","fromName":"Charles O'Farrell","fromEmail":"charleso@charleso.org","sentAt":"2008-08-22T22:45:45Z","receivedAt":"2008-08-22T22:45:45Z","isPatch":true,"sender":{"key":"charleso@charleso.org","avatar":"https://gravatar.com/avatar/ce96d531daa37646a38a81e48113865af86a6d290ad92931f3b217896bdf86ea?d=mp&s=160"},"body":"Signed-off-by: Charles O'Farrell <charleso@charleso.org>\n---\n .../src/org/spearce/jgit/lib/RefUpdate.java        |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java b/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java\nindex aa2cecb..34a784b 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java\n@@ -359,7 +359,7 @@ private Result updateImpl(final RevWalk walk, final Store store)\n \t\t\tnewObj = safeParse(walk, newValue);\n \t\t\toldObj = safeParse(walk, oldValue);\n \t\t\tif (newObj == oldObj)\n-\t\t\t\treturn Result.NO_CHANGE;\n+\t\t\t\treturn store.store(lock, Result.NO_CHANGE);\n \n \t\t\tif (newObj instanceof RevCommit && oldObj instanceof RevCommit) {\n \t\t\t\tif (walk.isMergedInto((RevCommit) oldObj, (RevCommit) newObj))\n@@ -390,6 +390,8 @@ private static RevObject safeParse(final RevWalk rw, final AnyObjectId id)\n \n \tprivate Result updateStore(final LockFile lock, final Result status)\n \t\t\tthrows IOException {\n+\t\tif (status == Result.NO_CHANGE)\n+\t\t\treturn status;\n \t\tlock.setNeedStatInformation(true);\n \t\tlock.write(newValue);\n \t\tString msg = getRefLogMessage();\n-- \n1.6.0.49.gea35\n"},{"id":"88220","messageId":"1219445147-6801-4-git-send-email-charleso@charleso.org","threadId":"15174","inReplyTo":"1219445147-6801-3-git-send-email-charleso@charleso.org","subject":"[JGIT PATCH 3/4] Added test for RefUpdate branch deletion","fromName":"Charles O'Farrell","fromEmail":"charleso@charleso.org","sentAt":"2008-08-22T22:45:46Z","receivedAt":"2008-08-22T22:45:46Z","isPatch":true,"sender":{"key":"charleso@charleso.org","avatar":"https://gravatar.com/avatar/ce96d531daa37646a38a81e48113865af86a6d290ad92931f3b217896bdf86ea?d=mp&s=160"},"body":"Signed-off-by: Charles O'Farrell <charleso@charleso.org>\n---\n .../tst/org/spearce/jgit/lib/RefUpdateTest.java    |  106 ++++++++++++++++++++\n 1 files changed, 106 insertions(+), 0 deletions(-)\n create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/lib/RefUpdateTest.java\n\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RefUpdateTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RefUpdateTest.java\nnew file mode 100644\nindex 0000000..62a60c3\n--- /dev/null\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RefUpdateTest.java\n@@ -0,0 +1,106 @@\n+/*\n+ * Copyright (C) 2008, Charles O'Farrell <charleso@charleso.org>\n+ *\n+ * All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or\n+ * without modification, are permitted provided that the following\n+ * conditions are met:\n+ *\n+ * - Redistributions of source code must retain the above copyright\n+ *   notice, this list of conditions and the following disclaimer.\n+ *\n+ * - Redistributions in binary form must reproduce the above\n+ *   copyright notice, this list of conditions and the following\n+ *   disclaimer in the documentation and/or other materials provided\n+ *   with the distribution.\n+ *\n+ * - Neither the name of the Git Development Community nor the\n+ *   names of its contributors may be used to endorse or promote\n+ *   products derived from this software without specific prior\n+ *   written permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND\n+ * CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES,\n+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\n+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+package org.spearce.jgit.lib;\n+\n+import java.io.File;\n+import java.io.IOException;\n+\n+import org.spearce.jgit.lib.RefUpdate.Result;\n+\n+public class RefUpdateTest extends RepositoryTestCase {\n+\n+\tprivate RefUpdate updateRef(final String name) throws IOException {\n+\t\tfinal RefUpdate ref = db.updateRef(name);\n+\t\tref.setNewObjectId(db.resolve(Constants.HEAD));\n+\t\treturn ref;\n+\t}\n+\n+\tprivate void delete(final RefUpdate ref, final Result expected)\n+\t\t\tthrows IOException {\n+\t\tdelete(ref, expected, true, true);\n+\t}\n+\n+\tprivate void delete(final RefUpdate ref, final Result expected,\n+\t\t\tfinal boolean exists, final boolean removed) throws IOException {\n+\t\tassertEquals(exists, db.getAllRefs().containsKey(ref.getName()));\n+\t\tassertEquals(expected, ref.delete());\n+\t\tassertEquals(!removed, db.getAllRefs().containsKey(ref.getName()));\n+\t}\n+\n+\tpublic void testLooseDelete() throws IOException {\n+\t\tfinal String newRef = \"refs/heads/abc\";\n+\t\tRefUpdate ref = updateRef(newRef);\n+\t\tref.update(); // create loose ref\n+\t\tref = updateRef(newRef); // refresh\n+\t\tdelete(ref, Result.NO_CHANGE);\n+\t}\n+\n+\tpublic void testDeleteHead() throws IOException {\n+\t\tfinal RefUpdate ref = updateRef(Constants.HEAD);\n+\t\tdelete(ref, Result.NOT_ATTEMPTED, true, false);\n+\t}\n+\n+\tpublic void testLogDeleted() throws IOException {\n+\t\tfinal File log = new File(db.getDirectory(), Constants.LOGS\n+\t\t\t\t+ \"/refs/heads/a\");\n+\t\tlog.getParentFile().mkdirs();\n+\t\tlog.createNewFile();\n+\t\tassertTrue(log.exists());\n+\t\tfinal RefUpdate ref = updateRef(\"refs/heads/a\");\n+\t\tdelete(ref, Result.FAST_FORWARD);\n+\t\tassertFalse(log.exists());\n+\t}\n+\n+\tpublic void testDeleteNotFound() throws IOException {\n+\t\tfinal RefUpdate ref = updateRef(\"refs/heads/xyz\");\n+\t\tdelete(ref, Result.NEW, false, true);\n+\t}\n+\n+\tpublic void testDeleteFastForward() throws IOException {\n+\t\tfinal RefUpdate ref = updateRef(\"refs/heads/a\");\n+\t\tdelete(ref, Result.FAST_FORWARD);\n+\t}\n+\n+\tpublic void testDeleteForce() throws IOException {\n+\t\tfinal RefUpdate ref = db.updateRef(\"refs/heads/b\");\n+\t\tref.setNewObjectId(db.resolve(\"refs/heads/a\"));\n+\t\tdelete(ref, Result.REJECTED, true, false);\n+\t\tref.setForceUpdate(true);\n+\t\tdelete(ref, Result.FORCED);\n+\t}\n+}\n-- \n1.6.0.49.gea35\n"},{"id":"88221","messageId":"1219445147-6801-5-git-send-email-charleso@charleso.org","threadId":"15174","inReplyTo":"1219445147-6801-4-git-send-email-charleso@charleso.org","subject":"[JGIT PATCH 4/4] Added extra javadoc for delete to significant RefUpdate results","fromName":"Charles O'Farrell","fromEmail":"charleso@charleso.org","sentAt":"2008-08-22T22:45:47Z","receivedAt":"2008-08-22T22:45:47Z","isPatch":true,"sender":{"key":"charleso@charleso.org","avatar":"https://gravatar.com/avatar/ce96d531daa37646a38a81e48113865af86a6d290ad92931f3b217896bdf86ea?d=mp&s=160"},"body":"Signed-off-by: Charles O'Farrell <charleso@charleso.org>\n---\n .../src/org/spearce/jgit/lib/RefUpdate.java        |   16 ++++++++--------\n 1 files changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java b/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java\nindex 34a784b..525bb62 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java\n@@ -52,11 +52,11 @@\n public class RefUpdate {\n \t/** Status of an update request. */\n \tpublic static enum Result {\n-\t\t/** The ref update has not been attempted by the caller. */\n+\t\t/** The ref update/delete has not been attempted by the caller. */\n \t\tNOT_ATTEMPTED,\n \n \t\t/**\n-\t\t * The ref could not be locked for update.\n+\t\t * The ref could not be locked for update/delete.\n \t\t * <p>\n \t\t * This is generally a transient failure and is usually caused by\n \t\t * another process trying to access the ref at the same time as this\n@@ -69,12 +69,12 @@\n \t\t * Same value already stored.\n \t\t * <p>\n \t\t * Both the old value and the new value are identical. No change was\n-\t\t * necessary.\n+\t\t * necessary for an update. For delete the branch is removed.\n \t\t */\n \t\tNO_CHANGE,\n \n \t\t/**\n-\t\t * The ref was created locally.\n+\t\t * The ref was created locally for an update, but ignored for delete.\n \t\t * <p>\n \t\t * The ref did not exist when the update started, but it was created\n \t\t * successfully with the new value.\n@@ -82,7 +82,7 @@\n \t\tNEW,\n \n \t\t/**\n-\t\t * The ref had to be forcefully updated.\n+\t\t * The ref had to be forcefully updated/deleted.\n \t\t * <p>\n \t\t * The ref already existed but its old value was not fully merged into\n \t\t * the new value. The configuration permitted a forced update to take\n@@ -92,7 +92,7 @@\n \t\tFORCED,\n \n \t\t/**\n-\t\t * The ref was updated in a fast-forward way.\n+\t\t * The ref was updated/deleted in a fast-forward way.\n \t\t * <p>\n \t\t * The tracking ref already existed and its old value was fully merged\n \t\t * into the new value. No history was made unreachable.\n@@ -104,7 +104,7 @@\n \t\t * <p>\n \t\t * The tracking ref already existed but its old value was not fully\n \t\t * merged into the new value. The configuration did not allow a forced\n-\t\t * update to take place, so ref still contains the old value. No\n+\t\t * update/delete to take place, so ref still contains the old value. No\n \t\t * previous history was lost.\n \t\t */\n \t\tREJECTED,\n@@ -117,7 +117,7 @@\n \t\tREJECTED_CURRENT_BRANCH,\n \n \t\t/**\n-\t\t * The ref was probably not updated because of I/O error.\n+\t\t * The ref was probably not updated/deleted because of I/O error.\n \t\t * <p>\n \t\t * Unexpected I/O error occurred when writing new ref. Such error may\n \t\t * result in uncertain state, but most probably ref was not updated.\n-- \n1.6.0.49.gea35\n"},{"id":"88229","messageId":"20080822232226.GP3483@spearce.org","threadId":"15174","inReplyTo":"1219445147-6801-2-git-send-email-charleso@charleso.org","subject":"Re: [JGIT PATCH 1/4] Ensured that RefUpdate cannot delete current branch","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-08-22T23:22:26Z","receivedAt":"2008-08-22T23:22:26Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Charles O'Farrell <charleso@charleso.org> wrote:\n> If attempted it will return a REJECTED_CURRENT_BRANCH Result.\n \n> @@ -323,6 +330,9 @@ public Result update(final RevWalk walk) throws IOException {\n>  \t * @throws IOException\n>  \t */\n>  \tpublic Result delete() throws IOException {\n> +\t\tif (name.substring(Constants.R_HEADS.length()).equals(\n> +\t\t\t\tdb.getRepository().getBranch()))\n> +\t\t\treturn Result.REJECTED_CURRENT_BRANCH;\n>  \t\ttry {\n>  \t\t\treturn updateImpl(new RevWalk(db.getRepository()),\n>  \t\t\t\t\tnew DeleteStore());\n\nI'm squashing this into the patch, as I think its a safer (and\nfaster) way to evaluate what the current branch is.  We have a\ncache in RefDatabase showing the current value of HEAD.  We also\ndon't look at .git/head-name, which happens during a bisection.\n\nBut I also don't think we want to mess around with this test if\nwe are dealing with refs/remotes or refs/tags.  Really it is only\nrefs/heads/ that should typically appear in HEAD, so we only need\nto guard against that case.  If the user knows enough to make HEAD\npoint at something else, maybe they will also know enough to not\ndelete the damn thing out from under themselves.  If we did fix it\nto test for all refs, its just a matter of removing the first if.\n\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java b/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java\nindex aa2cecb..77dada0 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java\n@@ -330,9 +330,12 @@ public Result update(final RevWalk walk) throws IOException {\n \t * @throws IOException\n \t */\n \tpublic Result delete() throws IOException {\n-\t\tif (name.substring(Constants.R_HEADS.length()).equals(\n-\t\t\t\tdb.getRepository().getBranch()))\n-\t\t\treturn Result.REJECTED_CURRENT_BRANCH;\n+\t\tif (name.startsWith(Constants.R_HEADS)) {\n+\t\t\tfinal Ref head = db.readRef(Constants.HEAD);\n+\t\t\tif (head != null && name.equals(head.getName()))\n+\t\t\t\treturn Result.REJECTED_CURRENT_BRANCH;\n+\t\t}\n+\n \t\ttry {\n \t\t\treturn updateImpl(new RevWalk(db.getRepository()),\n \t\t\t\t\tnew DeleteStore());\n\n-- \nShawn.\n"},{"id":"88231","messageId":"20080822232618.GQ3483@spearce.org","threadId":"15174","inReplyTo":"1219445147-6801-4-git-send-email-charleso@charleso.org","subject":"Re: [JGIT PATCH 3/4] Added test for RefUpdate branch deletion","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-08-22T23:26:18Z","receivedAt":"2008-08-22T23:26:18Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Charles O'Farrell <charleso@charleso.org> wrote:\n> +public class RefUpdateTest extends RepositoryTestCase {\n> +\n> +\tpublic void testDeleteHead() throws IOException {\n> +\t\tfinal RefUpdate ref = updateRef(Constants.HEAD);\n> +\t\tdelete(ref, Result.NOT_ATTEMPTED, true, false);\n> +\t}\n> +}\n\nSo I see you didn't run the unit tests before emailing.  ;-)\n\nI squashed this into the patch I am replying to:\n\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RefUpdateTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RefUpdateTest.java\nindex 62a60c3..1ade2ef 100644\n--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RefUpdateTest.java\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RefUpdateTest.java\n@@ -72,7 +72,7 @@ public void testLooseDelete() throws IOException {\n \n \tpublic void testDeleteHead() throws IOException {\n \t\tfinal RefUpdate ref = updateRef(Constants.HEAD);\n-\t\tdelete(ref, Result.NOT_ATTEMPTED, true, false);\n+\t\tdelete(ref, Result.REJECTED_CURRENT_BRANCH, true, false);\n \t}\n \n \tpublic void testLogDeleted() throws IOException {\n\nOtherwise the series looks good.  Compiles.  Passes tests.\nTests look correct.  Thanks!\n\n-- \nShawn.\n"},{"id":"88232","messageId":"200808230128.19035.robin.rosenberg.lists@dewire.com","threadId":"15174","inReplyTo":"1219445147-6801-4-git-send-email-charleso@charleso.org","subject":"Re: [JGIT PATCH 3/4] Added test for RefUpdate branch deletion","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg.lists@dewire.com","sentAt":"2008-08-22T23:28:18Z","receivedAt":"2008-08-22T23:28:18Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"lördagen den 23 augusti 2008 00.45.46 skrev Charles O'Farrell:\n\nHaving unit tests is lovely and we appreciate that very much. We need more of this. \nUnfortunately it breaks. Is the fix the obvious one?\n\n-- robin\n\n> +\tpublic void testDeleteHead() throws IOException {\n> +\t\tfinal RefUpdate ref = updateRef(Constants.HEAD);\n> +\t\tdelete(ref, Result.NOT_ATTEMPTED, true, false);\n\njunit.framework.AssertionFailedError: expected:<NOT_ATTEMPTED> but was:<REJECTED_CURRENT_BRANCH>\n\tat junit.framework.Assert.fail(Assert.java:47)\n\tat junit.framework.Assert.failNotEquals(Assert.java:280)\n\tat junit.framework.Assert.assertEquals(Assert.java:64)\n\tat junit.framework.Assert.assertEquals(Assert.java:71)\n\tat org.spearce.jgit.lib.RefUpdateTest.delete(RefUpdateTest.java:61)\n\tat org.spearce.jgit.lib.RefUpdateTest.testDeleteHead(RefUpdateTest.java:75)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:623)\n\tat junit.framework.TestCase.runTest(TestCase.java:164)\n\tat junit.framework.TestCase.runBare(TestCase.java:130)\n\tat junit.framework.TestResult$1.protect(TestResult.java:106)\n\tat junit.framework.TestResult.runProtected(TestResult.java:124)\n\tat junit.framework.TestResult.run(TestResult.java:109)\n\tat junit.framework.TestCase.run(TestCase.java:120)\n\tat org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)\n\tat org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)\n\tat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)\n\tat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)\n\tat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)\n\tat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)\n"},{"id":"88233","messageId":"20080822233149.GR3483@spearce.org","threadId":"15174","inReplyTo":"200808230128.19035.robin.rosenberg.lists@dewire.com","subject":"Re: [JGIT PATCH 3/4] Added test for RefUpdate branch deletion","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-08-22T23:31:49Z","receivedAt":"2008-08-22T23:31:49Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Robin Rosenberg <robin.rosenberg.lists@dewire.com> wrote:\n> lördagen den 23 augusti 2008 00.45.46 skrev Charles O'Farrell:\n> \n> Having unit tests is lovely and we appreciate that very much. We need more of this. \n> Unfortunately it breaks. Is the fix the obvious one?\n> \n> > +\tpublic void testDeleteHead() throws IOException {\n> > +\t\tfinal RefUpdate ref = updateRef(Constants.HEAD);\n> > +\t\tdelete(ref, Result.NOT_ATTEMPTED, true, false);\n> \n> junit.framework.AssertionFailedError: expected:<NOT_ATTEMPTED> but was:<REJECTED_CURRENT_BRANCH>\n\nYes.  See my reply.  Its already on repo.or.cz with the necessary\nsquashed patch.\n\n-- \nShawn.\n"}]}