1 /*
2  * Copyright (C) the libgit2 contributors. All rights reserved.
3  *
4  * This file is part of libgit2, distributed under the GNU GPL v2 with
5  * a Linking Exception. For full terms see the included COPYING file.
6  */
7 module libgit2_d.sys.index;
8 
9 
10 private static import libgit2_d.oid;
11 private static import libgit2_d.types;
12 
13 /**
14  * @file git2/sys/index.h
15  * @brief Low-level Git index manipulation routines
16  * @defgroup git_backend Git custom backend APIs
17  * @ingroup Git
18  * @{
19  */
20 extern (C):
21 nothrow @nogc:
22 package(libgit2_d):
23 
24 /**
25  * Representation of a rename conflict entry in the index.
26  */
27 struct git_index_name_entry
28 {
29 	char* ancestor;
30 	char* ours;
31 	char* theirs;
32 }
33 
34 /**
35  * Representation of a resolve undo entry in the index.
36  */
37 struct git_index_reuc_entry
38 {
39 	uint[3] mode;
40 	libgit2_d.oid.git_oid[3] oid;
41 	char* path;
42 }
43 
44 /**
45  * @name Conflict Name entry functions
46  *
47  * These functions work on rename conflict entries.
48  */
49 /**@{*/
50 
51 /**
52  * Get the count of filename conflict entries currently in the index.
53  *
54  * Params:
55  *      index = an existing index object
56  *
57  * Returns: integer of count of current filename conflict entries
58  */
59 //GIT_EXTERN
60 size_t git_index_name_entrycount(libgit2_d.types.git_index* index);
61 
62 /**
63  * Get a filename conflict entry from the index.
64  *
65  * The returned entry is read-only and should not be modified
66  * or freed by the caller.
67  *
68  * Params:
69  *      index = an existing index object
70  *      n = the position of the entry
71  *
72  * Returns: a pointer to the filename conflict entry; null if out of bounds
73  */
74 //GIT_EXTERN
75 const (.git_index_name_entry)* git_index_name_get_byindex(libgit2_d.types.git_index* index, size_t n);
76 
77 /**
78  * Record the filenames involved in a rename conflict.
79  *
80  * Params:
81  *      index = an existing index object
82  *      ancestor = the path of the file as it existed in the ancestor
83  *      ours = the path of the file as it existed in our tree
84  *      theirs = the path of the file as it existed in their tree
85  */
86 //GIT_EXTERN
87 int git_index_name_add(libgit2_d.types.git_index* index, const (char)* ancestor, const (char)* ours, const (char)* theirs);
88 
89 /**
90  * Remove all filename conflict entries.
91  *
92  * Params:
93  *      index = an existing index object
94  *
95  * Returns: 0 or an error code
96  */
97 //GIT_EXTERN
98 int git_index_name_clear(libgit2_d.types.git_index* index);
99 
100 /**@}*/
101 
102 /**
103  * @name Resolve Undo (REUC) index entry manipulation.
104  *
105  * These functions work on the Resolve Undo index extension and contains
106  * data about the original files that led to a merge conflict.
107  */
108 /**@{*/
109 
110 /**
111  * Get the count of resolve undo entries currently in the index.
112  *
113  * Params:
114  *      index = an existing index object
115  *
116  * Returns: integer of count of current resolve undo entries
117  */
118 //GIT_EXTERN
119 size_t git_index_reuc_entrycount(libgit2_d.types.git_index* index);
120 
121 /**
122  * Finds the resolve undo entry that points to the given path in the Git
123  * index.
124  *
125  * Params:
126  *      at_pos = the address to which the position of the reuc entry is written (optional)
127  *      index = an existing index object
128  *      path = path to search
129  *
130  * Returns: 0 if found, < 0 otherwise (git_error_code.GIT_ENOTFOUND)
131  */
132 //GIT_EXTERN
133 int git_index_reuc_find(size_t* at_pos, libgit2_d.types.git_index* index, const (char)* path);
134 
135 /**
136  * Get a resolve undo entry from the index.
137  *
138  * The returned entry is read-only and should not be modified
139  * or freed by the caller.
140  *
141  * Params:
142  *      index = an existing index object
143  *      path = path to search
144  *
145  * Returns: the resolve undo entry; null if not found
146  */
147 //GIT_EXTERN
148 const (.git_index_reuc_entry)* git_index_reuc_get_bypath(libgit2_d.types.git_index* index, const (char)* path);
149 
150 /**
151  * Get a resolve undo entry from the index.
152  *
153  * The returned entry is read-only and should not be modified
154  * or freed by the caller.
155  *
156  * Params:
157  *      index = an existing index object
158  *      n = the position of the entry
159  *
160  * Returns: a pointer to the resolve undo entry; null if out of bounds
161  */
162 //GIT_EXTERN
163 const (.git_index_reuc_entry)* git_index_reuc_get_byindex(libgit2_d.types.git_index* index, size_t n);
164 
165 /**
166  * Adds a resolve undo entry for a file based on the given parameters.
167  *
168  * The resolve undo entry contains the OIDs of files that were involved
169  * in a merge conflict after the conflict has been resolved.  This allows
170  * conflicts to be re-resolved later.
171  *
172  * If there exists a resolve undo entry for the given path in the index,
173  * it will be removed.
174  *
175  * This method will fail in bare index instances.
176  *
177  * Params:
178  *      index = an existing index object
179  *      path = filename to add
180  *      ancestor_mode = mode of the ancestor file
181  *      ancestor_id = oid of the ancestor file
182  *      our_mode = mode of our file
183  *      our_id = oid of our file
184  *      their_mode = mode of their file
185  *      their_id = oid of their file
186  *
187  * Returns: 0 or an error code
188  */
189 //GIT_EXTERN
190 int git_index_reuc_add(libgit2_d.types.git_index* index, const (char)* path, int ancestor_mode, const (libgit2_d.oid.git_oid)* ancestor_id, int our_mode, const (libgit2_d.oid.git_oid)* our_id, int their_mode, const (libgit2_d.oid.git_oid)* their_id);
191 
192 /**
193  * Remove an resolve undo entry from the index
194  *
195  * Params:
196  *      index = an existing index object
197  *      n = position of the resolve undo entry to remove
198  *
199  * Returns: 0 or an error code
200  */
201 //GIT_EXTERN
202 int git_index_reuc_remove(libgit2_d.types.git_index* index, size_t n);
203 
204 /**
205  * Remove all resolve undo entries from the index
206  *
207  * Params:
208  *      index = an existing index object
209  *
210  * Returns: 0 or an error code
211  */
212 //GIT_EXTERN
213 int git_index_reuc_clear(libgit2_d.types.git_index* index);
214 
215 /**@}*/
216 
217 /** @} */