summaryrefslogtreecommitdiff
path: root/tests/online/clone.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2021-09-07 17:53:49 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2021-10-17 09:49:01 -0400
commitf0e693b18afbe1de37d7da5b5a8967b6c87d8e53 (patch)
treebe5e1cdbfa218ba81ec06bf45e45cfeb7f79a2a5 /tests/online/clone.c
parent5346be3ddd3bcf19779c5d62e71f8442a0171133 (diff)
downloadlibgit2-ethomson/gitstr.tar.gz
str: introduce `git_str` for internal, `git_buf` is externalethomson/gitstr
libgit2 has two distinct requirements that were previously solved by `git_buf`. We require: 1. A general purpose string class that provides a number of utility APIs for manipulating data (eg, concatenating, truncating, etc). 2. A structure that we can use to return strings to callers that they can take ownership of. By using a single class (`git_buf`) for both of these purposes, we have confused the API to the point that refactorings are difficult and reasoning about correctness is also difficult. Move the utility class `git_buf` to be called `git_str`: this represents its general purpose, as an internal string buffer class. The name also is an homage to Junio Hamano ("gitstr"). The public API remains `git_buf`, and has a much smaller footprint. It is generally only used as an "out" param with strict requirements that follow the documentation. (Exceptions exist for some legacy APIs to avoid breaking callers unnecessarily.) Utility functions exist to convert a user-specified `git_buf` to a `git_str` so that we can call internal functions, then converting it back again.
Diffstat (limited to 'tests/online/clone.c')
-rw-r--r--tests/online/clone.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/tests/online/clone.c b/tests/online/clone.c
index 7d43c6a09..c55cf9f95 100644
--- a/tests/online/clone.c
+++ b/tests/online/clone.c
@@ -180,7 +180,7 @@ static int fetch_progress(const git_indexer_progress *stats, void *payload)
void test_online_clone__can_checkout_a_cloned_repo(void)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
git_reference *head, *remote_head;
bool checkout_progress_cb_was_called = false,
fetch_progress_cb_was_called = false;
@@ -193,8 +193,8 @@ void test_online_clone__can_checkout_a_cloned_repo(void)
cl_git_pass(git_clone(&g_repo, LIVE_REPO_URL, "./foo", &g_options));
- cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_repo), "master.txt"));
- cl_assert_equal_i(true, git_path_isfile(git_buf_cstr(&path)));
+ cl_git_pass(git_str_joinpath(&path, git_repository_workdir(g_repo), "master.txt"));
+ cl_assert_equal_i(true, git_path_isfile(git_str_cstr(&path)));
cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD"));
cl_assert_equal_i(GIT_REFERENCE_SYMBOLIC, git_reference_type(head));
@@ -209,7 +209,7 @@ void test_online_clone__can_checkout_a_cloned_repo(void)
git_reference_free(remote_head);
git_reference_free(head);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
static int remote_mirror_cb(git_remote **out, git_repository *repo,
@@ -406,16 +406,16 @@ void test_online_clone__credentials(void)
void test_online_clone__credentials_via_custom_headers(void)
{
const char *creds = "libgit3:libgit3";
- git_buf auth = GIT_BUF_INIT;
+ git_str auth = GIT_STR_INIT;
- cl_git_pass(git_buf_puts(&auth, "Authorization: Basic "));
- cl_git_pass(git_buf_encode_base64(&auth, creds, strlen(creds)));
+ cl_git_pass(git_str_puts(&auth, "Authorization: Basic "));
+ cl_git_pass(git_str_encode_base64(&auth, creds, strlen(creds)));
g_options.fetch_opts.custom_headers.count = 1;
g_options.fetch_opts.custom_headers.strings = &auth.ptr;
cl_git_pass(git_clone(&g_repo, "https://bitbucket.org/libgit2/testgitrepository.git", "./foo", &g_options));
- git_buf_dispose(&auth);
+ git_str_dispose(&auth);
}
void test_online_clone__bitbucket_style(void)
@@ -807,12 +807,12 @@ static int proxy_cert_cb(git_cert *cert, int valid, const char *host, void *payl
void test_online_clone__proxy_credentials_request(void)
{
- git_buf url = GIT_BUF_INIT;
+ git_str url = GIT_STR_INIT;
if (!_remote_proxy_host || !_remote_proxy_user || !_remote_proxy_pass)
cl_skip();
- cl_git_pass(git_buf_printf(&url, "%s://%s/",
+ cl_git_pass(git_str_printf(&url, "%s://%s/",
_remote_proxy_scheme ? _remote_proxy_scheme : "http",
_remote_proxy_host));
@@ -824,17 +824,17 @@ void test_online_clone__proxy_credentials_request(void)
cl_git_pass(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
cl_assert(called_proxy_creds);
- git_buf_dispose(&url);
+ git_str_dispose(&url);
}
void test_online_clone__proxy_credentials_in_url(void)
{
- git_buf url = GIT_BUF_INIT;
+ git_str url = GIT_STR_INIT;
if (!_remote_proxy_host || !_remote_proxy_user || !_remote_proxy_pass)
cl_skip();
- cl_git_pass(git_buf_printf(&url, "%s://%s:%s@%s/",
+ cl_git_pass(git_str_printf(&url, "%s://%s:%s@%s/",
_remote_proxy_scheme ? _remote_proxy_scheme : "http",
_remote_proxy_user, _remote_proxy_pass, _remote_proxy_host));
@@ -845,12 +845,12 @@ void test_online_clone__proxy_credentials_in_url(void)
cl_git_pass(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
cl_assert(called_proxy_creds == 0);
- git_buf_dispose(&url);
+ git_str_dispose(&url);
}
void test_online_clone__proxy_credentials_in_environment(void)
{
- git_buf url = GIT_BUF_INIT;
+ git_str url = GIT_STR_INIT;
if (!_remote_proxy_host || !_remote_proxy_user || !_remote_proxy_pass)
cl_skip();
@@ -863,7 +863,7 @@ void test_online_clone__proxy_credentials_in_environment(void)
g_options.fetch_opts.proxy_opts.type = GIT_PROXY_AUTO;
g_options.fetch_opts.proxy_opts.certificate_check = proxy_cert_cb;
- cl_git_pass(git_buf_printf(&url, "%s://%s:%s@%s/",
+ cl_git_pass(git_str_printf(&url, "%s://%s:%s@%s/",
_remote_proxy_scheme ? _remote_proxy_scheme : "http",
_remote_proxy_user, _remote_proxy_pass, _remote_proxy_host));
@@ -873,17 +873,17 @@ void test_online_clone__proxy_credentials_in_environment(void)
cl_git_pass(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
- git_buf_dispose(&url);
+ git_str_dispose(&url);
}
void test_online_clone__proxy_credentials_in_url_https(void)
{
- git_buf url = GIT_BUF_INIT;
+ git_str url = GIT_STR_INIT;
if (!_remote_proxy_host || !_remote_proxy_user || !_remote_proxy_pass)
cl_skip();
- cl_git_pass(git_buf_printf(&url, "%s://%s:%s@%s/",
+ cl_git_pass(git_str_printf(&url, "%s://%s:%s@%s/",
_remote_proxy_scheme ? _remote_proxy_scheme : "http",
_remote_proxy_user, _remote_proxy_pass, _remote_proxy_host));
@@ -895,7 +895,7 @@ void test_online_clone__proxy_credentials_in_url_https(void)
cl_git_pass(git_clone(&g_repo, "https://github.com/libgit2/TestGitRepository", "./foo", &g_options));
cl_assert(called_proxy_creds == 0);
- git_buf_dispose(&url);
+ git_str_dispose(&url);
}
void test_online_clone__proxy_auto_not_detected(void)
@@ -907,12 +907,12 @@ void test_online_clone__proxy_auto_not_detected(void)
void test_online_clone__proxy_cred_callback_after_failed_url_creds(void)
{
- git_buf url = GIT_BUF_INIT;
+ git_str url = GIT_STR_INIT;
if (!_remote_proxy_host || !_remote_proxy_user || !_remote_proxy_pass)
cl_skip();
- cl_git_pass(git_buf_printf(&url, "%s://invalid_user_name:INVALID_pass_WORD@%s/",
+ cl_git_pass(git_str_printf(&url, "%s://invalid_user_name:INVALID_pass_WORD@%s/",
_remote_proxy_scheme ? _remote_proxy_scheme : "http",
_remote_proxy_host));
@@ -924,7 +924,7 @@ void test_online_clone__proxy_cred_callback_after_failed_url_creds(void)
cl_git_pass(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
cl_assert(called_proxy_creds);
- git_buf_dispose(&url);
+ git_str_dispose(&url);
}
void test_online_clone__azurerepos(void)