From 2c38e5d46155106fa0a0aed2b551207f0e6f2f2a Mon Sep 17 00:00:00 2001 From: Christian Halstrick Date: Wed, 27 Oct 2010 10:37:05 +0200 Subject: [PATCH] Prevent endless loop of events fired by RefsDirectory RefsDirectory fires a RefsChangedEvent when it detect that one ref changed (new, modified, deleted). But there was a potential of wrong events beeing fired leading to a endless loop in EGit. Problem is that when calling getRefs(ALL) we don't want to report additional refs and by that we remove the additional refs from the list of "refs reported upwards last time". We fire an RefsChangedEvent because we think that the special refs are not there anymore. I fixed this by removing eventing for the additional refs. Another alternative would be to always scan also for additional refs and put them in the list of refs. But getRefs(ALL) would then remove the additional refs again. I didn't do that for performance reasons and also because I am not sure whether we want evnting for additional refs. Change-Id: Icb9398b55a8c6bbf03e38f6670feb67754ce91e0 Signed-off-by: Christian Halstrick --- .../src/org/eclipse/jgit/storage/file/RefDirectory.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/RefDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/RefDirectory.java index 2e4489cda4..96c8361adb 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/RefDirectory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/RefDirectory.java @@ -800,6 +800,13 @@ public class RefDirectory extends RefDatabase { final LooseRef n = scanRef(null, name); if (n == null) return packed.get(name); + + // check whether the found new ref is the an additional ref. These refs + // should not go into looseRefs + for (int i = 0; i < additionalRefsNames.length; i++) + if (name.equals(additionalRefsNames[i])) + return n; + if (looseRefs.compareAndSet(curList, curList.add(idx, n))) modCnt.incrementAndGet(); return n; -- 2.39.5