public void testRemoveMakesEmpty() { RefList <global::GitSharp.Core.Ref> one = toList(REF_A); RefList <global::GitSharp.Core.Ref> two = one.remove(1); Assert.AreNotSame(one, two); Assert.AreSame(two, RefList <global::GitSharp.Core.Ref> .emptyList()); }
public void testBuilder_Remove() { var builder = new RefList <global::GitSharp.Core.Ref> .Builder <global::GitSharp.Core.Ref>(); builder.add(REF_A); builder.add(REF_B); builder.remove(0); Assert.AreEqual(1, builder.size()); Assert.AreSame(REF_B, builder.get(0)); }
public void testRemoveEndOfList() { RefList <global::GitSharp.Core.Ref> one = toList(REF_A, REF_B, REF_c); RefList <global::GitSharp.Core.Ref> two = one.remove(2); Assert.AreNotSame(one, two); Assert.AreEqual(3, one.size()); Assert.AreSame(REF_A, one.get(0)); Assert.AreSame(REF_B, one.get(1)); Assert.AreSame(REF_c, one.get(2)); Assert.AreEqual(2, two.size()); Assert.AreSame(REF_A, two.get(0)); Assert.AreSame(REF_B, two.get(1)); }
public override IDictionary <string, Ref> getRefs(string prefix) { RefList <Ref> packed = getPackedRefs(); RefList <LooseRef> oldLoose = looseRefs.get(); var scan = new LooseScanner(oldLoose, this); scan.scan(prefix); RefList <LooseRef> loose; if (scan.newLoose != null) { loose = scan.newLoose.toRefList(); if (looseRefs.compareAndSet(oldLoose, loose)) { modCnt.incrementAndGet(); } } else { loose = oldLoose; } fireRefsChanged(); RefList <Ref> .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); 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); } } return(new RefMap(prefix, packed, upcast(loose), symbolic.toRefList())); }
private Ref readRef(string name, RefList <Ref> packed) { RefList <LooseRef> curList = looseRefs.get(); int idx = curList.find(name); if (0 <= idx) { LooseRef o = curList.get(idx); LooseRef n = scanRef(o, name); if (n == null) { if (looseRefs.compareAndSet(curList, curList.remove(idx))) { modCnt.incrementAndGet(); } return(packed.get(name)); } if (o == n) { return(n); } if (looseRefs.compareAndSet(curList, curList.set(idx, n))) { modCnt.incrementAndGet(); } return(n); } LooseRef n2 = scanRef(null, name); if (n2 == null) { return(packed.get(name)); } if (looseRefs.compareAndSet(curList, curList.add(idx, n2))) { modCnt.incrementAndGet(); } return(n2); }
public void testBuilder_Remove() { var builder = new RefList<global::GitSharp.Core.Ref>.Builder<global::GitSharp.Core.Ref>(); builder.add(REF_A); builder.add(REF_B); builder.remove(0); Assert.AreEqual(1, builder.size()); Assert.AreSame(REF_B, builder.get(0)); }