Esempio n. 1
0
        public override void Load(GitPackReader reader)
        {
            byte[] shaContents = reader.ReadBytes(20);

            BaseSHA = Sha.Decode(shaContents);
            Delta   = reader.UncompressToLength(Size).ToArray();
        }
Esempio n. 2
0
        /// <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;
            }
        }
Esempio n. 3
0
        public static string ToSHAString(this byte[] input)
        {
            string sha = Sha.Decode(input);

            if (!Utility.IsValidSHA(sha))
            {
                throw new ParseException("Invalid sha: {0}".FormatWith(sha));
            }

            return(sha);
        }