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.submodule;
8 
9 
10 private static import libgit2_d.buffer;
11 private static import libgit2_d.checkout;
12 private static import libgit2_d.oid;
13 private static import libgit2_d.remote;
14 private static import libgit2_d.types;
15 private static import std.traits;
16 
17 /**
18  * @file git2/submodule.h
19  * @brief Git submodule management utilities
20  *
21  * Submodule support in libgit2 builds a list of known submodules and keeps
22  * it in the repository.  The list is built from the .gitmodules file, the
23  * .git/config file, the index, and the HEAD tree.  Items in the working
24  * directory that look like submodules (i.e. a git repo) but are not
25  * mentioned in those places won't be tracked.
26  *
27  * @defgroup git_submodule Git submodule management routines
28  * @ingroup Git
29  * @{
30  */
31 extern (C):
32 nothrow @nogc:
33 public:
34 
35 /**
36  * Return codes for submodule status.
37  *
38  * A combination of these flags will be returned to describe the status of a
39  * submodule.  Depending on the "ignore" property of the submodule, some of
40  * the flags may never be returned because they indicate changes that are
41  * supposed to be ignored.
42  *
43  * Submodule info is contained in 4 places: the HEAD tree, the index, config
44  * files (both .git/config and .gitmodules), and the working directory.  Any
45  * or all of those places might be missing information about the submodule
46  * depending on what state the repo is in.  We consider all four places to
47  * build the combination of status flags.
48  *
49  * There are four values that are not really status, but give basic info
50  * about what sources of submodule data are available.  These will be
51  * returned even if ignore is set to "ALL".
52  *
53  * * IN_HEAD   - superproject head contains submodule
54  * * IN_INDEX  - superproject index contains submodule
55  * * IN_CONFIG - superproject gitmodules has submodule
56  * * IN_WD     - superproject workdir has submodule
57  *
58  * The following values will be returned so long as ignore is not "ALL".
59  *
60  * * INDEX_ADDED       - in index, not in head
61  * * INDEX_DELETED     - in head, not in index
62  * * INDEX_MODIFIED    - index and head don't match
63  * * WD_UNINITIALIZED  - workdir contains empty directory
64  * * WD_ADDED          - in workdir, not index
65  * * WD_DELETED        - in index, not workdir
66  * * WD_MODIFIED       - index and workdir head don't match
67  *
68  * The following can only be returned if ignore is "NONE" or "UNTRACKED".
69  *
70  * * WD_INDEX_MODIFIED - submodule workdir index is dirty
71  * * WD_WD_MODIFIED    - submodule workdir has modified files
72  *
73  * Lastly, the following will only be returned for ignore "NONE".
74  *
75  * * WD_UNTRACKED      - wd contains untracked files
76  */
77 enum git_submodule_status_t
78 {
79 	GIT_SUBMODULE_STATUS_IN_HEAD = 1u << 0,
80 	GIT_SUBMODULE_STATUS_IN_INDEX = 1u << 1,
81 	GIT_SUBMODULE_STATUS_IN_CONFIG = 1u << 2,
82 	GIT_SUBMODULE_STATUS_IN_WD = 1u << 3,
83 	GIT_SUBMODULE_STATUS_INDEX_ADDED = 1u << 4,
84 	GIT_SUBMODULE_STATUS_INDEX_DELETED = 1u << 5,
85 	GIT_SUBMODULE_STATUS_INDEX_MODIFIED = 1u << 6,
86 	GIT_SUBMODULE_STATUS_WD_UNINITIALIZED = 1u << 7,
87 	GIT_SUBMODULE_STATUS_WD_ADDED = 1u << 8,
88 	GIT_SUBMODULE_STATUS_WD_DELETED = 1u << 9,
89 	GIT_SUBMODULE_STATUS_WD_MODIFIED = 1u << 10,
90 	GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED = 1u << 11,
91 	GIT_SUBMODULE_STATUS_WD_WD_MODIFIED = 1u << 12,
92 	GIT_SUBMODULE_STATUS_WD_UNTRACKED = 1u << 13,
93 }
94 
95 enum GIT_SUBMODULE_STATUS__IN_FLAGS = 0x000Fu;
96 enum GIT_SUBMODULE_STATUS__INDEX_FLAGS = 0x0070u;
97 enum GIT_SUBMODULE_STATUS__WD_FLAGS = 0x3F80u;
98 
99 pragma(inline, true)
100 pure nothrow @safe @nogc
101 bool GIT_SUBMODULE_STATUS_IS_UNMODIFIED(T)(S)
102 	if (std.traits.isIntegral!(T))
103 
104 	do
105 	{
106 		return (S & ~.GIT_SUBMODULE_STATUS__IN_FLAGS) == 0;
107 	}
108 
109 pragma(inline, true)
110 pure nothrow @safe @nogc
111 bool GIT_SUBMODULE_STATUS_IS_INDEX_UNMODIFIED(T)(S)
112 	if (std.traits.isIntegral!(T))
113 
114 	do
115 	{
116 		return (S & .GIT_SUBMODULE_STATUS__INDEX_FLAGS) == 0;
117 	}
118 
119 pragma(inline, true)
120 pure nothrow @safe @nogc
121 bool GIT_SUBMODULE_STATUS_IS_WD_UNMODIFIED(T)(S)
122 	if (std.traits.isIntegral!(T))
123 
124 	do
125 	{
126 		return (S & (.GIT_SUBMODULE_STATUS__WD_FLAGS & ~.git_submodule_status_t.GIT_SUBMODULE_STATUS_WD_UNINITIALIZED)) == 0;
127 	}
128 
129 pragma(inline, true)
130 pure nothrow @safe @nogc
131 bool GIT_SUBMODULE_STATUS_IS_WD_DIRTY(T)(S)
132 	if (std.traits.isIntegral!(T))
133 
134 	do
135 	{
136 		return (S & (.git_submodule_status_t.GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED | .git_submodule_status_t.GIT_SUBMODULE_STATUS_WD_WD_MODIFIED | .git_submodule_status_t.GIT_SUBMODULE_STATUS_WD_UNTRACKED)) != 0;
137 	}
138 
139 /**
140  * Function pointer to receive each submodule
141  *
142  * Params:
143  *      sm = git_submodule currently being visited
144  *      name = name of the submodule
145  *      payload = value you passed to the foreach function as payload
146  *
147  * Returns: 0 on success or error code
148  */
149 alias git_submodule_cb = int function(libgit2_d.types.git_submodule* sm, const (char)* name, void* payload);
150 
151 /**
152  * Submodule update options structure
153  *
154  * Initialize with `GIT_SUBMODULE_UPDATE_OPTIONS_INIT`. Alternatively, you can
155  * use `git_submodule_update_options_init`.
156  */
157 struct git_submodule_update_options
158 {
159 	uint version_;
160 
161 	/**
162 	 * These options are passed to the checkout step. To disable
163 	 * checkout, set the `checkout_strategy` to
164 	 * `git_checkout_strategy_t.GIT_CHECKOUT_NONE`. Generally you will want the use
165 	 * git_checkout_strategy_t.GIT_CHECKOUT_SAFE to update files in the working
166 	 * directory.
167 	 */
168 	libgit2_d.checkout.git_checkout_options checkout_opts;
169 
170 	/**
171 	 * Options which control the fetch, including callbacks.
172 	 *
173 	 * The callbacks to use for reporting fetch progress, and for acquiring
174 	 * credentials in the event they are needed.
175 	 */
176 	libgit2_d.remote.git_fetch_options fetch_opts;
177 
178 	/**
179 	 * Allow fetching from the submodule's default remote if the target
180 	 * commit isn't found. Enabled by default.
181 	 */
182 	int allow_fetch;
183 }
184 
185 enum GIT_SUBMODULE_UPDATE_OPTIONS_VERSION = 1;
186 
187 pragma(inline, true)
188 pure nothrow @safe @nogc
189 .git_submodule_update_options GIT_SUBMODULE_UPDATE_OPTIONS_INIT()
190 
191 	do
192 	{
193 		libgit2_d.checkout.git_checkout_options CHECKOUT_OPTION =
194 		{
195 			version_: libgit2_d.checkout.GIT_CHECKOUT_OPTIONS_VERSION,
196 			checkout_strategy: libgit2_d.checkout.git_checkout_strategy_t.GIT_CHECKOUT_SAFE,
197 		};
198 
199 		.git_submodule_update_options OUTPUT =
200 		{
201 			version_: .GIT_SUBMODULE_UPDATE_OPTIONS_VERSION,
202 			checkout_opts: CHECKOUT_OPTION,
203 			fetch_opts: libgit2_d.remote.GIT_FETCH_OPTIONS_INIT(),
204 			allow_fetch: 1,
205 		};
206 
207 		return OUTPUT;
208 	}
209 
210 /**
211  * Initialize git_submodule_update_options structure
212  *
213  * Initializes a `git_submodule_update_options` with default values. Equivalent to
214  * creating an instance with `GIT_SUBMODULE_UPDATE_OPTIONS_INIT`.
215  *
216  * Params:
217  *      opts = The `git_submodule_update_options` struct to initialize.
218  *      version = The struct version; pass `GIT_SUBMODULE_UPDATE_OPTIONS_VERSION`.
219  *
220  * Returns: Zero on success; -1 on failure.
221  */
222 //GIT_EXTERN
223 int git_submodule_update_options_init(.git_submodule_update_options* opts, uint version_);
224 
225 /**
226  * Update a submodule. This will clone a missing submodule and
227  * checkout the subrepository to the commit specified in the index of
228  * the containing repository. If the submodule repository doesn't contain
229  * the target commit (e.g. because fetchRecurseSubmodules isn't set), then
230  * the submodule is fetched using the fetch options supplied in options.
231  *
232  * Params:
233  *      submodule = Submodule object
234  *      init = If the submodule is not initialized, setting this flag to true will initialize the submodule before updating. Otherwise, this will return an error if attempting to update an uninitialzed repository. but setting this to true forces them to be updated.
235  *      options = configuration options for the update.  If null, the function works as though GIT_SUBMODULE_UPDATE_OPTIONS_INIT was passed.
236  *
237  * Returns: 0 on success, any non-zero return value from a callback function, or a negative value to indicate an error (use `git_error_last` for a detailed error message).
238  */
239 //GIT_EXTERN
240 int git_submodule_update(libgit2_d.types.git_submodule* submodule, int init, .git_submodule_update_options* options);
241 
242 /**
243  * Lookup submodule information by name or path.
244  *
245  * Given either the submodule name or path (they are usually the same), this
246  * returns a structure describing the submodule.
247  *
248  * There are two expected error scenarios:
249  *
250  * - The submodule is not mentioned in the HEAD, the index, and the config,
251  *   but does "exist" in the working directory (i.e. there is a subdirectory
252  *   that appears to be a Git repository).  In this case, this function
253  *   returns git_error_code.GIT_EEXISTS to indicate a sub-repository exists but not in a
254  *   state where a git_submodule can be instantiated.
255  * - The submodule is not mentioned in the HEAD, index, or config and the
256  *   working directory doesn't contain a value git repo at that path.
257  *   There may or may not be anything else at that path, but nothing that
258  *   looks like a submodule.  In this case, this returns git_error_code.GIT_ENOTFOUND.
259  *
260  * You must call `git_submodule_free` when done with the submodule.
261  *
262  * Params:
263  *      out_ = Output ptr to submodule; pass null to just get return code
264  *      repo = The parent repository
265  *      name = The name of or path to the submodule; trailing slashes okay
266  *
267  * Returns: 0 on success, git_error_code.GIT_ENOTFOUND if submodule does not exist, git_error_code.GIT_EEXISTS if a repository is found in working directory only, -1 on other errors.
268  */
269 //GIT_EXTERN
270 int git_submodule_lookup(libgit2_d.types.git_submodule** out_, libgit2_d.types.git_repository* repo, const (char)* name);
271 
272 /**
273  * Release a submodule
274  *
275  * Params:
276  *      submodule = Submodule object
277  */
278 //GIT_EXTERN
279 void git_submodule_free(libgit2_d.types.git_submodule* submodule);
280 
281 /**
282  * Iterate over all tracked submodules of a repository.
283  *
284  * See the note on `git_submodule` above.  This iterates over the tracked
285  * submodules as described therein.
286  *
287  * If you are concerned about items in the working directory that look like
288  * submodules but are not tracked, the diff API will generate a diff record
289  * for workdir items that look like submodules but are not tracked, showing
290  * them as added in the workdir.  Also, the status API will treat the entire
291  * subdirectory of a contained git repo as a single git_status_t.GIT_STATUS_WT_NEW item.
292  *
293  * Params:
294  *      repo = The repository
295  *      callback = Function to be called with the name of each submodule. Return a non-zero value to terminate the iteration.
296  *      payload = Extra data to pass to callback
297  *
298  * Returns: 0 on success, -1 on error, or non-zero return value of callback
299  */
300 //GIT_EXTERN
301 int git_submodule_foreach(libgit2_d.types.git_repository* repo, .git_submodule_cb callback, void* payload);
302 
303 /**
304  * Set up a new git submodule for checkout.
305  *
306  * This does "git submodule add" up to the fetch and checkout of the
307  * submodule contents.  It preps a new submodule, creates an entry in
308  * .gitmodules and creates an empty initialized repository either at the
309  * given path in the working directory or in .git/modules with a gitlink
310  * from the working directory to the new repo.
311  *
312  * To fully emulate "git submodule add" call this function, then open the
313  * submodule repo and perform the clone step as needed (if you don't need
314  * anything custom see `git_submodule_add_clone()`). Lastly, call
315  * `git_submodule_add_finalize()` to wrap up adding the new submodule and
316  * .gitmodules to the index to be ready to commit.
317  *
318  * You must call `git_submodule_free` on the submodule object when done.
319  *
320  * Params:
321  *      out_ = The newly created submodule ready to open for clone
322  *      repo = The repository in which you want to create the submodule
323  *      url = URL for the submodule's remote
324  *      path = Path at which the submodule should be created
325  *      use_gitlink = Should workdir contain a gitlink to the repo in .git/modules vs. repo directly in workdir.
326  *
327  * Returns: 0 on success, git_error_code.GIT_EEXISTS if submodule already exists, -1 on other errors.
328  */
329 //GIT_EXTERN
330 int git_submodule_add_setup(libgit2_d.types.git_submodule** out_, libgit2_d.types.git_repository* repo, const (char)* url, const (char)* path, int use_gitlink);
331 
332 /**
333  * Perform the clone step for a newly created submodule.
334  *
335  * This performs the necessary `git_clone` to setup a newly-created submodule.
336  *
337  * Params:
338  *      out_ = The newly created repository object. Optional.
339  *      submodule = The submodule currently waiting for its clone.
340  *      opts = The options to use.
341  *
342  * Returns: 0 on success, -1 on other errors (see git_clone).
343  */
344 //GIT_EXTERN
345 int git_submodule_clone(libgit2_d.types.git_repository** out_, libgit2_d.types.git_submodule* submodule, const (.git_submodule_update_options)* opts);
346 
347 /**
348  * Resolve the setup of a new git submodule.
349  *
350  * This should be called on a submodule once you have called add setup
351  * and done the clone of the submodule.  This adds the .gitmodules file
352  * and the newly cloned submodule to the index to be ready to be committed
353  * (but doesn't actually do the commit).
354  *
355  * Params:
356  *      submodule = The submodule to finish adding.
357  */
358 //GIT_EXTERN
359 int git_submodule_add_finalize(libgit2_d.types.git_submodule* submodule);
360 
361 /**
362  * Add current submodule HEAD commit to index of superproject.
363  *
364  * Params:
365  *      submodule = The submodule to add to the index
366  *      write_index = Boolean if this should immediately write the index file.  If you pass this as false, you will have to get the git_index and explicitly call `git_index_write()` on it to save the change.
367  *
368  * Returns: 0 on success, <0 on failure
369  */
370 //GIT_EXTERN
371 int git_submodule_add_to_index(libgit2_d.types.git_submodule* submodule, int write_index);
372 
373 /**
374  * Get the containing repository for a submodule.
375  *
376  * This returns a pointer to the repository that contains the submodule.
377  * This is a just a reference to the repository that was passed to the
378  * original `git_submodule_lookup()` call, so if that repository has been
379  * freed, then this may be a dangling reference.
380  *
381  * Params:
382  *      submodule = Pointer to submodule object
383  *
384  * Returns: Pointer to `libgit2_d.types.git_repository`
385  */
386 //GIT_EXTERN
387 libgit2_d.types.git_repository* git_submodule_owner(libgit2_d.types.git_submodule* submodule);
388 
389 /**
390  * Get the name of submodule.
391  *
392  * Params:
393  *      submodule = Pointer to submodule object
394  *
395  * Returns: Pointer to the submodule name
396  */
397 //GIT_EXTERN
398 const (char)* git_submodule_name(libgit2_d.types.git_submodule* submodule);
399 
400 /**
401  * Get the path to the submodule.
402  *
403  * The path is almost always the same as the submodule name, but the
404  * two are actually not required to match.
405  *
406  * Params:
407  *      submodule = Pointer to submodule object
408  *
409  * Returns: Pointer to the submodule path
410  */
411 //GIT_EXTERN
412 const (char)* git_submodule_path(libgit2_d.types.git_submodule* submodule);
413 
414 /**
415  * Get the URL for the submodule.
416  *
417  * Params:
418  *      submodule = Pointer to submodule object
419  *
420  * Returns: Pointer to the submodule url
421  */
422 //GIT_EXTERN
423 const (char)* git_submodule_url(libgit2_d.types.git_submodule* submodule);
424 
425 /**
426  * Resolve a submodule url relative to the given repository.
427  *
428  * Params:
429  *      out_ = buffer to store the absolute submodule url in
430  *      repo = Pointer to repository object
431  *      url = Relative url
432  *
433  * Returns: 0 or an error code
434  */
435 //GIT_EXTERN
436 int git_submodule_resolve_url(libgit2_d.buffer.git_buf* out_, libgit2_d.types.git_repository* repo, const (char)* url);
437 
438 /**
439  * Get the branch for the submodule.
440  *
441  * Params:
442  *      submodule = Pointer to submodule object
443  *
444  * Returns: Pointer to the submodule branch
445  */
446 //GIT_EXTERN
447 const (char)* git_submodule_branch(libgit2_d.types.git_submodule* submodule);
448 
449 /**
450  * Set the branch for the submodule in the configuration
451  *
452  * After calling this, you may wish to call `git_submodule_sync()` to
453  * write the changes to the checked out submodule repository.
454  *
455  * Params:
456  *      repo = the repository to affect
457  *      name = the name of the submodule to configure
458  *      branch = Branch that should be used for the submodule
459  *
460  * Returns: 0 on success, <0 on failure
461  */
462 //GIT_EXTERN
463 int git_submodule_set_branch(libgit2_d.types.git_repository* repo, const (char)* name, const (char)* branch);
464 
465 /**
466  * Set the URL for the submodule in the configuration
467  *
468  *
469  * After calling this, you may wish to call `git_submodule_sync()` to
470  * write the changes to the checked out submodule repository.
471  *
472  * Params:
473  *      repo = the repository to affect
474  *      name = the name of the submodule to configure
475  *      url = URL that should be used for the submodule
476  *
477  * Returns: 0 on success, <0 on failure
478  */
479 //GIT_EXTERN
480 int git_submodule_set_url(libgit2_d.types.git_repository* repo, const (char)* name, const (char)* url);
481 
482 /**
483  * Get the OID for the submodule in the index.
484  *
485  * Params:
486  *      submodule = Pointer to submodule object
487  *
488  * Returns: Pointer to git_oid or null if submodule is not in index.
489  */
490 //GIT_EXTERN
491 const (libgit2_d.oid.git_oid)* git_submodule_index_id(libgit2_d.types.git_submodule* submodule);
492 
493 /**
494  * Get the OID for the submodule in the current HEAD tree.
495  *
496  * Params:
497  *      submodule = Pointer to submodule object
498  *
499  * Returns: Pointer to git_oid or null if submodule is not in the HEAD.
500  */
501 //GIT_EXTERN
502 const (libgit2_d.oid.git_oid)* git_submodule_head_id(libgit2_d.types.git_submodule* submodule);
503 
504 /**
505  * Get the OID for the submodule in the current working directory.
506  *
507  * This returns the OID that corresponds to looking up 'HEAD' in the checked
508  * out submodule.  If there are pending changes in the index or anything
509  * else, this won't notice that.  You should call `git_submodule_status()`
510  * for a more complete picture about the state of the working directory.
511  *
512  * Params:
513  *      submodule = Pointer to submodule object
514  *
515  * Returns: Pointer to git_oid or null if submodule is not checked out.
516  */
517 //GIT_EXTERN
518 const (libgit2_d.oid.git_oid)* git_submodule_wd_id(libgit2_d.types.git_submodule* submodule);
519 
520 /**
521  * Get the ignore rule that will be used for the submodule.
522  *
523  * These values control the behavior of `git_submodule_status()` for this
524  * submodule.  There are four ignore values:
525  *
526  *  - **git_submodule_ignore_t.GIT_SUBMODULE_IGNORE_NONE** will consider any change to the contents
527  *    of the submodule from a clean checkout to be dirty, including the
528  *    addition of untracked files.  This is the default if unspecified.
529  *  - **git_submodule_ignore_t.GIT_SUBMODULE_IGNORE_UNTRACKED** examines the contents of the
530  *    working tree (i.e. call `git_status_foreach()` on the submodule) but
531  *    UNTRACKED files will not count as making the submodule dirty.
532  *  - **git_submodule_ignore_t.GIT_SUBMODULE_IGNORE_DIRTY** means to only check if the HEAD of the
533  *    submodule has moved for status.  This is fast since it does not need to
534  *    scan the working tree of the submodule at all.
535  *  - **git_submodule_ignore_t.GIT_SUBMODULE_IGNORE_ALL** means not to open the submodule repo.
536  *    The working directory will be consider clean so long as there is a
537  *    checked out version present.
538  *
539  * Params:
540  *      submodule = The submodule to check
541  *
542  * Returns: The current libgit2_d.types.git_submodule_ignore_t valyue what will be used for this submodule.
543  */
544 //GIT_EXTERN
545 libgit2_d.types.git_submodule_ignore_t git_submodule_ignore(libgit2_d.types.git_submodule* submodule);
546 
547 /**
548  * Set the ignore rule for the submodule in the configuration
549  *
550  * This does not affect any currently-loaded instances.
551  *
552  * Params:
553  *      repo = the repository to affect
554  *      name = the name of the submdule
555  *      ignore = The new value for the ignore rule
556  *
557  * Returns: 0 or an error code
558  */
559 //GIT_EXTERN
560 int git_submodule_set_ignore(libgit2_d.types.git_repository* repo, const (char)* name, libgit2_d.types.git_submodule_ignore_t ignore);
561 
562 /**
563  * Get the update rule that will be used for the submodule.
564  *
565  * This value controls the behavior of the `git submodule update` command.
566  * There are four useful values documented with `libgit2_d.types.git_submodule_update_t`.
567  *
568  * Params:
569  *      submodule = The submodule to check
570  *
571  * Returns: The current libgit2_d.types.git_submodule_update_t value that will be used for this submodule.
572  */
573 //GIT_EXTERN
574 libgit2_d.types.git_submodule_update_t git_submodule_update_strategy(libgit2_d.types.git_submodule* submodule);
575 
576 /**
577  * Set the update rule for the submodule in the configuration
578  *
579  * This setting won't affect any existing instances.
580  *
581  * Params:
582  *      repo = the repository to affect
583  *      name = the name of the submodule to configure
584  *      update = The new value to use
585  *
586  * Returns: 0 or an error code
587  */
588 //GIT_EXTERN
589 int git_submodule_set_update(libgit2_d.types.git_repository* repo, const (char)* name, libgit2_d.types.git_submodule_update_t update);
590 
591 /**
592  * Read the fetchRecurseSubmodules rule for a submodule.
593  *
594  * This accesses the submodule.<name>.fetchRecurseSubmodules value for
595  * the submodule that controls fetching behavior for the submodule.
596  *
597  * Note that at this time, libgit2 does not honor this setting and the
598  * fetch functionality current ignores submodules.
599  *
600  * Returns: 0 if fetchRecurseSubmodules is false, 1 if true
601  */
602 //GIT_EXTERN
603 libgit2_d.types.git_submodule_recurse_t git_submodule_fetch_recurse_submodules(libgit2_d.types.git_submodule* submodule);
604 
605 /**
606  * Set the fetchRecurseSubmodules rule for a submodule in the configuration
607  *
608  * This setting won't affect any existing instances.
609  *
610  * Params:
611  *      repo = the repository to affect
612  *      name = the submodule to configure
613  *      fetch_recurse_submodules = Boolean value
614  *
615  * Returns: old value for fetchRecurseSubmodules
616  */
617 //GIT_EXTERN
618 int git_submodule_set_fetch_recurse_submodules(libgit2_d.types.git_repository* repo, const (char)* name, libgit2_d.types.git_submodule_recurse_t fetch_recurse_submodules);
619 
620 /**
621  * Copy submodule info into ".git/config" file.
622  *
623  * Just like "git submodule init", this copies information about the
624  * submodule into ".git/config".  You can use the accessor functions
625  * above to alter the in-memory git_submodule object and control what
626  * is written to the config, overriding what is in .gitmodules.
627  *
628  * Params:
629  *      submodule = The submodule to write into the superproject config
630  *      overwrite = By default, existing entries will not be overwritten, but setting this to true forces them to be updated.
631  *
632  * Returns: 0 on success, <0 on failure.
633  */
634 //GIT_EXTERN
635 int git_submodule_init(libgit2_d.types.git_submodule* submodule, int overwrite);
636 
637 /**
638  * Set up the subrepository for a submodule in preparation for clone.
639  *
640  * This function can be called to init and set up a submodule
641  * repository from a submodule in preparation to clone it from
642  * its remote.
643  *
644  * Params:
645  *      out_ = Output pointer to the created git repository.
646  *      sm = The submodule to create a new subrepository from.
647  *      use_gitlink = Should the workdir contain a gitlink to the repo in .git/modules vs. repo directly in workdir.
648  *
649  * Returns: 0 on success, <0 on failure.
650  */
651 //GIT_EXTERN
652 int git_submodule_repo_init(libgit2_d.types.git_repository** out_, const (libgit2_d.types.git_submodule)* sm, int use_gitlink);
653 
654 /**
655  * Copy submodule remote info into submodule repo.
656  *
657  * This copies the information about the submodules URL into the checked out
658  * submodule config, acting like "git submodule sync".  This is useful if
659  * you have altered the URL for the submodule (or it has been altered by a
660  * fetch of upstream changes) and you need to update your local repo.
661  */
662 //GIT_EXTERN
663 int git_submodule_sync(libgit2_d.types.git_submodule* submodule);
664 
665 /**
666  * Open the repository for a submodule.
667  *
668  * This is a newly opened repository object.  The caller is responsible for
669  * calling `git_repository_free()` on it when done.  Multiple calls to this
670  * function will return distinct `libgit2_d.types.git_repository` objects.  This will only
671  * work if the submodule is checked out into the working directory.
672  *
673  * Params:
674  *      repo = Pointer to the submodule repo which was opened
675  *      submodule = Submodule to be opened
676  *
677  * Returns: 0 on success, <0 if submodule repo could not be opened.
678  */
679 //GIT_EXTERN
680 int git_submodule_open(libgit2_d.types.git_repository** repo, libgit2_d.types.git_submodule* submodule);
681 
682 /**
683  * Reread submodule info from config, index, and HEAD.
684  *
685  * Call this to reread cached submodule information for this submodule if
686  * you have reason to believe that it has changed.
687  *
688  * Params:
689  *      submodule = The submodule to reload
690  *      force = Force reload even if the data doesn't seem out of date
691  *
692  * Returns: 0 on success, <0 on error
693  */
694 //GIT_EXTERN
695 int git_submodule_reload(libgit2_d.types.git_submodule* submodule, int force);
696 
697 /**
698  * Get the status for a submodule.
699  *
700  * This looks at a submodule and tries to determine the status.  It
701  * will return a combination of the `GIT_SUBMODULE_STATUS` values above.
702  * How deeply it examines the working directory to do this will depend
703  * on the `libgit2_d.types.git_submodule_ignore_t` value for the submodule.
704  *
705  * Params:
706  *      status = Combination of `GIT_SUBMODULE_STATUS` flags
707  *      repo = the repository in which to look
708  *      name = name of the submodule
709  *      ignore = the ignore rules to follow
710  *
711  * Returns: 0 on success, <0 on error
712  */
713 //GIT_EXTERN
714 int git_submodule_status(uint* status, libgit2_d.types.git_repository* repo, const (char)* name, libgit2_d.types.git_submodule_ignore_t ignore);
715 
716 /**
717  * Get the locations of submodule information.
718  *
719  * This is a bit like a very lightweight version of `git_submodule_status`.
720  * It just returns a made of the first four submodule status values (i.e.
721  * the ones like git_submodule_status_t.GIT_SUBMODULE_STATUS_IN_HEAD, etc) that tell you where the
722  * submodule data comes from (i.e. the HEAD commit, gitmodules file, etc.).
723  * This can be useful if you want to know if the submodule is present in the
724  * working directory at this point in time, etc.
725  *
726  * Params:
727  *      location_status = Combination of first four `GIT_SUBMODULE_STATUS` flags
728  *      submodule = Submodule for which to get status
729  *
730  * Returns: 0 on success, <0 on error
731  */
732 //GIT_EXTERN
733 int git_submodule_location(uint* location_status, libgit2_d.types.git_submodule* submodule);
734 
735 /** @} */