Ejemplo n.º 1
0
        /// <summary>
        /// Parse the complete commit message and decode it to a string.
        /// <para />
        /// This method parses and returns the message portion of the commit buffer,
        /// After taking the commit's character set into account and decoding the
        /// buffer using that character set. This method is a fairly expensive
        /// operation and produces a new string on each invocation.
        /// </summary>
        /// <returns>
        /// Decoded commit message as a string. Never null.
        /// </returns>
        public string getFullMessage()
        {
            byte[] raw  = _buffer;
            int    msgB = RawParseUtils.commitMessage(raw, 0);

            if (msgB < 0)
            {
                return(string.Empty);
            }
            Encoding enc = RawParseUtils.parseEncoding(raw);

            return(RawParseUtils.decode(enc, raw, msgB, raw.Length));
        }
Ejemplo n.º 2
0
        ///	<summary>
        /// Parse the commit message and return the first "line" of it.
        /// <para />
        /// The first line is everything up to the first pair of LFs. This is the
        /// "oneline" format, suitable for output in a single line display.
        /// <para />
        /// This method parses and returns the message portion of the commit buffer,
        /// after taking the commit's character set into account and decoding the
        /// buffer using that character set. This method is a fairly expensive
        /// operation and produces a new string on each invocation.
        /// </summary>
        /// <returns>
        /// Decoded commit message as a string. Never null. The returned
        /// string does not contain any LFs, even if the first paragraph
        /// spanned multiple lines. Embedded LFs are converted to spaces.
        /// </returns>
        public string getShortMessage()
        {
            byte[] raw  = _buffer;
            int    msgB = RawParseUtils.commitMessage(raw, 0);

            if (msgB < 0)
            {
                return(string.Empty);
            }

            Encoding enc  = RawParseUtils.parseEncoding(raw);
            int      msgE = RawParseUtils.endOfParagraph(raw, msgB);
            string   str  = RawParseUtils.decode(enc, raw, msgB, msgE);

            if (hasLF(raw, msgB, msgE))
            {
                str = str.Replace('\n', ' ');
            }
            return(str);
        }