summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-05-14 09:33:54 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2015-05-17 15:45:37 +0200
commit7b5ce2e5c43db345590c8702b669325df59c8524 (patch)
tree7bdb60c732a86d46930864917307abef0f52ea53
parent9663d1bd8b99dded448ad013898e082a73cdce57 (diff)
downloadlibgit2-7b5ce2e5c43db345590c8702b669325df59c8524.tar.gz
clone: don't rely on auto-saving for single-branch
The code used to rely on the clone code calling the remote's save, which does not happen anymore, meaning that the configuration settings the remote expected were not being written to disk. The run-time configuration was still being affected, so the right branch was being cloned. The tests continued to pass as we did not check for the configuration entires. Fix this by creating the remote with the single-branch refspec we want and checking for its existence in the configuration.
-rw-r--r--tests/online/remotes.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/tests/online/remotes.c b/tests/online/remotes.c
index 70374be2f..a86f2d9ae 100644
--- a/tests/online/remotes.c
+++ b/tests/online/remotes.c
@@ -1,19 +1,12 @@
#include "clar_libgit2.h"
+static const char *refspec = "refs/heads/first-merge:refs/remotes/origin/first-merge";
+
static int remote_single_branch(git_remote **out, git_repository *repo, const char *name, const char *url, void *payload)
{
- char *fetch_refspecs[] = {
- "refs/heads/first-merge:refs/remotes/origin/first-merge",
- };
- git_strarray fetch_refspecs_strarray = {
- fetch_refspecs,
- 1,
- };
-
GIT_UNUSED(payload);
- cl_git_pass(git_remote_create(out, repo, name, url));
- cl_git_pass(git_remote_set_fetch_refspecs(*out, &fetch_refspecs_strarray));
+ cl_git_pass(git_remote_create_with_fetchspec(out, repo, name, url, refspec));
return 0;
}
@@ -22,6 +15,7 @@ void test_online_remotes__single_branch(void)
{
git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
git_repository *repo;
+ git_remote *remote;
git_strarray refs;
size_t i, count = 0;
@@ -38,6 +32,15 @@ void test_online_remotes__single_branch(void)
cl_assert_equal_i(1, count);
git_strarray_free(&refs);
+
+ cl_git_pass(git_remote_lookup(&remote, repo, "origin"));
+ cl_git_pass(git_remote_get_fetch_refspecs(&refs, remote));
+
+ cl_assert_equal_i(1, refs.count);
+ cl_assert_equal_s(refspec, refs.strings[0]);
+
+ git_strarray_free(&refs);
+ git_remote_free(remote);
git_repository_free(repo);
}