Welcome to mirror list, hosted at ThFree Co, Russian Federation.

TreeEntryChanges.cs « LibGit2Sharp - github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 205ff42c3321c6e339f1c4688dedafad44f4bc4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System.Diagnostics;
using System.Globalization;
using LibGit2Sharp.Core;

namespace LibGit2Sharp
{
    /// <summary>
    /// Holds the changes between two versions of a tree entry.
    /// </summary>
    [DebuggerDisplay("{DebuggerDisplay,nq}")]
    public class TreeEntryChanges
    {
        /// <summary>
        /// Needed for mocking purposes.
        /// </summary>
        protected TreeEntryChanges()
        { }

        internal TreeEntryChanges(GitDiffDelta delta)
        {
            Path = LaxFilePathMarshaler.FromNative(delta.NewFile.Path).Native;
            OldPath = LaxFilePathMarshaler.FromNative(delta.OldFile.Path).Native;

            Mode = (Mode)delta.NewFile.Mode;
            OldMode = (Mode)delta.OldFile.Mode;
            Oid = delta.NewFile.Id;
            OldOid = delta.OldFile.Id;

            Status = (delta.Status == ChangeKind.Untracked || delta.Status == ChangeKind.Ignored)
                ? ChangeKind.Added
                : delta.Status;
        }

        /// <summary>
        /// The new path.
        /// </summary>
        public virtual string Path { get; private set; }

        /// <summary>
        /// The new <see cref="Mode"/>.
        /// </summary>
        public virtual Mode Mode { get; private set; }

        /// <summary>
        /// The new content hash.
        /// </summary>
        public virtual ObjectId Oid { get; private set; }

        /// <summary>
        /// The kind of change that has been done (added, deleted, modified ...).
        /// </summary>
        public virtual ChangeKind Status { get; private set; }

        /// <summary>
        /// The old path.
        /// </summary>
        public virtual string OldPath { get; private set; }

        /// <summary>
        /// The old <see cref="Mode"/>.
        /// </summary>
        public virtual Mode OldMode { get; private set; }

        /// <summary>
        /// The old content hash.
        /// </summary>
        public virtual ObjectId OldOid { get; private set; }

        private string DebuggerDisplay
        {
            get
            {
                return string.Format(CultureInfo.InvariantCulture,
                    "Path = {0}, File {1}",
                    !string.IsNullOrEmpty(Path) ? Path : OldPath, Status);
            }
        }
    }
}