summaryrefslogtreecommitdiff
path: root/tests/network
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-12-21 15:31:03 +0000
committerCarlos Martín Nieto <cmn@dwim.me>2015-03-03 18:35:12 +0100
commit9a97f49e3aa15edc479fc590f4b28fc44c155c40 (patch)
treeb85de2d396b9d0d408f688212c0cdc74347ea7b3 /tests/network
parent76f034180aee96fcc1fffd5267ccbc6ada68482a (diff)
downloadlibgit2-9a97f49e3aa15edc479fc590f4b28fc44c155c40.tar.gz
config: borrow refcounted referencescmn/config-borrow-entry
This changes the get_entry() method to return a refcounted version of the config entry, which you have to free when you're done. This allows us to avoid freeing the memory in which the entry is stored on a refresh, which may happen at any time for a live config. For this reason, get_string() has been forbidden on live configs and a new function get_string_buf() has been added, which stores the string in a git_buf which the user then owns. The functions which parse the string value takea advantage of the borrowing to parse safely and then release the entry.
Diffstat (limited to 'tests/network')
-rw-r--r--tests/network/remote/remotes.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/tests/network/remote/remotes.c b/tests/network/remote/remotes.c
index 2ae6886bd..e750f7b1e 100644
--- a/tests/network/remote/remotes.c
+++ b/tests/network/remote/remotes.c
@@ -1,4 +1,5 @@
#include "clar_libgit2.h"
+#include "config/config_helpers.h"
#include "buffer.h"
#include "refspec.h"
#include "remote.h"
@@ -385,26 +386,17 @@ void test_network_remote_remotes__cannot_add_a_remote_with_an_invalid_name(void)
void test_network_remote_remotes__tagopt(void)
{
- const char *opt;
- git_config *cfg;
-
- cl_git_pass(git_repository_config(&cfg, _repo));
-
git_remote_set_autotag(_remote, GIT_REMOTE_DOWNLOAD_TAGS_ALL);
cl_git_pass(git_remote_save(_remote));
- cl_git_pass(git_config_get_string(&opt, cfg, "remote.test.tagopt"));
- cl_assert_equal_s("--tags", opt);
+ assert_config_entry_value(_repo, "remote.test.tagopt", "--tags");
git_remote_set_autotag(_remote, GIT_REMOTE_DOWNLOAD_TAGS_NONE);
cl_git_pass(git_remote_save(_remote));
- cl_git_pass(git_config_get_string(&opt, cfg, "remote.test.tagopt"));
- cl_assert_equal_s("--no-tags", opt);
+ assert_config_entry_value(_repo, "remote.test.tagopt", "--no-tags");
git_remote_set_autotag(_remote, GIT_REMOTE_DOWNLOAD_TAGS_AUTO);
cl_git_pass(git_remote_save(_remote));
- cl_assert(git_config_get_string(&opt, cfg, "remote.test.tagopt") == GIT_ENOTFOUND);
-
- git_config_free(cfg);
+ assert_config_entry_existence(_repo, "remote.test.tagopt", false);
}
void test_network_remote_remotes__can_load_with_an_empty_url(void)