aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file
diff options
context:
space:
mode:
authorRobin Rosenberg <robin.rosenberg@dewire.com>2011-06-13 00:20:51 +0200
committerRobin Rosenberg <robin.rosenberg@dewire.com>2011-07-22 11:51:41 +0200
commitc536873c87db0d87292a90a905b30301c110ceb3 (patch)
treed1e3664f8d0b016a0a59945c7e6618135292dbf6 /org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file
parentf1713abcdcb5097d4e44893862bedc6e27dde20e (diff)
downloadjgit-c536873c87db0d87292a90a905b30301c110ceb3.tar.gz
jgit-c536873c87db0d87292a90a905b30301c110ceb3.zip
Fix reading of ref names containing characters that sort before /
A set of ref names like ('a/b' and 'a+b') would cause the RefDirectory to think that the set of refs have changed because it traversed the 'a' directory in the subtree before looking at 'a+b', but it then compared with the know refs which are sorted with 'a+b' first. Fix this by traversing the refs tree in another order. Treat a directory as if they ends with a '/' before deciding on the order to traverse the refs tree. Bug: 348834 Change-Id: I23377f8df00c7252bf27dbcfba5da193c5403917 Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/RefDirectoryTest.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/RefDirectoryTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/RefDirectoryTest.java
index dc2ccb97fb..3ca4f589db 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/RefDirectoryTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/RefDirectoryTest.java
@@ -61,6 +61,9 @@ import java.io.File;
import java.io.IOException;
import java.util.Map;
+import org.eclipse.jgit.events.ListenerHandle;
+import org.eclipse.jgit.events.RefsChangedEvent;
+import org.eclipse.jgit.events.RefsChangedListener;
import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase;
import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.lib.AnyObjectId;
@@ -466,6 +469,33 @@ public class RefDirectoryTest extends LocalDiskRepositoryTestCase {
}
@Test
+ public void testGetRefs_LooseSorting_Bug_348834() throws IOException {
+ Map<String, Ref> refs;
+
+ writeLooseRef("refs/heads/my/a+b", A);
+ writeLooseRef("refs/heads/my/a/b/c", B);
+
+ final int[] count = new int[1];
+
+ ListenerHandle listener = Repository.getGlobalListenerList()
+ .addRefsChangedListener(new RefsChangedListener() {
+
+ public void onRefsChanged(RefsChangedEvent event) {
+ count[0]++;
+ }
+ });
+
+ refs = refdir.getRefs(RefDatabase.ALL);
+ refs = refdir.getRefs(RefDatabase.ALL);
+ listener.remove();
+ assertEquals(1, count[0]); // Bug 348834 multiple RefsChangedEvents
+ assertEquals(2, refs.size());
+ assertEquals(A, refs.get("refs/heads/my/a+b").getObjectId());
+ assertEquals(B, refs.get("refs/heads/my/a/b/c").getObjectId());
+
+ }
+
+ @Test
public void testGetRefs_TagsOnly_AllPacked() throws IOException {
Map<String, Ref> tags;
Ref a;