mirror of
https://git.proxmox.com/git/libgit2
synced 2026-01-06 18:52:21 +00:00
remote: use git_branch_upstream_remote()
This reduces the clutter somewhat and lets us see what we're asking about the reference.
This commit is contained in:
parent
82374d9825
commit
e235db0212
15
src/remote.c
15
src/remote.c
@ -936,9 +936,10 @@ static int remote_head_for_ref(git_remote_head **out, git_remote *remote, git_re
|
||||
git_buf remote_name = GIT_BUF_INIT;
|
||||
git_buf upstream_name = GIT_BUF_INIT;
|
||||
git_buf config_key = GIT_BUF_INIT;
|
||||
git_buf upstream_remote = GIT_BUF_INIT;
|
||||
git_repository *repo;
|
||||
git_config *config = NULL;
|
||||
const char *ref_name, *branch_remote;
|
||||
const char *ref_name;
|
||||
int error = 0;
|
||||
|
||||
assert(out && spec && ref);
|
||||
@ -958,17 +959,16 @@ static int remote_head_for_ref(git_remote_head **out, git_remote *remote, git_re
|
||||
}
|
||||
|
||||
if ((!git_reference__is_branch(ref_name)) ||
|
||||
(error = git_repository_config_snapshot(&config, repo)) < 0 ||
|
||||
(error = git_buf_printf(&config_key, "branch.%s.remote",
|
||||
ref_name + strlen(GIT_REFS_HEADS_DIR))) < 0 ||
|
||||
(error = git_config_get_string(&branch_remote, config, git_buf_cstr(&config_key))) < 0 ||
|
||||
git__strcmp(git_remote_name(remote), branch_remote) ||
|
||||
(error = git_branch_upstream_remote(&upstream_remote, repo, ref_name)) ||
|
||||
git__strcmp(git_remote_name(remote), git_buf_cstr(&upstream_remote)) ||
|
||||
(error = git_branch_upstream_name(&upstream_name, repo, ref_name)) < 0 ||
|
||||
!git_refspec_dst_matches(spec, git_buf_cstr(&upstream_name)) ||
|
||||
(error = git_refspec_rtransform(&remote_name, spec, upstream_name.ptr)) < 0) {
|
||||
/* Not an error if there is no upstream */
|
||||
if (error == GIT_ENOTFOUND)
|
||||
if (error == GIT_ENOTFOUND) {
|
||||
giterr_clear();
|
||||
error = 0;
|
||||
}
|
||||
|
||||
goto cleanup;
|
||||
}
|
||||
@ -977,6 +977,7 @@ static int remote_head_for_ref(git_remote_head **out, git_remote *remote, git_re
|
||||
|
||||
cleanup:
|
||||
git_reference_free(resolved_ref);
|
||||
git_buf_free(&upstream_remote);
|
||||
git_buf_free(&remote_name);
|
||||
git_buf_free(&upstream_name);
|
||||
git_buf_free(&config_key);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user