Unverified Commit 936b184e by Edward Thomson Committed by GitHub

Merge pull request #6434 from tagesuhu/main

Fixes #6433: git_submodule_update fails to update configured but missing submodule
parents 12832bab 3f4b91b2
......@@ -1338,7 +1338,11 @@ int git_submodule_update(git_submodule *sm, int init, git_submodule_update_optio
/* Get the status of the submodule to determine if it is already initialized */
if ((error = git_submodule_status(&submodule_status, sm->repo, sm->name, GIT_SUBMODULE_IGNORE_UNSPECIFIED)) < 0)
goto done;
/* If the submodule is configured but hasn't been added, skip it */
if (submodule_status == GIT_SUBMODULE_STATUS_IN_CONFIG)
goto done;
/*
* If submodule work dir is not already initialized, check to see
* what we need to do (initialize, clone, return error...)
......
......@@ -206,6 +206,26 @@ void test_submodule_update__update_and_init_submodule(void)
git_submodule_free(sm);
}
void test_submodule_update__update_skip_configured_missing_submodule(void)
{
git_submodule *sm;
git_submodule_update_options update_options = GIT_SUBMODULE_UPDATE_OPTIONS_INIT;
unsigned int submodule_status = 0;
g_repo = setup_fixture_submod2();
/* get the submodule */
cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_gitmodules_only"));
cl_git_pass(git_submodule_status(&submodule_status, g_repo, "sm_gitmodules_only", GIT_SUBMODULE_IGNORE_UNSPECIFIED));
cl_assert_equal_i(submodule_status, GIT_SUBMODULE_STATUS_IN_CONFIG);
/* update (with option to initialize sub repo) */
cl_git_pass(git_submodule_update(sm, 1, &update_options));
git_submodule_free(sm);
}
void test_submodule_update__update_already_checked_out_submodule(void)
{
git_submodule *sm = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment