Commit 12595ab8 by nulltoken

revparse: deploy git_reference_remote_tracking_from_branch()

parent 84f18e35
......@@ -249,32 +249,12 @@ static int walk_ref_history(git_object **out, git_repository *repo, const char *
date_error = git__date_parse(&timestamp, 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 (!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 (!strcmp(reflogspec, "@{u}") || !strcmp(reflogspec, "@{upstream}")) {
git_reference *tracking;
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);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment