mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-07 12:57:05 +00:00
Make submodule fetchRecurse match other options
This removes the fetchRecurse compiler warnings and makes the behavior match the other submodule options (i.e. the in-memory setting can be reset to the on-disk value).
This commit is contained in:
parent
5572d2b8a1
commit
c0644c3fbb
@ -105,19 +105,6 @@ typedef enum {
|
||||
GIT_SUBMODULE_STATUS_WD_WD_MODIFIED | \
|
||||
GIT_SUBMODULE_STATUS_WD_UNTRACKED)) != 0)
|
||||
|
||||
/**
|
||||
* Options for submodule recurse.
|
||||
*
|
||||
* * 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_NO = 0,
|
||||
GIT_SUBMODULE_RECURSE_YES = 1,
|
||||
GIT_SUBMODULE_RECURSE_ONDEMAND = 2,
|
||||
} git_submodule_recurse_t;
|
||||
|
||||
/**
|
||||
* Lookup submodule information by name or path.
|
||||
*
|
||||
|
@ -323,6 +323,25 @@ typedef enum {
|
||||
GIT_SUBMODULE_IGNORE_DEFAULT = 0
|
||||
} git_submodule_ignore_t;
|
||||
|
||||
/**
|
||||
* Options for submodule recurse.
|
||||
*
|
||||
* 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,
|
||||
} git_submodule_recurse_t;
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
|
||||
|
@ -498,6 +498,7 @@ int git_submodule_save(git_submodule *submodule)
|
||||
|
||||
submodule->ignore_default = submodule->ignore;
|
||||
submodule->update_default = submodule->update;
|
||||
submodule->fetch_recurse_default = submodule->fetch_recurse;
|
||||
submodule->flags |= GIT_SUBMODULE_STATUS_IN_CONFIG;
|
||||
|
||||
cleanup:
|
||||
@ -650,6 +651,9 @@ git_submodule_recurse_t git_submodule_set_fetch_recurse_submodules(
|
||||
|
||||
assert(submodule);
|
||||
|
||||
if (fetch_recurse_submodules == GIT_SUBMODULE_RECURSE_RESET)
|
||||
fetch_recurse_submodules = submodule->fetch_recurse_default;
|
||||
|
||||
old = submodule->fetch_recurse;
|
||||
submodule->fetch_recurse = fetch_recurse_submodules;
|
||||
return old;
|
||||
@ -1000,7 +1004,7 @@ static git_submodule *submodule_alloc(git_repository *repo, const char *name)
|
||||
GIT_REFCOUNT_INC(sm);
|
||||
sm->ignore = sm->ignore_default = GIT_SUBMODULE_IGNORE_NONE;
|
||||
sm->update = sm->update_default = GIT_SUBMODULE_UPDATE_CHECKOUT;
|
||||
sm->fetch_recurse = GIT_SUBMODULE_RECURSE_YES;
|
||||
sm->fetch_recurse = sm->fetch_recurse_default = GIT_SUBMODULE_RECURSE_NO;
|
||||
sm->repo = repo;
|
||||
sm->branch = NULL;
|
||||
|
||||
@ -1218,6 +1222,7 @@ static int submodule_load_from_config(
|
||||
else if (strcasecmp(property, "fetchRecurseSubmodules") == 0) {
|
||||
if (git_submodule_parse_recurse(&sm->fetch_recurse, value) < 0)
|
||||
return -1;
|
||||
sm->fetch_recurse_default = sm->fetch_recurse;
|
||||
}
|
||||
else if (strcasecmp(property, "ignore") == 0) {
|
||||
if ((error = git_submodule_parse_ignore(&sm->ignore, value)) < 0)
|
||||
|
@ -60,7 +60,9 @@
|
||||
* - `update_default` is the update value from the config
|
||||
* - `ignore` is a git_submodule_ignore_t value - see gitmodules(5) ignore.
|
||||
* - `ignore_default` is the ignore value from the config
|
||||
* - `fetch_recurse` is 0 or 1 - see gitmodules(5) fetchRecurseSubmodules.
|
||||
* - `fetch_recurse` is a git_submodule_recurse_t value - see gitmodules(5)
|
||||
* fetchRecurseSubmodules.
|
||||
* - `fetch_recurse_default` is the recurse value from the config
|
||||
*
|
||||
* - `repo` is the parent repository that contains this submodule.
|
||||
* - `flags` after for internal use, tracking where this submodule has been
|
||||
@ -87,6 +89,7 @@ struct git_submodule {
|
||||
git_submodule_ignore_t ignore;
|
||||
git_submodule_ignore_t ignore_default;
|
||||
git_submodule_recurse_t fetch_recurse;
|
||||
git_submodule_recurse_t fetch_recurse_default;
|
||||
|
||||
/* internal information */
|
||||
git_repository *repo;
|
||||
|
@ -178,25 +178,28 @@ void test_submodule_modify__edit_and_save(void)
|
||||
cl_git_pass(git_submodule_set_url(sm1, SM_LIBGIT2_URL));
|
||||
old_ignore = git_submodule_set_ignore(sm1, GIT_SUBMODULE_IGNORE_UNTRACKED);
|
||||
old_update = git_submodule_set_update(sm1, GIT_SUBMODULE_UPDATE_REBASE);
|
||||
old_fetchrecurse = git_submodule_set_fetch_recurse_submodules(sm1, GIT_SUBMODULE_RECURSE_YES);
|
||||
old_fetchrecurse = git_submodule_set_fetch_recurse_submodules(
|
||||
sm1, GIT_SUBMODULE_RECURSE_YES);
|
||||
|
||||
cl_assert_equal_s(SM_LIBGIT2_URL, git_submodule_url(sm1));
|
||||
cl_assert_equal_i(
|
||||
(int)GIT_SUBMODULE_IGNORE_UNTRACKED, (int)git_submodule_ignore(sm1));
|
||||
GIT_SUBMODULE_IGNORE_UNTRACKED, git_submodule_ignore(sm1));
|
||||
cl_assert_equal_i(
|
||||
(int)GIT_SUBMODULE_UPDATE_REBASE, (int)git_submodule_update(sm1));
|
||||
cl_assert_equal_i(GIT_SUBMODULE_RECURSE_YES, git_submodule_fetch_recurse_submodules(sm1));
|
||||
GIT_SUBMODULE_UPDATE_REBASE, git_submodule_update(sm1));
|
||||
cl_assert_equal_i(
|
||||
GIT_SUBMODULE_RECURSE_YES, git_submodule_fetch_recurse_submodules(sm1));
|
||||
|
||||
/* revert without saving (and confirm setters return old value) */
|
||||
cl_git_pass(git_submodule_set_url(sm1, old_url));
|
||||
cl_assert_equal_i(
|
||||
(int)GIT_SUBMODULE_IGNORE_UNTRACKED,
|
||||
(int)git_submodule_set_ignore(sm1, GIT_SUBMODULE_IGNORE_RESET));
|
||||
GIT_SUBMODULE_IGNORE_UNTRACKED,
|
||||
git_submodule_set_ignore(sm1, GIT_SUBMODULE_IGNORE_RESET));
|
||||
cl_assert_equal_i(
|
||||
(int)GIT_SUBMODULE_UPDATE_REBASE,
|
||||
(int)git_submodule_set_update(sm1, GIT_SUBMODULE_UPDATE_RESET));
|
||||
GIT_SUBMODULE_UPDATE_REBASE,
|
||||
git_submodule_set_update(sm1, GIT_SUBMODULE_UPDATE_RESET));
|
||||
cl_assert_equal_i(
|
||||
GIT_SUBMODULE_RECURSE_YES, git_submodule_set_fetch_recurse_submodules(sm1, old_fetchrecurse));
|
||||
GIT_SUBMODULE_RECURSE_YES, git_submodule_set_fetch_recurse_submodules(
|
||||
sm1, GIT_SUBMODULE_RECURSE_RESET));
|
||||
|
||||
/* check that revert was successful */
|
||||
cl_assert_equal_s(old_url, git_submodule_url(sm1));
|
||||
@ -243,19 +246,22 @@ void test_submodule_modify__edit_and_save(void)
|
||||
|
||||
cl_assert_equal_s(SM_LIBGIT2_URL, git_submodule_url(sm2));
|
||||
cl_assert_equal_i(
|
||||
(int)GIT_SUBMODULE_IGNORE_UNTRACKED, (int)git_submodule_ignore(sm2));
|
||||
GIT_SUBMODULE_IGNORE_UNTRACKED, git_submodule_ignore(sm2));
|
||||
cl_assert_equal_i(
|
||||
(int)GIT_SUBMODULE_UPDATE_REBASE, (int)git_submodule_update(sm2));
|
||||
cl_assert_equal_i(GIT_SUBMODULE_RECURSE_YES, git_submodule_fetch_recurse_submodules(sm2));
|
||||
GIT_SUBMODULE_UPDATE_REBASE, git_submodule_update(sm2));
|
||||
cl_assert_equal_i(
|
||||
GIT_SUBMODULE_RECURSE_NO, git_submodule_fetch_recurse_submodules(sm2));
|
||||
|
||||
/* set fetchRecurseSubmodules on-demand */
|
||||
cl_git_pass(git_submodule_reload(sm1));
|
||||
git_submodule_set_fetch_recurse_submodules(sm1, GIT_SUBMODULE_RECURSE_ONDEMAND);
|
||||
cl_assert_equal_i(GIT_SUBMODULE_RECURSE_ONDEMAND, git_submodule_fetch_recurse_submodules(sm1));
|
||||
cl_assert_equal_i(
|
||||
GIT_SUBMODULE_RECURSE_ONDEMAND, git_submodule_fetch_recurse_submodules(sm1));
|
||||
/* call save */
|
||||
cl_git_pass(git_submodule_save(sm1));
|
||||
cl_git_pass(git_submodule_reload(sm1));
|
||||
cl_assert_equal_i(GIT_SUBMODULE_RECURSE_ONDEMAND, git_submodule_fetch_recurse_submodules(sm1));
|
||||
cl_assert_equal_i(
|
||||
GIT_SUBMODULE_RECURSE_ONDEMAND, git_submodule_fetch_recurse_submodules(sm1));
|
||||
|
||||
git_repository_free(r2);
|
||||
git__free(old_url);
|
||||
|
Loading…
Reference in New Issue
Block a user