#include "clar_libgit2.h"
-#include "fileops.h"
+#include "futils.h"
#include "sysdir.h"
-#include "path.h"
#ifdef GIT_WIN32
#define NUM_VARS 5
void test_core_env__0(void)
{
- git_buf path = GIT_BUF_INIT, found = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT, found = GIT_STR_INIT;
char testfile[16], tidx = '0';
char **val;
const char *testname = "testfile";
continue;
}
- cl_git_pass(git_path_prettify(&path, *val, NULL));
+ cl_git_pass(git_fs_path_prettify(&path, *val, NULL));
/* vary testfile name in each directory so accidentally leaving
* an environment variable set from a previous iteration won't
* accidentally make this test pass...
*/
testfile[testlen] = tidx++;
- cl_git_pass(git_buf_joinpath(&path, path.ptr, testfile));
+ cl_git_pass(git_str_joinpath(&path, path.ptr, testfile));
cl_git_mkfile(path.ptr, "find me");
- git_buf_rtruncate_at_char(&path, '/');
+ git_str_rtruncate_at_char(&path, '/');
cl_assert_equal_i(
GIT_ENOTFOUND, git_sysdir_find_global_file(&found, testfile));
cl_git_pass(git_sysdir_find_global_file(&found, testfile));
{
- int root = git_path_root(path.ptr);
+ int root = git_fs_path_root(path.ptr);
char old;
if (root >= 0) {
(void)p_rmdir(*val);
}
- git_buf_free(&path);
- git_buf_free(&found);
+ git_str_dispose(&path);
+ git_str_dispose(&found);
}
void test_core_env__1(void)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
cl_assert_equal_i(
GIT_ENOTFOUND, git_sysdir_find_global_file(&path, "nonexistentfile"));
GIT_ENOTFOUND, git_sysdir_find_system_file(&path, "nonexistentfile"));
#endif
- git_buf_free(&path);
+ git_str_dispose(&path);
}
static void check_global_searchpath(
- const char *path, int position, const char *file, git_buf *temp)
+ const char *path, int position, const char *file, git_str *temp)
{
- git_buf out = GIT_BUF_INIT;
+ git_str out = GIT_STR_INIT;
/* build and set new path */
if (position < 0)
- cl_git_pass(git_buf_join(temp, GIT_PATH_LIST_SEPARATOR, path, "$PATH"));
+ cl_git_pass(git_str_join(temp, GIT_PATH_LIST_SEPARATOR, path, "$PATH"));
else if (position > 0)
- cl_git_pass(git_buf_join(temp, GIT_PATH_LIST_SEPARATOR, "$PATH", path));
+ cl_git_pass(git_str_join(temp, GIT_PATH_LIST_SEPARATOR, "$PATH", path));
else
- cl_git_pass(git_buf_sets(temp, path));
+ cl_git_pass(git_str_sets(temp, path));
cl_git_pass(git_libgit2_opts(
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, temp->ptr));
cl_assert_equal_i(
GIT_ENOTFOUND, git_sysdir_find_global_file(temp, file));
- git_buf_free(&out);
+ git_str_dispose(&out);
}
void test_core_env__2(void)
{
- git_buf path = GIT_BUF_INIT, found = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT, found = GIT_STR_INIT;
char testfile[16], tidx = '0';
char **val;
const char *testname = "alternate";
continue;
}
- cl_git_pass(git_path_prettify(&path, *val, NULL));
+ cl_git_pass(git_fs_path_prettify(&path, *val, NULL));
/* vary testfile name so any sloppiness is resetting variables or
* deleting files won't accidentally make a test pass.
*/
testfile[testlen] = tidx++;
- cl_git_pass(git_buf_joinpath(&path, path.ptr, testfile));
+ cl_git_pass(git_str_joinpath(&path, path.ptr, testfile));
cl_git_mkfile(path.ptr, "find me");
- git_buf_rtruncate_at_char(&path, '/');
+ git_str_rtruncate_at_char(&path, '/');
/* default should be NOTFOUND */
cl_assert_equal_i(
check_global_searchpath(path.ptr, 1, testfile, &found);
/* cleanup */
- cl_git_pass(git_buf_joinpath(&path, path.ptr, testfile));
+ cl_git_pass(git_str_joinpath(&path, path.ptr, testfile));
(void)p_unlink(path.ptr);
(void)p_rmdir(*val);
}
- git_buf_free(&path);
- git_buf_free(&found);
+ git_str_dispose(&path);
+ git_str_dispose(&found);
}
void test_core_env__substitution(void)
{
- git_buf buf = GIT_BUF_INIT, expected = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT, expected = GIT_STR_INIT;
/* Set it to something non-default so we have controllable values */
cl_git_pass(git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, "/tmp/a"));
cl_git_pass(git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, &buf));
cl_assert_equal_s("/tmp/a", buf.ptr);
- git_buf_clear(&buf);
- cl_git_pass(git_buf_join(&buf, GIT_PATH_LIST_SEPARATOR, "$PATH", "/tmp/b"));
+ git_str_clear(&buf);
+ cl_git_pass(git_str_join(&buf, GIT_PATH_LIST_SEPARATOR, "$PATH", "/tmp/b"));
cl_git_pass(git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, buf.ptr));
cl_git_pass(git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, &buf));
- cl_git_pass(git_buf_join(&expected, GIT_PATH_LIST_SEPARATOR, "/tmp/a", "/tmp/b"));
+ cl_git_pass(git_str_join(&expected, GIT_PATH_LIST_SEPARATOR, "/tmp/a", "/tmp/b"));
cl_assert_equal_s(expected.ptr, buf.ptr);
- git_buf_free(&expected);
- git_buf_free(&buf);
+ git_str_dispose(&expected);
+ git_str_dispose(&buf);
}