mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-08 05:08:07 +00:00
submodule: get rid of _save()
We no longer have any setters which affect an instance, so `git_submodule_save()` is no longer relevant.
This commit is contained in:
parent
d6073b30f3
commit
961861fafa
@ -300,20 +300,6 @@ GIT_EXTERN(int) git_submodule_add_to_index(
|
|||||||
git_submodule *submodule,
|
git_submodule *submodule,
|
||||||
int write_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.
|
* Get the containing repository for a submodule.
|
||||||
*
|
*
|
||||||
|
@ -764,44 +764,6 @@ const char *git_submodule_recurse_to_str(git_submodule_recurse_t recurse)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int git_submodule_save(git_submodule *submodule)
|
|
||||||
{
|
|
||||||
int error = 0;
|
|
||||||
git_config_backend *mods;
|
|
||||||
git_buf key = GIT_BUF_INIT;
|
|
||||||
|
|
||||||
assert(submodule);
|
|
||||||
|
|
||||||
mods = open_gitmodules(submodule->repo, GITMODULES_CREATE);
|
|
||||||
if (!mods) {
|
|
||||||
giterr_set(GITERR_SUBMODULE,
|
|
||||||
"Adding submodules to a bare repository is not supported");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((error = git_buf_printf(&key, "submodule.%s.", submodule->name)) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
/* save values for path, url, update, ignore, fetchRecurseSubmodules */
|
|
||||||
|
|
||||||
if ((error = submodule_config_key_trunc_puts(&key, "path")) < 0 ||
|
|
||||||
(error = git_config_file_set_string(mods, key.ptr, submodule->path)) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
/* update internal defaults */
|
|
||||||
|
|
||||||
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:
|
|
||||||
git_config_file_free(mods);
|
|
||||||
git_buf_free(&key);
|
|
||||||
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
git_repository *git_submodule_owner(git_submodule *submodule)
|
git_repository *git_submodule_owner(git_submodule *submodule)
|
||||||
{
|
{
|
||||||
assert(submodule);
|
assert(submodule);
|
||||||
|
@ -194,12 +194,3 @@ void test_submodule_modify__set_url(void)
|
|||||||
cl_assert_equal_s(SM_LIBGIT2_URL, git_submodule_url(sm));
|
cl_assert_equal_s(SM_LIBGIT2_URL, git_submodule_url(sm));
|
||||||
git_submodule_free(sm);
|
git_submodule_free(sm);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_submodule_modify__save_last(void)
|
|
||||||
{
|
|
||||||
git_submodule *sm;
|
|
||||||
|
|
||||||
cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_gitmodules_only"));
|
|
||||||
cl_git_pass(git_submodule_save(sm));
|
|
||||||
git_submodule_free(sm);
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user