diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-06-04 17:31:42 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-06-04 17:31:42 +0200 |
commit | 57cb1179e5c9c8f5c27c9115f13f1cae5d0f87a0 (patch) | |
tree | 67871086b1437dcd410979b423cd3ba140ab9257 /tests/network/remote/remotes.c | |
parent | 90befde4a1938641dfdb9a7bdb9f361d1de5c26f (diff) | |
download | libgit2-cmn/config-default-snapshot.tar.gz |
Make the default repository config getter return a snapshotcmn/config-default-snapshot
You should always use a snapshot, with the sole exception of writing to
the configuration.
Any reads that are not against a snapshot have race conditions, both in
terms of returned values as well as dangling pointers.
Diffstat (limited to 'tests/network/remote/remotes.c')
-rw-r--r-- | tests/network/remote/remotes.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/tests/network/remote/remotes.c b/tests/network/remote/remotes.c index 333b52a5b..0a441532d 100644 --- a/tests/network/remote/remotes.c +++ b/tests/network/remote/remotes.c @@ -262,7 +262,7 @@ void test_network_remote_remotes__missing_refspecs(void) git_remote_free(_remote); _remote = NULL; - cl_git_pass(git_repository_config(&cfg, _repo)); + cl_git_pass(git_repository_config_writable(&cfg, _repo)); cl_git_pass(git_config_set_string(cfg, "remote.specless.url", "http://example.com")); cl_git_pass(git_remote_load(&_remote, _repo, "specless")); @@ -278,7 +278,7 @@ void test_network_remote_remotes__list(void) cl_assert(list.count == 5); git_strarray_free(&list); - cl_git_pass(git_repository_config(&cfg, _repo)); + cl_git_pass(git_repository_config_writable(&cfg, _repo)); /* Create a new remote */ cl_git_pass(git_config_set_string(cfg, "remote.specless.url", "http://example.com")); @@ -380,22 +380,27 @@ 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_repository_config(&cfg, _repo)); cl_git_pass(git_config_get_string(&opt, cfg, "remote.test.tagopt")); cl_assert_equal_s("--tags", opt); + git_config_free(cfg); git_remote_set_autotag(_remote, GIT_REMOTE_DOWNLOAD_TAGS_NONE); cl_git_pass(git_remote_save(_remote)); + + cl_git_pass(git_repository_config(&cfg, _repo)); cl_git_pass(git_config_get_string(&opt, cfg, "remote.test.tagopt")); cl_assert_equal_s("--no-tags", opt); + git_config_free(cfg); 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); + cl_git_pass(git_repository_config(&cfg, _repo)); + cl_assert(git_config_get_string(&opt, cfg, "remote.test.tagopt") == GIT_ENOTFOUND); git_config_free(cfg); } |