/// <summary> /// Gets called be the Children getter for lazy loading /// </summary> private void LoadChildren() { _children = new TreeNodeCollection(); try { using (GitObjectReader stream = new GitObjectReader(_childrenRaw)) { while (!stream.IsEndOfStream) { string mode, path, sha; mode = stream.ReadWord().GetString(); path = stream.ReadToNull().GetString(); sha = Sha.Decode(stream.ReadBytes(20)); TreeNode child = Repo.Storage.GetObject <TreeNode>(sha); child.Path = path; child.Mode = FileMode.FromBits(int.Parse(mode)); child.Parent = this; _children.Add(child); } } } catch (Exception) { // Reset _children field, otherwise the object would be in an invalid state _children = null; throw; } }
/// <summary> /// Loads the commit from the GitObjectReader /// </summary> /// <param name="input">A reader with inflated commit contents</param> public override void Deserialize(GitObjectReader input) { //Skip 'tree' at beginning of line and read tree sha input.ReadWord(); _treeSha = input.ReadLine().GetString(); // Check for 'parent' at beginning of line _parentShas = new List <string>(); string parentOrAuthor = input.ReadWord().GetString(); // TODO: Make recursive while (parentOrAuthor == "parent") { _parentShas.Add(input.GetString(40)); input.Position++; // Skip 'author' parentOrAuthor = input.ReadWord().GetString(); } // Author string authorLine = input.ReadLine().GetString(); AuthoredDate = Utility.StripDate(authorLine, out authorLine); Author = Contributer.Parse(authorLine); // Committer input.ReadWord(); string committerLine = input.ReadLine().GetString(); CommittedDate = Utility.StripDate(committerLine, out committerLine); Committer = Contributer.Parse(committerLine); //Skip extra '\n' input.Position++; Message = input.ReadToEnd().GetString().TrimEnd(); }