Commit 961861fa by Carlos Martín Nieto

submodule: get rid of `_save()`

We no longer have any setters which affect an instance, so
`git_submodule_save()` is no longer relevant.
parent d6073b30
...@@ -301,20 +301,6 @@ GIT_EXTERN(int) git_submodule_add_to_index( ...@@ -301,20 +301,6 @@ GIT_EXTERN(int) git_submodule_add_to_index(
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.
* *
* This returns a pointer to the repository that contains the submodule. * This returns a pointer to the repository that contains the submodule.
......
...@@ -764,44 +764,6 @@ const char *git_submodule_recurse_to_str(git_submodule_recurse_t recurse) ...@@ -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) ...@@ -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);
}
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