Ejemplo n.º 1
0
        internal unsafe TreeEntryChanges(git_diff_delta* delta)
        {
            Path = LaxFilePathMarshaler.FromNative(delta->new_file.Path).Native;
            OldPath = LaxFilePathMarshaler.FromNative(delta->old_file.Path).Native;

            Mode = (Mode)delta->new_file.Mode;
            OldMode = (Mode)delta->old_file.Mode;
            Oid = ObjectId.BuildFromPtr(&delta->new_file.Id);
            OldOid = ObjectId.BuildFromPtr(&delta->old_file.Id);
            Exists = (delta->new_file.Flags & GitDiffFlags.GIT_DIFF_FLAG_EXISTS) != 0;
            OldExists = (delta->old_file.Flags & GitDiffFlags.GIT_DIFF_FLAG_EXISTS) != 0;

            Status = GetStatusFromChangeKind(delta->status);
        }
Ejemplo n.º 2
0
        private unsafe int LineCallback(git_diff_delta* delta, GitDiffHunk hunk, GitDiffLine line, IntPtr payload)
        {
            string decodedContent = LaxUtf8Marshaler.FromNative(line.content, (int)line.contentLen);

            string prefix;

            switch (line.lineOrigin)
            {
                case GitDiffLineOrigin.GIT_DIFF_LINE_ADDITION:
                    LinesAdded++;
                    prefix = Encoding.ASCII.GetString(new[] { (byte)line.lineOrigin });
                    break;

                case GitDiffLineOrigin.GIT_DIFF_LINE_DELETION:
                    LinesDeleted++;
                    prefix = Encoding.ASCII.GetString(new[] { (byte)line.lineOrigin });
                    break;

                case GitDiffLineOrigin.GIT_DIFF_LINE_CONTEXT:
                    prefix = Encoding.ASCII.GetString(new[] { (byte)line.lineOrigin });
                    break;

                default:
                    prefix = string.Empty;
                    break;
            }

            AppendToPatch(prefix);
            AppendToPatch(decodedContent);
            return 0;
        }
Ejemplo n.º 3
0
        private unsafe int HunkCallback(git_diff_delta* delta, GitDiffHunk hunk, IntPtr payload)
        {
            string decodedContent = LaxUtf8Marshaler.FromBuffer(hunk.Header, (int)hunk.HeaderLen);

            AppendToPatch(decodedContent);
            return 0;
        }
Ejemplo n.º 4
0
        private unsafe int FileCallback(git_diff_delta* delta, float progress, IntPtr payload)
        {
            IsBinaryComparison = delta->flags.HasFlag(GitDiffFlags.GIT_DIFF_FLAG_BINARY);

            if (!IsBinaryComparison)
            {
                return 0;
            }

            AppendToPatch("Binary content differ\n");

            return 0;
        }