diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2015-06-24 23:34:40 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-06-24 23:34:40 +0200 |
commit | daacf96d101b9d2100a5028090b5af5249d8893d (patch) | |
tree | 450942a1431c22f634f9c16916408bd80f165702 /include/git2 | |
parent | e1f434f8643f26d48ee8de21d715069de76b14e1 (diff) | |
parent | 783672fa5be4f0e9dce72bcd74690258bdbac0a9 (diff) | |
download | libgit2-daacf96d101b9d2100a5028090b5af5249d8893d.tar.gz |
Merge pull request #3097 from libgit2/cmn/submodule-config-state
Remove run-time configuration settings from submodules
Diffstat (limited to 'include/git2')
-rw-r--r-- | include/git2/diff.h | 2 | ||||
-rw-r--r-- | include/git2/submodule.h | 113 | ||||
-rw-r--r-- | include/git2/types.h | 12 |
3 files changed, 44 insertions, 83 deletions
diff --git a/include/git2/diff.h b/include/git2/diff.h index 0ecdc1bed..90e2e1b22 100644 --- a/include/git2/diff.h +++ b/include/git2/diff.h @@ -399,7 +399,7 @@ typedef struct { * `git_diff_options_init` programmatic initialization. */ #define GIT_DIFF_OPTIONS_INIT \ - {GIT_DIFF_OPTIONS_VERSION, 0, GIT_SUBMODULE_IGNORE_DEFAULT, {NULL,0}, NULL, NULL, 3} + {GIT_DIFF_OPTIONS_VERSION, 0, GIT_SUBMODULE_IGNORE_FALLBACK, {NULL,0}, NULL, NULL, 3} /** * Initializes a `git_diff_options` with default values. Equivalent to diff --git a/include/git2/submodule.h b/include/git2/submodule.h index 48faf8a49..cbafccd1b 100644 --- a/include/git2/submodule.h +++ b/include/git2/submodule.h @@ -301,20 +301,6 @@ GIT_EXTERN(int) git_submodule_add_to_index( int write_index); /** - * Write submodule settings to .gitmodules file. - * - * This commits any in-memory changes to the submodule to the gitmodules - * file on disk. You may also be interested in `git_submodule_init()` which - * writes submodule info to ".git/config" (which is better for local changes - * to submodule settings) and/or `git_submodule_sync()` which writes - * settings about remotes to the actual submodule repository. - * - * @param submodule The submodule to write. - * @return 0 on success, <0 on failure. - */ -GIT_EXTERN(int) git_submodule_save(git_submodule *submodule); - -/** * Get the containing repository for a submodule. * * This returns a pointer to the repository that contains the submodule. @@ -373,36 +359,31 @@ GIT_EXTERN(int) git_submodule_resolve_url(git_buf *out, git_repository *repo, co GIT_EXTERN(const char *) git_submodule_branch(git_submodule *submodule); /** - * Set the branch for the submodule. + * Set the branch for the submodule in the configuration * - * This sets the branch in memory for the submodule. This will be used for - * any following submodule actions while this submodule data is in memory. - * - * After calling this, you may wish to call `git_submodule_save()` to write - * the changes back to the ".gitmodules" file and `git_submodule_sync()` to + * After calling this, you may wish to call `git_submodule_sync()` to * write the changes to the checked out submodule repository. * - * @param submodule Pointer to the submodule object + * @param repo the repository to affect + * @param name the name of the submodule to configure * @param branch Branch that should be used for the submodule * @return 0 on success, <0 on failure */ -GIT_EXTERN(int) git_submodule_set_branch(git_submodule *submodule, const char *branch); +GIT_EXTERN(int) git_submodule_set_branch(git_repository *repo, const char *name, const char *branch); /** - * Set the URL for the submodule. + * Set the URL for the submodule in the configuration * - * This sets the URL in memory for the submodule. This will be used for - * any following submodule actions while this submodule data is in memory. * - * After calling this, you may wish to call `git_submodule_save()` to write - * the changes back to the ".gitmodules" file and `git_submodule_sync()` to + * After calling this, you may wish to call `git_submodule_sync()` to * write the changes to the checked out submodule repository. * - * @param submodule Pointer to the submodule object + * @param repo the repository to affect + * @param name the name of the submodule to configure * @param url URL that should be used for the submodule * @return 0 on success, <0 on failure */ -GIT_EXTERN(int) git_submodule_set_url(git_submodule *submodule, const char *url); +GIT_EXTERN(int) git_submodule_set_url(git_repository *repo, const char *name, const char *url); /** * Get the OID for the submodule in the index. @@ -452,9 +433,6 @@ GIT_EXTERN(const git_oid *) git_submodule_wd_id(git_submodule *submodule); * The working directory will be consider clean so long as there is a * checked out version present. * - * plus the special **GIT_SUBMODULE_IGNORE_RESET** which can be used with - * `git_submodule_set_ignore()` to revert to the on-disk setting. - * * @param submodule The submodule to check * @return The current git_submodule_ignore_t valyue what will be used for * this submodule. @@ -463,32 +441,25 @@ GIT_EXTERN(git_submodule_ignore_t) git_submodule_ignore( git_submodule *submodule); /** - * Set the ignore rule for the submodule. - * - * This sets the in-memory ignore rule for the submodule which will - * control the behavior of `git_submodule_status()`. + * Set the ignore rule for the submodule in the configuration * - * To make changes persistent, call `git_submodule_save()` to write the - * value to disk (in the ".gitmodules" and ".git/config" files). + * This does not affect any currently-loaded instances. * - * Call with `GIT_SUBMODULE_IGNORE_RESET` or call `git_submodule_reload()` - * to revert the in-memory rule to the value that is on disk. - * - * @param submodule The submodule to update + * @param repo the repository to affect + * @param name the name of the submdule * @param ignore The new value for the ignore rule - * @return old value for ignore + * @return 0 or an error code */ -GIT_EXTERN(git_submodule_ignore_t) git_submodule_set_ignore( - git_submodule *submodule, +GIT_EXTERN(int) git_submodule_set_ignore( + git_repository *repo, + const char *name, git_submodule_ignore_t ignore); /** * Get the update rule that will be used for the submodule. * * This value controls the behavior of the `git submodule update` command. - * There are four useful values documented with `git_submodule_update_t` - * plus the `GIT_SUBMODULE_UPDATE_RESET` which can be used to revert to - * the on-disk setting. + * There are four useful values documented with `git_submodule_update_t`. * * @param submodule The submodule to check * @return The current git_submodule_update_t value that will be used @@ -498,23 +469,18 @@ GIT_EXTERN(git_submodule_update_t) git_submodule_update_strategy( git_submodule *submodule); /** - * Set the update rule for the submodule. - * - * The initial value comes from the ".git/config" setting of - * `submodule.$name.update` for this submodule (which is initialized from - * the ".gitmodules" file). Using this function sets the update rule in - * memory for the submodule. Call `git_submodule_save()` to write out the - * new update rule. + * Set the update rule for the submodule in the configuration * - * Calling this again with GIT_SUBMODULE_UPDATE_RESET or calling - * `git_submodule_reload()` will revert the rule to the on disk value. + * This setting won't affect any existing instances. * - * @param submodule The submodule to update + * @param repo the repository to affect + * @param name the name of the submodule to configure * @param update The new value to use - * @return old value for update + * @return 0 or an error code */ -GIT_EXTERN(git_submodule_update_t) git_submodule_set_update( - git_submodule *submodule, +GIT_EXTERN(int) git_submodule_set_update( + git_repository *repo, + const char *name, git_submodule_update_t update); /** @@ -532,18 +498,18 @@ GIT_EXTERN(git_submodule_recurse_t) git_submodule_fetch_recurse_submodules( git_submodule *submodule); /** - * Set the fetchRecurseSubmodules rule for a submodule. + * Set the fetchRecurseSubmodules rule for a submodule in the configuration * - * This sets the submodule.<name>.fetchRecurseSubmodules value for - * the submodule. You should call `git_submodule_save()` if you want - * to persist the new value. + * This setting won't affect any existing instances. * - * @param submodule The submodule to modify + * @param repo the repository to affect + * @param name the submodule to configure * @param fetch_recurse_submodules Boolean value * @return old value for fetchRecurseSubmodules */ -GIT_EXTERN(git_submodule_recurse_t) git_submodule_set_fetch_recurse_submodules( - git_submodule *submodule, +GIT_EXTERN(int) git_submodule_set_fetch_recurse_submodules( + git_repository *repo, + const char *name, git_submodule_recurse_t fetch_recurse_submodules); /** @@ -634,16 +600,19 @@ GIT_EXTERN(int) git_submodule_reload_all(git_repository *repo, int force); * This looks at a submodule and tries to determine the status. It * will return a combination of the `GIT_SUBMODULE_STATUS` values above. * How deeply it examines the working directory to do this will depend - * on the `git_submodule_ignore_t` value for the submodule - which can be - * set either temporarily or permanently with `git_submodule_set_ignore()`. + * on the `git_submodule_ignore_t` value for the submodule. * * @param status Combination of `GIT_SUBMODULE_STATUS` flags - * @param submodule Submodule for which to get status + * @param repo the repository in which to look + * @param name name of the submodule + * @param ignore the ignore rules to follow * @return 0 on success, <0 on error */ GIT_EXTERN(int) git_submodule_status( unsigned int *status, - git_submodule *submodule); + git_repository *repo, + const char *name, + git_submodule_ignore_t ignore); /** * Get the locations of submodule information. diff --git a/include/git2/types.h b/include/git2/types.h index c97e5ba61..e975c6097 100644 --- a/include/git2/types.h +++ b/include/git2/types.h @@ -349,7 +349,6 @@ typedef struct git_submodule git_submodule; * * The values are: * - * - GIT_SUBMODULE_UPDATE_RESET: reset to the on-disk value. * - GIT_SUBMODULE_UPDATE_CHECKOUT: the default; when a submodule is * updated, checkout the new detached HEAD to the submodule directory. * - GIT_SUBMODULE_UPDATE_REBASE: update by rebasing the current checked @@ -362,8 +361,6 @@ typedef struct git_submodule git_submodule; * when we don't want any particular update rule to be specified. */ typedef enum { - GIT_SUBMODULE_UPDATE_RESET = -1, - GIT_SUBMODULE_UPDATE_CHECKOUT = 1, GIT_SUBMODULE_UPDATE_REBASE = 2, GIT_SUBMODULE_UPDATE_MERGE = 3, @@ -386,7 +383,7 @@ typedef enum { * * The values are: * - * - GIT_SUBMODULE_IGNORE_RESET: reset to the on-disk value. + * - GIT_SUBMODULE_IGNORE_FALLBACK: use the submodule's configuration * - GIT_SUBMODULE_IGNORE_NONE: don't ignore any change - i.e. even an * untracked file, will mark the submodule as dirty. Ignored files are * still ignored, of course. @@ -400,14 +397,12 @@ typedef enum { * when we don't want any particular ignore rule to be specified. */ typedef enum { - GIT_SUBMODULE_IGNORE_RESET = -1, /**< reset to on-disk value */ + GIT_SUBMODULE_IGNORE_FALLBACK = -1, /**< use the submodule's configuration */ GIT_SUBMODULE_IGNORE_NONE = 1, /**< any change or untracked == dirty */ GIT_SUBMODULE_IGNORE_UNTRACKED = 2, /**< dirty if tracked files change */ GIT_SUBMODULE_IGNORE_DIRTY = 3, /**< only dirty if HEAD moved */ GIT_SUBMODULE_IGNORE_ALL = 4, /**< never dirty */ - - GIT_SUBMODULE_IGNORE_DEFAULT = 0 } git_submodule_ignore_t; /** @@ -415,15 +410,12 @@ typedef enum { * * Represent the value of `submodule.$name.fetchRecurseSubmodules` * - * * GIT_SUBMODULE_RECURSE_RESET - reset to the on-disk value * * GIT_SUBMODULE_RECURSE_NO - do no recurse into submodules * * GIT_SUBMODULE_RECURSE_YES - recurse into submodules * * GIT_SUBMODULE_RECURSE_ONDEMAND - recurse into submodules only when * commit not already in local clone */ typedef enum { - GIT_SUBMODULE_RECURSE_RESET = -1, - GIT_SUBMODULE_RECURSE_NO = 0, GIT_SUBMODULE_RECURSE_YES = 1, GIT_SUBMODULE_RECURSE_ONDEMAND = 2, |