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 git2.common;
15 import git2.errors;
16 import git2.types;
17 import 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 /**
100  * Callback for transfer progress information during remote operations (cloning,
101  * fetching).
102  *
103  * Generally called in-line with network operations, take care not to degrade
104  * performance.
105  */
106 struct GitTransferProgress
107 {
108     static if (targetLibGitVersion == VersionInfo(0, 19, 0)) {
109         uint totalObjects;
110         uint indexedObjects;
111         uint receivedObjects;
112         size_t receivedBytes;
113     } else static if (targetLibGitVersion == VersionInfo(0, 20, 0)) {
114         uint totalObjects;
115         uint indexedObjects;
116         uint receivedObjects;
117         uint localObjects;
118         uint totalDeltas;
119         uint indexedDeltas;
120         size_t receivedBytes;
121     } else static assert(false);
122 }
123 
124 /// ditto
125 alias TransferCallbackDelegate = ContinueWalk delegate(const ref GitTransferProgress stats);