]> source.dussan.org Git - jgit.git/commit
Fix deleting symrefs 31/100931/4
authorDave Borowitz <dborowitz@google.com>
Fri, 7 Jul 2017 15:24:51 +0000 (11:24 -0400)
committerDave Borowitz <dborowitz@google.com>
Mon, 17 Jul 2017 15:56:35 +0000 (11:56 -0400)
commitf529fa6729a9b8b5c1329bf75639d26b0067f9d9
tree77514b58dc44e267e01d8883465d94a44cf31984
parent9c33f7364d41956240818ba12d8b79d5ea846162
Fix deleting symrefs

The RefDirectory implementation of doDelete never considered whether to
delete a symref or its leaf, because the detachingSymbolicRef bit was
never exposed from RefUpdate. The behavior was thus incorrectly to
always delete the symref, never the leaf.

There was no test for this behavior. The only thing that attempted to be
a test was testDeleteHeadInBareRepo, but this test was broken for
reasons unrelated to this bug. Specifically, it set the leaf to point to
a completely nonexistent object, and then asserted that deleting HEAD
resulted in NO_CHANGE. The only reason this test ever passed is because
of a quirk of updateImpl, which treats a missing object as the same as
null. This quirk aside, the test wasn't really testing the right thing.
Turn this into a real test by writing out a real object and pointing the
leaf at that.

Also, add a test for the detachingSymbolicRef case, i.e. deleting the
symref and leaving the leaf alone.

Change-Id: Ib96d2a35b4f99eba0734725486085fc6f9d78aa5
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefUpdateTest.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java