1 /*
2  *             Copyright Andrej Mitrovic 2013.
3  *  Distributed under the Boost Software License, Version 1.0.
4  *     (See accompanying file LICENSE_1_0.txt or copy at
5  *           http://www.boost.org/LICENSE_1_0.txt)
6  */
7 module git.types;
8 
9 import std.array;
10 import std.conv;
11 import std.exception;
12 import std.string;
13 
14 import deimos.git2.common;
15 import deimos.git2.errors;
16 import deimos.git2.types;
17 import deimos.git2.util;
18 
19 import git.exception;
20 import git.version_;
21 
22 /** Basic type (loose or packed) of any Git object. */
23 enum GitType
24 {
25     /// Object can be any of the following types.
26     any        = GIT_OBJ_ANY,
27 
28     /// Object is invalid.
29     bad        = GIT_OBJ_BAD,
30 
31     /// Reserved for future use.
32     ext1       = GIT_OBJ__EXT1,
33 
34     /// A commit object.
35     commit     = GIT_OBJ_COMMIT,
36 
37     /// A tree (directory listing) object.
38     tree       = GIT_OBJ_TREE,
39 
40     /// A file revision object.
41     blob       = GIT_OBJ_BLOB,
42 
43     /// An annotated tag object.
44     tag        = GIT_OBJ_TAG,
45 
46     /// Reserved for future use.
47     ext2       = GIT_OBJ__EXT2,
48 
49     /// A delta, base is given by an offset.
50     ofs_delta  = GIT_OBJ_OFS_DELTA,
51 
52     /// A delta, base is given by object id.
53     ref_delta  = GIT_OBJ_REF_DELTA
54 }
55 
56 /** Basic type of any Git reference. */
57 enum GitRefType
58 {
59     /** Invalid reference. */
60     invalid = GIT_REF_INVALID,
61 
62     /** A reference which points at an object id. */
63     oid = GIT_REF_OID,
64 
65     /** A reference which points at another reference. */
66     symbolic = GIT_REF_SYMBOLIC,
67 
68     list_all = GIT_REF_LISTALL,
69 }
70 
71 /** Basic type of any Git branch. */
72 enum GitBranchType
73 {
74     local = GIT_BRANCH_LOCAL,
75     remote = GIT_BRANCH_REMOTE,
76 }
77 
78 /** Valid modes for index and tree entries. */
79 enum GitFileModeType
80 {
81     new_ = GIT_FILEMODE_NEW,
82     tree = GIT_FILEMODE_TREE,
83     blob = GIT_FILEMODE_BLOB,
84     blob_exe = GIT_FILEMODE_BLOB_EXECUTABLE,
85     link = GIT_FILEMODE_LINK,
86     commit = GIT_FILEMODE_COMMIT,
87 }
88 
89 /// The return type of walker callbacks.
90 enum ContinueWalk
91 {
92     /// Stop walk
93     no,
94 
95     /// Continue walk
96     yes
97 }
98 
99 /// The return type of walker callbacks.
100 enum ContinueWalkSkip
101 {
102     /// Stop walk
103     no,
104 
105     /// Continue walk
106     yes,
107 
108     /// Skip the current sub tree
109     skip
110 }
111 
112 /**
113  * Callback for transfer progress information during remote operations (cloning,
114  * fetching).
115  *
116  * Generally called in-line with network operations, take care not to degrade
117  * performance.
118  */
119 struct GitTransferProgress
120 {
121     package this(const(git_transfer_progress)* p)
122     {
123         this.tupleof = (*p).tupleof;
124     }
125 
126     uint totalObjects;
127     uint indexedObjects;
128     uint receivedObjects;
129     static if (targetLibGitVersion == VersionInfo(0, 20, 0)) {
130         uint local_objects;
131         uint total_deltas;
132         uint indexed_deltas;
133     }
134     size_t receivedBytes;
135 }
136 
137 /// ditto
138 alias TransferCallbackDelegate = void delegate(const ref GitTransferProgress stats);