diff options
| author | Russell Belfer <rb@github.com> | 2014-01-03 14:40:25 -0800 |
|---|---|---|
| committer | Russell Belfer <rb@github.com> | 2014-01-03 14:40:25 -0800 |
| commit | ac9f92316b4fcace1c591a33d20fa4514f3ec2c6 (patch) | |
| tree | a0d0739e314182f8a1846077951e39a73e860bda /src | |
| parent | 5f5e44652eba5bffe57034a0ad839017bff4de44 (diff) | |
| parent | 10311979492a4b91b24ebab178588e9af801bc42 (diff) | |
| download | libgit2-ac9f92316b4fcace1c591a33d20fa4514f3ec2c6.tar.gz | |
Merge pull request #2022 from KTXSoftware/development
submodule branch option + little VS2013 fix
Diffstat (limited to 'src')
| -rw-r--r-- | src/config_file.c | 2 | ||||
| -rw-r--r-- | src/submodule.c | 20 | ||||
| -rw-r--r-- | src/submodule.h | 1 |
3 files changed, 22 insertions, 1 deletions
diff --git a/src/config_file.c b/src/config_file.c index 0971aa7b0..2e78f7c8b 100644 --- a/src/config_file.c +++ b/src/config_file.c @@ -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++) { diff --git a/src/submodule.c b/src/submodule.c index 26dfe2c6b..3ffbfdba4 100644 --- a/src/submodule.c +++ b/src/submodule.c @@ -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; diff --git a/src/submodule.h b/src/submodule.h index 2a610e112..94748aca0 100644 --- a/src/submodule.h +++ b/src/submodule.h @@ -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; |
