diff options
| author | Carlos Martín Nieto <cmn@dwim.me> | 2014-03-15 03:53:36 +0100 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-04-18 16:03:01 +0200 |
| commit | 29c4cb0965b67ad1ae7f640dfee67cf3ce358c26 (patch) | |
| tree | 6aaaea724b43049fdc045ae1ea6c043f44e34c0d /src/branch.c | |
| parent | 55ebd7d369a789f27fe1ad6b8ec8965aa1335d08 (diff) | |
| download | libgit2-29c4cb0965b67ad1ae7f640dfee67cf3ce358c26.tar.gz | |
Use config snapshotting
This way we can assume we have a consistent view of the config situation
when we're looking up remote, branch, pack-objects, etc.
Diffstat (limited to 'src/branch.c')
| -rw-r--r-- | src/branch.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/branch.c b/src/branch.c index 63c6ec110..d8c82b73e 100644 --- a/src/branch.c +++ b/src/branch.c @@ -306,17 +306,13 @@ int git_branch_name( static int retrieve_upstream_configuration( const char **out, - git_repository *repo, + const git_config *config, const char *canonical_branch_name, const char *format) { - git_config *config; git_buf buf = GIT_BUF_INIT; int error; - if (git_repository_config__weakptr(&config, repo) < 0) - return -1; - if (git_buf_printf(&buf, format, canonical_branch_name + strlen(GIT_REFS_HEADS_DIR)) < 0) return -1; @@ -336,6 +332,7 @@ int git_branch_upstream_name( int error = -1; git_remote *remote = NULL; const git_refspec *refspec; + git_config *config, *repo_config; assert(out && refname); @@ -344,12 +341,18 @@ int git_branch_upstream_name( if (!git_reference__is_branch(refname)) return not_a_local_branch(refname); + if ((error = git_repository_config__weakptr(&repo_config, repo)) < 0) + return error; + + if ((error = git_config_snapshot(&config, repo_config)) < 0) + return error; + if ((error = retrieve_upstream_configuration( - &remote_name, repo, refname, "branch.%s.remote")) < 0) + &remote_name, config, refname, "branch.%s.remote")) < 0) goto cleanup; if ((error = retrieve_upstream_configuration( - &merge_name, repo, refname, "branch.%s.merge")) < 0) + &merge_name, config, refname, "branch.%s.merge")) < 0) goto cleanup; if (!*remote_name || !*merge_name) { @@ -378,6 +381,7 @@ int git_branch_upstream_name( error = git_buf_set(out, git_buf_cstr(&buf), git_buf_len(&buf)); cleanup: + git_config_free(config); git_remote_free(remote); git_buf_free(&buf); return error; |
