mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-05 17:12:51 +00:00
Merge pull request #2022 from KTXSoftware/development
submodule branch option + little VS2013 fix
This commit is contained in:
commit
ac9f92316b
@ -283,6 +283,14 @@ GIT_EXTERN(const char *) git_submodule_path(git_submodule *submodule);
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_submodule_url(git_submodule *submodule);
|
||||
|
||||
/**
|
||||
* Get the branch for the submodule.
|
||||
*
|
||||
* @param submodule Pointer to submodule object
|
||||
* @return Pointer to the submodule branch
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_submodule_branch(git_submodule *submodule);
|
||||
|
||||
/**
|
||||
* Set the URL for the submodule.
|
||||
*
|
||||
|
@ -213,7 +213,7 @@ static int config_refresh(git_config_backend *cfg)
|
||||
int res = 0, updated = 0, any_updated = 0;
|
||||
diskfile_backend *b = (diskfile_backend *)cfg;
|
||||
git_strmap *old_values;
|
||||
struct reader *reader;
|
||||
struct reader *reader = NULL;
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < git_array_size(b->readers); i++) {
|
||||
|
@ -472,6 +472,10 @@ int git_submodule_save(git_submodule *submodule)
|
||||
(error = git_config_file_set_string(mods, key.ptr, submodule->url)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if ((error = submodule_config_key_trunc_puts(&key, "branch")) < 0 ||
|
||||
(error = git_config_file_set_string(mods, key.ptr, submodule->branch)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!(error = submodule_config_key_trunc_puts(&key, "update")) &&
|
||||
(val = git_submodule_update_to_str(submodule->update)) != NULL)
|
||||
error = git_config_file_set_string(mods, key.ptr, val);
|
||||
@ -528,6 +532,12 @@ const char *git_submodule_url(git_submodule *submodule)
|
||||
return submodule->url;
|
||||
}
|
||||
|
||||
const char *git_submodule_branch(git_submodule *submodule)
|
||||
{
|
||||
assert(submodule);
|
||||
return submodule->branch;
|
||||
}
|
||||
|
||||
int git_submodule_set_url(git_submodule *submodule, const char *url)
|
||||
{
|
||||
assert(submodule && url);
|
||||
@ -992,6 +1002,7 @@ static git_submodule *submodule_alloc(git_repository *repo, const char *name)
|
||||
sm->update = sm->update_default = GIT_SUBMODULE_UPDATE_CHECKOUT;
|
||||
sm->fetch_recurse = GIT_SUBMODULE_RECURSE_YES;
|
||||
sm->repo = repo;
|
||||
sm->branch = NULL;
|
||||
|
||||
return sm;
|
||||
}
|
||||
@ -1190,6 +1201,15 @@ static int submodule_load_from_config(
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
else if (strcasecmp(property, "branch") == 0) {
|
||||
git__free(sm->branch);
|
||||
sm->branch = NULL;
|
||||
|
||||
if (value != NULL && (sm->branch = git__strdup(value)) == NULL) {
|
||||
error = -1;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
else if (strcasecmp(property, "update") == 0) {
|
||||
if ((error = git_submodule_parse_update(&sm->update, value)) < 0)
|
||||
goto done;
|
||||
|
@ -81,6 +81,7 @@ struct git_submodule {
|
||||
char *name;
|
||||
char *path; /* important: may just point to "name" string */
|
||||
char *url;
|
||||
char *branch;
|
||||
git_submodule_update_t update;
|
||||
git_submodule_update_t update_default;
|
||||
git_submodule_ignore_t ignore;
|
||||
|
Loading…
Reference in New Issue
Block a user