diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-07-04 09:03:33 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-09-30 15:43:24 +0200 |
commit | c5837cad85c2730d30cd3c8b1018bd392ca8115a (patch) | |
tree | 52c0d3d9d80e213556020313a6409bffc6ede7a4 /tests | |
parent | 2cdd5c5752f1dea43cd31be9b75be7f7f5e4eab1 (diff) | |
download | libgit2-cmn/remote-fetch-refs.tar.gz |
remote: implement opportunistic remote-tracking branch updatescmn/remote-fetch-refs
When a list of refspecs is passed to fetch (what git would consider
refspec passed on the command-line), we not only need to perform the
updates described in that refspec, but also update the remote-tracking
branch of the fetched remote heads according to the remote's configured
refspecs.
These "fetches" are not however to be written to FETCH_HEAD as they
would be duplicate data, and it's not what the user asked for.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/network/remote/local.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/network/remote/local.c b/tests/network/remote/local.c index ceccf45d0..c6c9e4ca9 100644 --- a/tests/network/remote/local.c +++ b/tests/network/remote/local.c @@ -408,3 +408,24 @@ void test_network_remote_local__fetch_default_reflog_message(void) git_reflog_free(log); git_signature_free(sig); } + +void test_network_remote_local__opportunistic_update(void) +{ + git_reference *ref; + char *refspec_strings[] = { + "master", + }; + git_strarray array = { + refspec_strings, + 1, + }; + + /* this remote has a passive refspec of "refs/heads/<star>:refs/remotes/origin/<star>" */ + cl_git_pass(git_remote_create(&remote, repo, "origin", cl_git_fixture_url("testrepo.git"))); + /* and we pass the active refspec "master" */ + cl_git_pass(git_remote_fetch(remote, &array, NULL, NULL)); + + /* and we expect that to update our copy of origin's master */ + cl_git_pass(git_reference_lookup(&ref, repo, "refs/remotes/origin/master")); + git_reference_free(ref); +} |