diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2014-11-06 10:19:22 -0500 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2014-11-06 10:19:22 -0500 |
commit | f890a84fe00091ac4b9430c131e25d5bf6d3eafe (patch) | |
tree | cebcddd0d555ffda66045ee6ebefd75095316343 | |
parent | b4e5432ff032c7d05c82ad2871e27f990493d6b7 (diff) | |
parent | 6d20006f7e8dbc26cf07bf8a945bc6972642c303 (diff) | |
download | libgit2-f890a84fe00091ac4b9430c131e25d5bf6d3eafe.tar.gz |
Merge pull request #2682 from libgit2/cmn/fetch-tags-refspec
remote: check for the validity of the refspec when updating FETCH_HEAD
-rw-r--r-- | src/remote.c | 1 | ||||
-rw-r--r-- | tests/network/remote/remotes.c | 27 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/remote.c b/src/remote.c index c98c160ee..0007c41db 100644 --- a/src/remote.c +++ b/src/remote.c @@ -964,6 +964,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) diff --git a/tests/network/remote/remotes.c b/tests/network/remote/remotes.c index 543a3a31b..2cdf9226e 100644 --- a/tests/network/remote/remotes.c +++ b/tests/network/remote/remotes.c @@ -246,6 +246,33 @@ void test_network_remote_remotes__missing_refspecs(void) git_config_free(cfg); } +void test_network_remote_remotes__nonmatch_upstream_refspec(void) +{ + git_config *config; + git_remote *remote; + char *specstr[] = { + "refs/tags/*:refs/tags/*", + }; + git_strarray specs = { + specstr, + 1, + }; + + cl_git_pass(git_remote_create(&remote, _repo, "taggy", git_repository_path(_repo))); + + /* + * Set the current branch's upstream remote to a dummy ref so we call into the code + * which tries to check for the current branch's upstream in the refspecs + */ + cl_git_pass(git_repository_config(&config, _repo)); + cl_git_pass(git_config_set_string(config, "branch.master.remote", "taggy")); + cl_git_pass(git_config_set_string(config, "branch.master.merge", "refs/heads/foo")); + + cl_git_pass(git_remote_fetch(remote, &specs, NULL, NULL)); + + git_remote_free(remote); +} + void test_network_remote_remotes__list(void) { git_strarray list; |