Commit 75d1c8c664eba0ddef802b1bf6d1327707014c6e

Edward Thomson 2013-04-30T17:33:11

move NAME and REUC extensions to sys/

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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
diff --git a/include/git2/index.h b/include/git2/index.h
index 01e3d2c..d23c3a8 100644
--- a/include/git2/index.h
+++ b/include/git2/index.h
@@ -84,19 +84,6 @@ typedef struct git_index_entry {
 	char *path;
 } git_index_entry;
 
-typedef struct git_index_name_entry {
-	char *ancestor;
-	char *ours;
-	char *theirs;
-} git_index_name_entry;
-
-/** Representation of a resolve undo entry in the index. */
-typedef struct git_index_reuc_entry {
-	unsigned int mode[3];
-	git_oid oid[3];
-	char *path;
-} git_index_reuc_entry;
-
 /** Capabilities of system that affect index actions. */
 enum {
 	GIT_INDEXCAP_IGNORE_CASE = 1,
@@ -484,149 +471,6 @@ GIT_EXTERN(int) git_index_has_conflicts(const git_index *index);
 
 /**@}*/
 
-/** @name Conflict Name entry functions
- *
- * These functions work on rename conflict entries.
- */
-/**@{*/
-
-/**
- * Get the count of filename conflict entries currently in the index.
- *
- * @param index an existing index object
- * @return integer of count of current filename conflict entries
- */
-GIT_EXTERN(unsigned int) git_index_name_entrycount(git_index *index);
-
-/**
- * Get a filename conflict entry from the index.
- *
- * The returned entry is read-only and should not be modified
- * or freed by the caller.
- *
- * @param index an existing index object
- * @param n the position of the entry
- * @return a pointer to the filename conflict entry; NULL if out of bounds
- */
-GIT_EXTERN(const git_index_name_entry *) git_index_name_get_byindex(
-	git_index *index, size_t n);
-
-/**
- * Record the filenames involved in a rename conflict.
- *
- * @param index an existing index object
- * @param ancestor the path of the file as it existed in the ancestor
- * @param ours the path of the file as it existed in our tree
- * @param theirs the path of the file as it existed in their tree
- */
-GIT_EXTERN(int) git_index_name_add(git_index *index,
-	const char *ancestor, const char *ours, const char *theirs);
-
-/**
- * Remove all filename conflict entries.
- *
- * @param index an existing index object
- * @return 0 or an error code
- */
-GIT_EXTERN(void) git_index_name_clear(git_index *index);
-/**@}*/
-
-/** @name Resolve Undo (REUC) index entry manipulation.
- *
- * These functions work on the Resolve Undo index extension and contains
- * data about the original files that led to a merge conflict.
- */
-/**@{*/
-
-/**
- * Get the count of resolve undo entries currently in the index.
- *
- * @param index an existing index object
- * @return integer of count of current resolve undo entries
- */
-GIT_EXTERN(unsigned int) git_index_reuc_entrycount(git_index *index);
-
-/**
- * Finds the resolve undo entry that points to the given path in the Git
- * index.
- *
- * @param at_pos the address to which the position of the reuc entry is written (optional)
- * @param index an existing index object
- * @param path path to search
- * @return 0 if found, < 0 otherwise (GIT_ENOTFOUND)
- */
-GIT_EXTERN(int) git_index_reuc_find(size_t *at_pos, git_index *index, const char *path);
-
-/**
- * Get a resolve undo entry from the index.
- *
- * The returned entry is read-only and should not be modified
- * or freed by the caller.
- *
- * @param index an existing index object
- * @param path path to search
- * @return the resolve undo entry; NULL if not found
- */
-GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_bypath(git_index *index, const char *path);
-
-/**
- * Get a resolve undo entry from the index.
- *
- * The returned entry is read-only and should not be modified
- * or freed by the caller.
- *
- * @param index an existing index object
- * @param n the position of the entry
- * @return a pointer to the resolve undo entry; NULL if out of bounds
- */
-GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_byindex(git_index *index, size_t n);
-
-/**
- * Adds a resolve undo entry for a file based on the given parameters.
- *
- * The resolve undo entry contains the OIDs of files that were involved
- * in a merge conflict after the conflict has been resolved.  This allows
- * conflicts to be re-resolved later.
- *
- * If there exists a resolve undo entry for the given path in the index,
- * it will be removed.
- *
- * This method will fail in bare index instances.
- *
- * @param index an existing index object
- * @param path filename to add
- * @param ancestor_mode mode of the ancestor file
- * @param ancestor_id oid of the ancestor file
- * @param our_mode mode of our file
- * @param our_id oid of our file
- * @param their_mode mode of their file
- * @param their_id oid of their file
- * @return 0 or an error code
- */
-GIT_EXTERN(int) git_index_reuc_add(git_index *index, const char *path,
-	int ancestor_mode, const git_oid *ancestor_id,
-	int our_mode, const git_oid *our_id,
-	int their_mode, const git_oid *their_id);
-
-/**
- * Remove an resolve undo entry from the index
- *
- * @param index an existing index object
- * @param n position of the resolve undo entry to remove
- * @return 0 or an error code
- */
-GIT_EXTERN(int) git_index_reuc_remove(git_index *index, size_t n);
-
-/**
- * Remove all resolve undo entries from the index
- *
- * @param index an existing index object
- * @return 0 or an error code
- */
-GIT_EXTERN(void) git_index_reuc_clear(git_index *index);
-
-/**@}*/
-
 /** @} */
 GIT_END_DECL
 #endif
diff --git a/include/git2/sys/index.h b/include/git2/sys/index.h
new file mode 100644
index 0000000..f74637f
--- /dev/null
+++ b/include/git2/sys/index.h
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_sys_git_index_h__
+#define INCLUDE_sys_git_index_h__
+
+/**
+ * @file git2/sys/index.h
+ * @brief Low-level Git index manipulation routines
+ * @defgroup git_backend Git custom backend APIs
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+/** Representation of a rename conflict entry in the index. */
+typedef struct git_index_name_entry {
+	char *ancestor;
+	char *ours;
+	char *theirs;
+} git_index_name_entry;
+
+/** Representation of a resolve undo entry in the index. */
+typedef struct git_index_reuc_entry {
+	unsigned int mode[3];
+	git_oid oid[3];
+	char *path;
+} git_index_reuc_entry;
+
+/** @name Conflict Name entry functions
+ *
+ * These functions work on rename conflict entries.
+ */
+/**@{*/
+
+/**
+ * Get the count of filename conflict entries currently in the index.
+ *
+ * @param index an existing index object
+ * @return integer of count of current filename conflict entries
+ */
+GIT_EXTERN(unsigned int) git_index_name_entrycount(git_index *index);
+
+/**
+ * Get a filename conflict entry from the index.
+ *
+ * The returned entry is read-only and should not be modified
+ * or freed by the caller.
+ *
+ * @param index an existing index object
+ * @param n the position of the entry
+ * @return a pointer to the filename conflict entry; NULL if out of bounds
+ */
+GIT_EXTERN(const git_index_name_entry *) git_index_name_get_byindex(
+	git_index *index, size_t n);
+
+/**
+ * Record the filenames involved in a rename conflict.
+ *
+ * @param index an existing index object
+ * @param ancestor the path of the file as it existed in the ancestor
+ * @param ours the path of the file as it existed in our tree
+ * @param theirs the path of the file as it existed in their tree
+ */
+GIT_EXTERN(int) git_index_name_add(git_index *index,
+	const char *ancestor, const char *ours, const char *theirs);
+
+/**
+ * Remove all filename conflict entries.
+ *
+ * @param index an existing index object
+ * @return 0 or an error code
+ */
+GIT_EXTERN(void) git_index_name_clear(git_index *index);
+
+/**@}*/
+
+/** @name Resolve Undo (REUC) index entry manipulation.
+ *
+ * These functions work on the Resolve Undo index extension and contains
+ * data about the original files that led to a merge conflict.
+ */
+/**@{*/
+
+/**
+ * Get the count of resolve undo entries currently in the index.
+ *
+ * @param index an existing index object
+ * @return integer of count of current resolve undo entries
+ */
+GIT_EXTERN(unsigned int) git_index_reuc_entrycount(git_index *index);
+
+/**
+ * Finds the resolve undo entry that points to the given path in the Git
+ * index.
+ *
+ * @param at_pos the address to which the position of the reuc entry is written (optional)
+ * @param index an existing index object
+ * @param path path to search
+ * @return 0 if found, < 0 otherwise (GIT_ENOTFOUND)
+ */
+GIT_EXTERN(int) git_index_reuc_find(size_t *at_pos, git_index *index, const char *path);
+
+/**
+ * Get a resolve undo entry from the index.
+ *
+ * The returned entry is read-only and should not be modified
+ * or freed by the caller.
+ *
+ * @param index an existing index object
+ * @param path path to search
+ * @return the resolve undo entry; NULL if not found
+ */
+GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_bypath(git_index *index, const char *path);
+
+/**
+ * Get a resolve undo entry from the index.
+ *
+ * The returned entry is read-only and should not be modified
+ * or freed by the caller.
+ *
+ * @param index an existing index object
+ * @param n the position of the entry
+ * @return a pointer to the resolve undo entry; NULL if out of bounds
+ */
+GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_byindex(git_index *index, size_t n);
+
+/**
+ * Adds a resolve undo entry for a file based on the given parameters.
+ *
+ * The resolve undo entry contains the OIDs of files that were involved
+ * in a merge conflict after the conflict has been resolved.  This allows
+ * conflicts to be re-resolved later.
+ *
+ * If there exists a resolve undo entry for the given path in the index,
+ * it will be removed.
+ *
+ * This method will fail in bare index instances.
+ *
+ * @param index an existing index object
+ * @param path filename to add
+ * @param ancestor_mode mode of the ancestor file
+ * @param ancestor_id oid of the ancestor file
+ * @param our_mode mode of our file
+ * @param our_id oid of our file
+ * @param their_mode mode of their file
+ * @param their_id oid of their file
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_index_reuc_add(git_index *index, const char *path,
+	int ancestor_mode, const git_oid *ancestor_id,
+	int our_mode, const git_oid *our_id,
+	int their_mode, const git_oid *their_id);
+
+/**
+ * Remove an resolve undo entry from the index
+ *
+ * @param index an existing index object
+ * @param n position of the resolve undo entry to remove
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_index_reuc_remove(git_index *index, size_t n);
+
+/**
+ * Remove all resolve undo entries from the index
+ *
+ * @param index an existing index object
+ * @return 0 or an error code
+ */
+GIT_EXTERN(void) git_index_reuc_clear(git_index *index);
+
+/**@}*/
+
+/** @} */
+GIT_END_DECL
+#endif
+
diff --git a/src/index.c b/src/index.c
index 656fb5b..a935c00 100644
--- a/src/index.c
+++ b/src/index.c
@@ -19,6 +19,7 @@
 #include "git2/oid.h"
 #include "git2/blob.h"
 #include "git2/config.h"
+#include "git2/sys/index.h"
 
 #define entry_size(type,len) ((offsetof(type, path) + (len) + 8) & ~7)
 #define short_entry_size(len) entry_size(struct entry_short, len)
diff --git a/src/merge.c b/src/merge.c
index 681f302..3595eb0 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -36,6 +36,7 @@
 #include "git2/signature.h"
 #include "git2/config.h"
 #include "git2/tree.h"
+#include "git2/sys/index.h"
 
 #define GIT_MERGE_INDEX_ENTRY_EXISTS(X)	((X).mode != 0)
 
diff --git a/tests-clar/index/names.c b/tests-clar/index/names.c
index ffc9842..6861553 100644
--- a/tests-clar/index/names.c
+++ b/tests-clar/index/names.c
@@ -1,5 +1,6 @@
 #include "clar_libgit2.h"
 #include "index.h"
+#include "git2/sys/index.h"
 #include "git2/repository.h"
 #include "../reset/reset_helpers.h"
 
diff --git a/tests-clar/index/reuc.c b/tests-clar/index/reuc.c
index 4d5955a..0e38a92 100644
--- a/tests-clar/index/reuc.c
+++ b/tests-clar/index/reuc.c
@@ -1,5 +1,6 @@
 #include "clar_libgit2.h"
 #include "index.h"
+#include "git2/sys/index.h"
 #include "git2/repository.h"
 #include "../reset/reset_helpers.h"
 
diff --git a/tests-clar/merge/merge_helpers.c b/tests-clar/merge/merge_helpers.c
index 7cb1e53..b2c70be 100644
--- a/tests-clar/merge/merge_helpers.c
+++ b/tests-clar/merge/merge_helpers.c
@@ -5,6 +5,7 @@
 #include "merge_helpers.h"
 #include "merge.h"
 #include "git2/merge.h"
+#include "git2/sys/index.h"
 
 int merge_trees_from_branches(
 	git_index **index, git_repository *repo,
diff --git a/tests-clar/merge/trees/trivial.c b/tests-clar/merge/trees/trivial.c
index 54b07e7..7d8d2cb 100644
--- a/tests-clar/merge/trees/trivial.c
+++ b/tests-clar/merge/trees/trivial.c
@@ -5,6 +5,7 @@
 #include "../merge_helpers.h"
 #include "refs.h"
 #include "fileops.h"
+#include "git2/sys/index.h"
 
 static git_repository *repo;