GitSharp.Core.Patch.Patch.warn C# (CSharp) Method

warn() public method

public warn ( byte buf, int ptr, string msg ) : void
buf byte
ptr int
msg string
return void
        public void warn(byte[] buf, int ptr, string msg)
        {
            addError(new FormatError(buf, ptr, FormatError.Severity.WARNING, msg));
        }

Usage Example

Exemplo n.º 1
0
		public virtual int parseBody(Patch script, int end)
		{
			byte[] buf = _file.Buffer;
			int c = RawParseUtils.nextLF(buf, _startOffset), last = c;

			_oldImage.LinesDeleted = 0;
			_oldImage.LinesAdded = 0;

			for (; c < end; last = c, c = RawParseUtils.nextLF(buf, c))
			{
				bool breakScan;
				switch (buf[c])
				{
					case (byte)' ':
					case (byte)'\n':
						LinesContext++;
						continue;

					case (byte)'-':
						_oldImage.LinesDeleted++;
						continue;

					case (byte)'+':
						_oldImage.LinesAdded++;
						continue;

					case (byte)'\\': // Matches "\ No newline at end of file"
						continue;

					default:
						breakScan = true;
						break;
				}

				if (breakScan)
				{
					break;
				}
			}

			if (last < end && LinesContext + _oldImage.LinesDeleted - 1 == _oldImage.LineCount
				&& LinesContext + _oldImage.LinesAdded == NewLineCount
				&& RawParseUtils.match(buf, last, Patch.SigFooter) >= 0)
			{
				// This is an extremely common occurrence of "corruption".
				// Users add footers with their signatures After this mark,
				// and git diff adds the git executable version number.
				// Let it slide; the hunk otherwise looked sound.
				//
				_oldImage.LinesDeleted--;
				return last;
			}

			if (LinesContext + _oldImage.LinesDeleted < _oldImage.LineCount)
			{
				int missingCount = _oldImage.LineCount - (LinesContext + _oldImage.LinesDeleted);
				script.error(buf, _startOffset, "Truncated hunk, at least "
												+ missingCount + " old lines is missing");
			}
			else if (LinesContext + _oldImage.LinesAdded < NewLineCount)
			{
				int missingCount = NewLineCount - (LinesContext + _oldImage.LinesAdded);
				script.error(buf, _startOffset, "Truncated hunk, at least "
												+ missingCount + " new lines is missing");
			}
			else if (LinesContext + _oldImage.LinesDeleted > _oldImage.LineCount
					 || LinesContext + _oldImage.LinesAdded > NewLineCount)
			{
				string oldcnt = _oldImage.LineCount + ":" + NewLineCount;
				string newcnt = (LinesContext + _oldImage.LinesDeleted) + ":"
								+ (LinesContext + _oldImage.LinesAdded);
				script.warn(buf, _startOffset, "Hunk header " + oldcnt
											   + " does not match body line count of " + newcnt);
			}

			return c;
		}
All Usage Examples Of GitSharp.Core.Patch.Patch::warn