summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-11-02 20:11:54 +0100
committerCarlos Martín Nieto <cmn@dwim.me>2014-11-03 15:12:32 +0100
commit6d20006f7e8dbc26cf07bf8a945bc6972642c303 (patch)
tree0504f0f3a000e20f54613be7887ea25f50af45ae
parent0f838d27f19f611651df1a4a031196815ebe70cb (diff)
downloadlibgit2-6d20006f7e8dbc26cf07bf8a945bc6972642c303.tar.gz
remote: check the relevance of the refspec when updating FETCH_HEADcmn/fetch-tags-refspec
Before trying to rtransform using the given refspec to figure out what the name of the upstream branch is on the remote, we must make sure that the target of the refspec applies to the current branch's upstream.
-rw-r--r--src/remote.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/remote.c b/src/remote.c
index 0ae377e47..477a884dd 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -983,6 +983,7 @@ static int remote_head_for_ref(git_remote_head **out, git_remote *remote, git_re
(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_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)