]> source.dussan.org Git - jgit.git/commitdiff
Fix processing of broken symbolic references in RefDirectory 44/2544/1
authorMarc Strapetz <marc.strapetz@syntevo.com>
Wed, 9 Feb 2011 11:54:09 +0000 (12:54 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Sun, 20 Feb 2011 23:48:48 +0000 (00:48 +0100)
Change-Id: Ic1ceb9c99dca2c69e61ea0ef03ec64f13714b80a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/storage/file/RefDirectory.java

index c8c7d0dd83f956b221619aeb5b40f3602eda2f8e..e8ce2c546775ebd9f8ec6e412d4acaf0931ce426 100644 (file)
@@ -290,17 +290,19 @@ public class RefDirectory extends RefDatabase {
 
                RefList.Builder<Ref> symbolic = scan.symbolic;
                for (int idx = 0; idx < symbolic.size();) {
-                       Ref ref = symbolic.get(idx);
-                       ref = resolve(ref, 0, prefix, loose, packed);
-                       if (ref != null && ref.getObjectId() != null) {
-                               symbolic.set(idx, ref);
+                       final Ref symbolicRef = symbolic.get(idx);
+                       final Ref resolvedRef = resolve(symbolicRef, 0, prefix, loose, packed);
+                       if (resolvedRef != null && resolvedRef.getObjectId() != null) {
+                               symbolic.set(idx, resolvedRef);
                                idx++;
                        } else {
                                // A broken symbolic reference, we have to drop it from the
                                // collections the client is about to receive. Should be a
                                // rare occurrence so pay a copy penalty.
-                               loose = loose.remove(idx);
                                symbolic.remove(idx);
+                               final int toRemove = loose.find(symbolicRef.getName());
+                               if (0 <= toRemove)
+                                       loose = loose.remove(toRemove);
                        }
                }