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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
using System;
namespace LibGit2Sharp.Core
{
/// <summary>
/// Underlying type of a <see cref="GitObject"/>
/// </summary>
internal enum GitObjectType
{
/// <summary>
/// Object can be of any type.
/// </summary>
Any = -2,
/// <summary>
/// Object is invalid.
/// </summary>
Bad = -1,
/// <summary>
/// Reserved for future use.
/// </summary>
Ext1 = 0,
/// <summary>
/// A commit object.
/// </summary>
Commit = 1,
/// <summary>
/// A tree (directory listing) object.
/// </summary>
Tree = 2,
/// <summary>
/// A file revision object.
/// </summary>
Blob = 3,
/// <summary>
/// An annotated tag object.
/// </summary>
Tag = 4,
/// <summary>
/// Reserved for future use.
/// </summary>
Ext2 = 5,
/// <summary>
/// A delta, base is given by an offset.
/// </summary>
OfsDelta = 6,
/// <summary>
/// A delta, base is given by object id.
/// </summary>
RefDelta = 7
}
internal static class GitObjectTypeExtensions
{
public static TreeEntryTargetType ToTreeEntryTargetType(this GitObjectType type)
{
switch (type)
{
case GitObjectType.Commit:
return TreeEntryTargetType.GitLink;
case GitObjectType.Tree:
return TreeEntryTargetType.Tree;
case GitObjectType.Blob:
return TreeEntryTargetType.Blob;
default:
throw new InvalidOperationException(string.Format("Cannot map {0} to a TreeEntryTargetType.", type));
}
}
public static ObjectType ToObjectType(this GitObjectType type)
{
switch (type)
{
case GitObjectType.Commit:
return ObjectType.Commit;
case GitObjectType.Tree:
return ObjectType.Tree;
case GitObjectType.Blob:
return ObjectType.Blob;
case GitObjectType.Tag:
return ObjectType.Tag;
default:
throw new InvalidOperationException(string.Format("Cannot map {0} to a ObjectType.", type));
}
}
}
}
|