summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2012-07-12 00:52:01 +0200
committernulltoken <emeric.fermas@gmail.com>2012-07-12 01:06:13 +0200
commit12595ab8f91a71e5a596a883b31789d5317e9ec2 (patch)
tree18621f9995e7c9898fc42d849230102b42d0519b
parent84f18e358742b77bfc815f2a360a41f3f1b9abd7 (diff)
downloadlibgit2-12595ab8f91a71e5a596a883b31789d5317e9ec2.tar.gz
revparse: deploy git_reference_remote_tracking_from_branch()
-rw-r--r--src/revparse.c32
1 files changed, 6 insertions, 26 deletions
diff --git a/src/revparse.c b/src/revparse.c
index 670f67e1..2b03c86b 100644
--- a/src/revparse.c
+++ b/src/revparse.c
@@ -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);
}
}