diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-11-02 20:03:23 +0100 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-11-02 20:03:23 +0100 |
commit | 0f838d27f19f611651df1a4a031196815ebe70cb (patch) | |
tree | f2881c17f59e056a00ba2b3d5f95ad95e03c1081 | |
parent | 521c0cab7a02f718e4a7e3c2ae7ef81d6f16ffd1 (diff) | |
download | libgit2-0f838d27f19f611651df1a4a031196815ebe70cb.tar.gz |
remote: add a failing test for checking the current branch's upstream
When we update FETCH_HEAD we check whether the remote is the current
branch's upstream remote. The code does not check whether the current
refspec is relevant for this reference but always tries to perform the
reverse transformation, which causes it to error out if the refspec
doesn't match the reference.
Thanks to Pierre-Olivier Latour for the reproduction recipe.
-rw-r--r-- | tests/network/remote/remotes.c | 27 |
1 files changed, 27 insertions, 0 deletions
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; |