mirror of
https://git.proxmox.com/git/libgit2
synced 2025-06-19 06:41:46 +00:00
revparse: deploy git_reference_remote_tracking_from_branch()
This commit is contained in:
parent
84f18e3587
commit
12595ab8f9
@ -249,32 +249,12 @@ static int walk_ref_history(git_object **out, git_repository *repo, const char *
|
||||
date_error = git__date_parse(×tamp, git_buf_cstr(&datebuf));
|
||||
|
||||
/* @{u} or @{upstream} -> upstream branch, for a tracking branch. This is stored in the config. */
|
||||
if (!git__prefixcmp(git_reference_name(disambiguated), GIT_REFS_HEADS_DIR) &&
|
||||
(!strcmp(reflogspec, "@{u}") || !strcmp(reflogspec, "@{upstream}"))) {
|
||||
git_config *cfg;
|
||||
if (!git_repository_config(&cfg, repo)) {
|
||||
/* Is the ref a tracking branch? */
|
||||
const char *remote;
|
||||
git_buf_clear(&buf);
|
||||
git_buf_printf(&buf, "branch.%s.remote",
|
||||
git_reference_name(disambiguated) + strlen(GIT_REFS_HEADS_DIR));
|
||||
if (!strcmp(reflogspec, "@{u}") || !strcmp(reflogspec, "@{upstream}")) {
|
||||
git_reference *tracking;
|
||||
|
||||
if (!git_config_get_string(&remote, cfg, git_buf_cstr(&buf))) {
|
||||
/* Yes. Find the first merge target name. */
|
||||
const char *mergetarget;
|
||||
git_buf_clear(&buf);
|
||||
git_buf_printf(&buf, "branch.%s.merge",
|
||||
git_reference_name(disambiguated) + strlen(GIT_REFS_HEADS_DIR));
|
||||
|
||||
if (!git_config_get_string(&mergetarget, cfg, git_buf_cstr(&buf)) &&
|
||||
!git__prefixcmp(mergetarget, "refs/heads/")) {
|
||||
/* Success. Look up the target and fetch the object. */
|
||||
git_buf_clear(&buf);
|
||||
git_buf_printf(&buf, "refs/remotes/%s/%s", remote, mergetarget+11);
|
||||
retcode = revparse_lookup_fully_qualifed_ref(out, repo, git_buf_cstr(&buf));
|
||||
}
|
||||
}
|
||||
git_config_free(cfg);
|
||||
if (!(retcode = git_reference_remote_tracking_from_branch(&tracking, disambiguated))) {
|
||||
retcode = revparse_lookup_fully_qualifed_ref(out, repo, git_reference_name(tracking));
|
||||
git_reference_free(tracking);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user