void Remove(List <Shelf> stashes, Shelf s) { int i = stashes.FindIndex(st => st.CommitId == s.CommitId); if (i != -1) { stashes.RemoveAt(i); Shelf next = stashes.FirstOrDefault(ns => ns.PrevShelfCommitId == s.CommitId); if (next != null) { next.PrevShelfCommitId = s.PrevShelfCommitId; } if (stashes.Count == 0) { // No more stashes. The ref and log files can be deleted. ShelfRefFile.Delete(); ShelfLogFile.Delete(); return; } WriteShelfes(stashes); if (i == stashes.Count) { // We deleted the head. Write the new head. File.WriteAllText(ShelfRefFile.FullName, stashes.Last().CommitId + "\n"); } } }
public void Clear() { if (ShelfRefFile.Exists) { ShelfRefFile.Delete(); } if (ShelfLogFile.Exists) { ShelfLogFile.Delete(); } }