/// <exception cref="System.IO.IOException"></exception> private RefList <Ref> ParsePackedRefs(BufferedReader br) { RefListBuilder <Ref> all = new RefListBuilder <Ref>(); Ref last = null; bool peeled = false; bool needSort = false; string p; while ((p = br.ReadLine()) != null) { if (p[0] == '#') { if (p.StartsWith(PACKED_REFS_HEADER)) { p = Sharpen.Runtime.Substring(p, PACKED_REFS_HEADER.Length); peeled = p.Contains(PACKED_REFS_PEELED); } continue; } if (p[0] == '^') { if (last == null) { throw new IOException(JGitText.Get().peeledLineBeforeRef); } ObjectId id = ObjectId.FromString(Sharpen.Runtime.Substring(p, 1)); last = new ObjectIdRef.PeeledTag(RefStorage.PACKED, last.GetName(), last.GetObjectId (), id); all.Set(all.Size() - 1, last); continue; } int sp = p.IndexOf(' '); ObjectId id_1 = ObjectId.FromString(Sharpen.Runtime.Substring(p, 0, sp)); string name = Copy(p, sp + 1, p.Length); ObjectIdRef cur; if (peeled) { cur = new ObjectIdRef.PeeledNonTag(RefStorage.PACKED, name, id_1); } else { cur = new ObjectIdRef.Unpeeled(RefStorage.PACKED, name, id_1); } if (last != null && RefComparator.CompareTo(last, cur) > 0) { needSort = true; } all.Add(cur); last = cur; } if (needSort) { all.Sort(); } return(all.ToRefList()); }
/// <exception cref="System.IO.IOException"></exception> private void ReadPackedRefsImpl(IDictionary <string, Ref> avail, BufferedReader br ) { Ref last = null; bool peeled = false; for (; ;) { string line = br.ReadLine(); if (line == null) { break; } if (line[0] == '#') { if (line.StartsWith(RefDirectory.PACKED_REFS_HEADER)) { line = Sharpen.Runtime.Substring(line, RefDirectory.PACKED_REFS_HEADER.Length); peeled = line.Contains(RefDirectory.PACKED_REFS_PEELED); } continue; } if (line[0] == '^') { if (last == null) { throw new TransportException(JGitText.Get().peeledLineBeforeRef); } ObjectId id = ObjectId.FromString(Sharpen.Runtime.Substring(line, 1)); last = new ObjectIdRef.PeeledTag(RefStorage.PACKED, last.GetName(), last.GetObjectId (), id); avail.Put(last.GetName(), last); continue; } int sp = line.IndexOf(' '); if (sp < 0) { throw new TransportException(MessageFormat.Format(JGitText.Get().unrecognizedRef, line)); } ObjectId id_1 = ObjectId.FromString(Sharpen.Runtime.Substring(line, 0, sp)); string name = Sharpen.Runtime.Substring(line, sp + 1); if (peeled) { last = new ObjectIdRef.PeeledNonTag(RefStorage.PACKED, name, id_1); } else { last = new ObjectIdRef.Unpeeled(RefStorage.PACKED, name, id_1); } avail.Put(last.GetName(), last); } }