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