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 <christian.halstrick@sap.com>
This commit is contained in:
Christian Halstrick 2010-10-27 10:37:05 +02:00
parent 07cae6e6c1
commit 2c38e5d461
1 changed files with 7 additions and 0 deletions

View File

@ -800,6 +800,13 @@ private Ref readRef(String name, RefList<Ref> packed) throws IOException {
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;