summaryrefslogtreecommitdiff
path: root/tests-clay
diff options
context:
space:
mode:
Diffstat (limited to 'tests-clay')
-rw-r--r--tests-clay/clay.h1
-rw-r--r--tests-clay/clay_libgit2.h9
-rw-r--r--tests-clay/clay_main.c7
-rw-r--r--tests-clay/core/buffer.c54
-rw-r--r--tests-clay/core/dirent.c48
-rw-r--r--tests-clay/core/path.c133
-rw-r--r--tests-clay/core/rmdir.c34
-rw-r--r--tests-clay/repo/init.c10
-rw-r--r--tests-clay/repo/open.c17
9 files changed, 226 insertions, 87 deletions
diff --git a/tests-clay/clay.h b/tests-clay/clay.h
index b3aae467c..608980d44 100644
--- a/tests-clay/clay.h
+++ b/tests-clay/clay.h
@@ -111,6 +111,7 @@ extern void test_core_path__1(void);
extern void test_core_path__2(void);
extern void test_core_path__5(void);
extern void test_core_path__6(void);
+extern void test_core_path__7(void);
extern void test_core_rmdir__delete_recursive(void);
extern void test_core_rmdir__fail_to_delete_non_empty_dir(void);
extern void test_core_rmdir__initialize(void);
diff --git a/tests-clay/clay_libgit2.h b/tests-clay/clay_libgit2.h
index 6b14b7d6e..d0faf9a90 100644
--- a/tests-clay/clay_libgit2.h
+++ b/tests-clay/clay_libgit2.h
@@ -42,4 +42,13 @@ GIT_INLINE(void) cl_assert_strequal_internal(
}
}
+/*
+ * Some utility macros for building long strings
+ */
+#define REP4(STR) STR STR STR STR
+#define REP15(STR) REP4(STR) REP4(STR) REP4(STR) STR STR STR
+#define REP16(STR) REP4(REP4(STR))
+#define REP256(STR) REP16(REP16(STR))
+#define REP1024(STR) REP4(REP256(STR))
+
#endif
diff --git a/tests-clay/clay_main.c b/tests-clay/clay_main.c
index 409ce7643..f0ec50966 100644
--- a/tests-clay/clay_main.c
+++ b/tests-clay/clay_main.c
@@ -171,7 +171,8 @@ static const struct clay_func _clay_cb_core_path[] = {
{"1", &test_core_path__1},
{"2", &test_core_path__2},
{"5", &test_core_path__5},
- {"6", &test_core_path__6}
+ {"6", &test_core_path__6},
+ {"7", &test_core_path__7}
};
static const struct clay_func _clay_cb_core_rmdir[] = {
{"delete_recursive", &test_core_rmdir__delete_recursive},
@@ -351,7 +352,7 @@ static const struct clay_suite _clay_suites[] = {
"core::path",
{NULL, NULL},
{NULL, NULL},
- _clay_cb_core_path, 5
+ _clay_cb_core_path, 6
},
{
"core::rmdir",
@@ -494,7 +495,7 @@ static const struct clay_suite _clay_suites[] = {
};
static size_t _clay_suite_count = 34;
-static size_t _clay_callback_count = 113;
+static size_t _clay_callback_count = 114;
/* Core test functions */
static void
diff --git a/tests-clay/core/buffer.c b/tests-clay/core/buffer.c
index 7d25b8179..2f376c50a 100644
--- a/tests-clay/core/buffer.c
+++ b/tests-clay/core/buffer.c
@@ -5,9 +5,6 @@
const char *test_string = TESTSTR;
const char *test_string_x2 = TESTSTR TESTSTR;
-#define REP4(STR) STR STR STR STR
-#define REP16(STR) REP4(REP4(STR))
-#define REP1024(STR) REP16(REP16(REP4(STR)))
#define TESTSTR_4096 REP1024("1234")
#define TESTSTR_8192 REP1024("12341234")
const char *test_4096 = TESTSTR_4096;
@@ -52,7 +49,7 @@ void test_core_buffer__2(void)
{
git_buf buf = GIT_BUF_INIT;
int i;
- char data[100];
+ char data[128];
cl_assert(buf.size == 0);
@@ -135,22 +132,28 @@ void test_core_buffer__2(void)
git_buf_puts(&buf, REP4("0123456789"));
cl_assert(git_buf_oom(&buf) == 0);
- git_buf_copy_cstr(data, 100, &buf);
- cl_assert_strequal(data, REP4("0123456789"));
+ git_buf_copy_cstr(data, sizeof(data), &buf);
+ cl_assert_strequal(REP4("0123456789"), data);
git_buf_copy_cstr(data, 11, &buf);
- cl_assert_strequal(data, "0123456789");
+ cl_assert_strequal("0123456789", data);
git_buf_copy_cstr(data, 3, &buf);
- cl_assert_strequal(data, "01");
+ cl_assert_strequal("01", data);
git_buf_copy_cstr(data, 1, &buf);
- cl_assert_strequal(data, "");
+ cl_assert_strequal("", data);
- git_buf_copy_cstr(data, 100, &buf);
- cl_assert_strequal(data, REP4("0123456789"));
+ git_buf_copy_cstr(data, sizeof(data), &buf);
+ cl_assert_strequal(REP4("0123456789"), data);
+
+ git_buf_sets(&buf, REP256("x"));
+ git_buf_copy_cstr(data, sizeof(data), &buf);
+ /* since sizeof(data) == 128, only 127 bytes should be copied */
+ cl_assert_strequal(REP4(REP16("x")) REP16("x") REP16("x")
+ REP16("x") "xxxxxxxxxxxxxxx", data);
git_buf_free(&buf);
- git_buf_copy_cstr(data, 100, &buf);
- cl_assert_strequal(data, "");
+ git_buf_copy_cstr(data, sizeof(data), &buf);
+ cl_assert_strequal("", data);
}
/* let's do some tests with larger buffers to push our limits */
@@ -340,9 +343,10 @@ void test_core_buffer__6(void)
}
-/* test take cstr data */
+/* test detach/attach data */
void test_core_buffer__7(void)
{
+ const char *fun = "This is fun";
git_buf a = GIT_BUF_INIT;
char *b = NULL;
@@ -350,18 +354,36 @@ void test_core_buffer__7(void)
cl_assert(git_buf_oom(&a) == 0);
cl_assert_strequal("foo", git_buf_cstr(&a));
- b = git_buf_take_cstr(&a);
+ b = git_buf_detach(&a);
cl_assert_strequal("foo", b);
cl_assert_strequal("", a.ptr);
git__free(b);
- b = git_buf_take_cstr(&a);
+ b = git_buf_detach(&a);
cl_assert_strequal(NULL, b);
cl_assert_strequal("", a.ptr);
git_buf_free(&a);
+
+ b = git__strdup(fun);
+ git_buf_attach(&a, b, 0);
+
+ cl_assert_strequal(fun, a.ptr);
+ cl_assert(a.size == (ssize_t)strlen(fun));
+ cl_assert(a.asize == (ssize_t)strlen(fun) + 1);
+
+ git_buf_free(&a);
+
+ b = git__strdup(fun);
+ git_buf_attach(&a, b, strlen(fun) + 1);
+
+ cl_assert_strequal(fun, a.ptr);
+ cl_assert(a.size == (ssize_t)strlen(fun));
+ cl_assert(a.asize == (ssize_t)strlen(fun) + 1);
+
+ git_buf_free(&a);
}
diff --git a/tests-clay/core/dirent.c b/tests-clay/core/dirent.c
index 105e8d8f0..4f55368ac 100644
--- a/tests-clay/core/dirent.c
+++ b/tests-clay/core/dirent.c
@@ -9,10 +9,10 @@ typedef struct name_data {
typedef struct walk_data {
char *sub; /* sub-directory name */
name_data *names; /* name state data */
+ git_buf path;
} walk_data;
-static char path_buffer[GIT_PATH_MAX];
static char *top_dir = "dir-walk";
static walk_data *state_loc;
@@ -27,7 +27,8 @@ static void setup(walk_data *d)
if (strcmp(d->sub, ".") != 0)
cl_must_pass(p_mkdir(d->sub, 0777));
- strcpy(path_buffer, d->sub);
+ cl_git_pass(git_buf_sets(&d->path, d->sub));
+
state_loc = d;
for (n = d->names; n->name; n++) {
@@ -53,6 +54,8 @@ static void dirent_cleanup__cb(void *_d)
cl_must_pass(p_chdir(".."));
cl_must_pass(p_rmdir(top_dir));
+
+ git_buf_free(&d->path);
}
static void check_counts(walk_data *d)
@@ -64,7 +67,7 @@ static void check_counts(walk_data *d)
}
}
-static int one_entry(void *state, char *path)
+static int one_entry(void *state, git_buf *path)
{
walk_data *d = (walk_data *) state;
name_data *n;
@@ -72,11 +75,11 @@ static int one_entry(void *state, char *path)
if (state != state_loc)
return GIT_ERROR;
- if (path != path_buffer)
+ if (path != &d->path)
return GIT_ERROR;
for (n = d->names; n->name; n++) {
- if (!strcmp(n->name, path)) {
+ if (!strcmp(n->name, path->ptr)) {
n->count++;
return 0;
}
@@ -85,7 +88,7 @@ static int one_entry(void *state, char *path)
return GIT_ERROR;
}
-static int dont_call_me(void *GIT_UNUSED(state), char *GIT_UNUSED(path))
+static int dont_call_me(void *GIT_UNUSED(state), git_buf *GIT_UNUSED(path))
{
GIT_UNUSED_ARG(state)
GIT_UNUSED_ARG(path)
@@ -102,7 +105,8 @@ static name_data dot_names[] = {
};
static walk_data dot = {
".",
- dot_names
+ dot_names,
+ GIT_BUF_INIT
};
/* make sure that the '.' folder is not traversed */
@@ -111,8 +115,7 @@ void test_core_dirent__dont_traverse_dot(void)
cl_set_cleanup(&dirent_cleanup__cb, &dot);
setup(&dot);
- cl_git_pass(git_futils_direach(path_buffer,
- sizeof(path_buffer),
+ cl_git_pass(git_futils_direach(&dot.path,
one_entry,
&dot));
@@ -128,7 +131,8 @@ static name_data sub_names[] = {
};
static walk_data sub = {
"sub",
- sub_names
+ sub_names,
+ GIT_BUF_INIT
};
/* traverse a subfolder */
@@ -137,8 +141,7 @@ void test_core_dirent__traverse_subfolder(void)
cl_set_cleanup(&dirent_cleanup__cb, &sub);
setup(&sub);
- cl_git_pass(git_futils_direach(path_buffer,
- sizeof(path_buffer),
+ cl_git_pass(git_futils_direach(&sub.path,
one_entry,
&sub));
@@ -148,7 +151,8 @@ void test_core_dirent__traverse_subfolder(void)
static walk_data sub_slash = {
"sub/",
- sub_names
+ sub_names,
+ GIT_BUF_INIT
};
/* traverse a slash-terminated subfolder */
@@ -157,8 +161,7 @@ void test_core_dirent__traverse_slash_terminated_folder(void)
cl_set_cleanup(&dirent_cleanup__cb, &sub_slash);
setup(&sub_slash);
- cl_git_pass(git_futils_direach(path_buffer,
- sizeof(path_buffer),
+ cl_git_pass(git_futils_direach(&sub_slash.path,
one_entry,
&sub_slash));
@@ -171,7 +174,8 @@ static name_data empty_names[] = {
};
static walk_data empty = {
"empty",
- empty_names
+ empty_names,
+ GIT_BUF_INIT
};
/* make sure that empty folders are not traversed */
@@ -180,16 +184,14 @@ void test_core_dirent__dont_traverse_empty_folders(void)
cl_set_cleanup(&dirent_cleanup__cb, &empty);
setup(&empty);
- cl_git_pass(git_futils_direach(path_buffer,
- sizeof(path_buffer),
+ cl_git_pass(git_futils_direach(&empty.path,
one_entry,
&empty));
check_counts(&empty);
/* make sure callback not called */
- cl_git_pass(git_futils_direach(path_buffer,
- sizeof(path_buffer),
+ cl_git_pass(git_futils_direach(&empty.path,
dont_call_me,
&empty));
}
@@ -204,7 +206,8 @@ static name_data odd_names[] = {
};
static walk_data odd = {
"odd",
- odd_names
+ odd_names,
+ GIT_BUF_INIT
};
/* make sure that strange looking filenames ('..c') are traversed */
@@ -213,8 +216,7 @@ void test_core_dirent__traverse_weird_filenames(void)
cl_set_cleanup(&dirent_cleanup__cb, &odd);
setup(&odd);
- cl_git_pass(git_futils_direach(path_buffer,
- sizeof(path_buffer),
+ cl_git_pass(git_futils_direach(&odd.path,
one_entry,
&odd));
diff --git a/tests-clay/core/path.c b/tests-clay/core/path.c
index c394c7285..1a588a39f 100644
--- a/tests-clay/core/path.c
+++ b/tests-clay/core/path.c
@@ -4,26 +4,30 @@
static void
check_dirname(const char *A, const char *B)
{
- char dir[64], *dir2;
+ git_buf dir = GIT_BUF_INIT;
+ char *dir2;
- cl_assert(git_path_dirname_r(dir, sizeof(dir), A) >= 0);
- cl_assert(strcmp(dir, B) == 0);
- cl_assert((dir2 = git_path_dirname(A)) != NULL);
- cl_assert(strcmp(dir2, B) == 0);
+ cl_assert(git_path_dirname_r(&dir, A) >= 0);
+ cl_assert_strequal(B, dir.ptr);
+ git_buf_free(&dir);
+ cl_assert((dir2 = git_path_dirname(A)) != NULL);
+ cl_assert_strequal(B, dir2);
git__free(dir2);
}
static void
check_basename(const char *A, const char *B)
{
- char base[64], *base2;
+ git_buf base = GIT_BUF_INIT;
+ char *base2;
- cl_assert(git_path_basename_r(base, sizeof(base), A) >= 0);
- cl_assert(strcmp(base, B) == 0);
- cl_assert((base2 = git_path_basename(A)) != NULL);
- cl_assert(strcmp(base2, B) == 0);
+ cl_assert(git_path_basename_r(&base, A) >= 0);
+ cl_assert_strequal(B, base.ptr);
+ git_buf_free(&base);
+ cl_assert((base2 = git_path_basename(A)) != NULL);
+ cl_assert_strequal(B, base2);
git__free(base2);
}
@@ -33,16 +37,18 @@ check_topdir(const char *A, const char *B)
const char *dir;
cl_assert((dir = git_path_topdir(A)) != NULL);
- cl_assert(strcmp(dir, B) == 0);
+ cl_assert_strequal(B, dir);
}
static void
check_joinpath(const char *path_a, const char *path_b, const char *expected_path)
{
- char joined_path[GIT_PATH_MAX];
+ git_buf joined_path = GIT_BUF_INIT;
- git_path_join(joined_path, path_a, path_b);
- cl_assert(strcmp(joined_path, expected_path) == 0);
+ cl_git_pass(git_buf_joinpath(&joined_path, path_a, path_b));
+ cl_assert_strequal(expected_path, joined_path.ptr);
+
+ git_buf_free(&joined_path);
}
static void
@@ -53,17 +59,19 @@ check_joinpath_n(
const char *path_d,
const char *expected_path)
{
- char joined_path[GIT_PATH_MAX];
+ git_buf joined_path = GIT_BUF_INIT;
+
+ cl_git_pass(git_buf_join_n(&joined_path, '/', 4,
+ path_a, path_b, path_c, path_d));
+ cl_assert_strequal(expected_path, joined_path.ptr);
- git_path_join_n(joined_path, 4, path_a, path_b, path_c, path_d);
- cl_assert(strcmp(joined_path, expected_path) == 0);
+ git_buf_free(&joined_path);
}
/* get the dirname of a path */
void test_core_path__0(void)
{
-
check_dirname(NULL, ".");
check_dirname("", ".");
check_dirname("a", ".");
@@ -77,6 +85,8 @@ void test_core_path__0(void)
check_dirname("usr/lib/", "usr");
check_dirname("usr/lib//", "usr");
check_dirname(".git/", ".");
+
+ check_dirname(REP16("/abc"), REP15("/abc"));
}
/* get the base name of a path */
@@ -91,6 +101,9 @@ void test_core_path__1(void)
check_basename("/usr/lib", "lib");
check_basename("/usr/lib//", "lib");
check_basename("usr/lib", "lib");
+
+ check_basename(REP16("/abc"), "abc");
+ check_basename(REP1024("/abc"), "abc");
}
/* get the latest component in a path */
@@ -125,6 +138,20 @@ void test_core_path__5(void)
check_joinpath("/a", "/b/", "/a/b/");
check_joinpath("/a/", "b/", "/a/b/");
check_joinpath("/a/", "/b/", "/a/b/");
+
+ check_joinpath("/abcd", "/defg", "/abcd/defg");
+ check_joinpath("/abcd", "/defg/", "/abcd/defg/");
+ check_joinpath("/abcd/", "defg/", "/abcd/defg/");
+ check_joinpath("/abcd/", "/defg/", "/abcd/defg/");
+
+ check_joinpath("/abcdefgh", "/12345678", "/abcdefgh/12345678");
+ check_joinpath("/abcdefgh", "/12345678/", "/abcdefgh/12345678/");
+ check_joinpath("/abcdefgh/", "12345678/", "/abcdefgh/12345678/");
+
+ check_joinpath(REP1024("aaaa"), REP1024("bbbb"),
+ REP1024("aaaa") "/" REP1024("bbbb"));
+ check_joinpath(REP1024("/aaaa"), REP1024("/bbbb"),
+ REP1024("/aaaa") REP1024("/bbbb"));
}
/* properly join path components for more than one path */
@@ -136,4 +163,74 @@ void test_core_path__6(void)
check_joinpath_n("", "", "", "a", "a");
check_joinpath_n("a", "b", "", "/c/d/", "a/b/c/d/");
check_joinpath_n("a", "b", "", "/c/d", "a/b/c/d");
+ check_joinpath_n("abcd", "efgh", "ijkl", "mnop", "abcd/efgh/ijkl/mnop");
+ check_joinpath_n("abcd/", "efgh/", "ijkl/", "mnop/", "abcd/efgh/ijkl/mnop/");
+ check_joinpath_n("/abcd/", "/efgh/", "/ijkl/", "/mnop/", "/abcd/efgh/ijkl/mnop/");
+
+ check_joinpath_n(REP1024("a"), REP1024("b"), REP1024("c"), REP1024("d"),
+ REP1024("a") "/" REP1024("b") "/"
+ REP1024("c") "/" REP1024("d"));
+ check_joinpath_n(REP1024("/a"), REP1024("/b"), REP1024("/c"), REP1024("/d"),
+ REP1024("/a") REP1024("/b")
+ REP1024("/c") REP1024("/d"));
+}
+
+
+static void
+check_path_to_dir(
+ const char* path,
+ const char* expected)
+{
+ git_buf tgt = GIT_BUF_INIT;
+
+ git_buf_sets(&tgt, path);
+ cl_git_pass(git_path_to_dir(&tgt));
+ cl_assert_strequal(expected, tgt.ptr);
+
+ git_buf_free(&tgt);
+}
+
+static void
+check_string_to_dir(
+ const char* path,
+ int maxlen,
+ const char* expected)
+{
+ int len = strlen(path);
+ char *buf = git__malloc(len + 2);
+ strncpy(buf, path, len + 2);
+
+ git_path_string_to_dir(buf, maxlen);
+
+ cl_assert_strequal(expected, buf);
+
+ git__free(buf);
+}
+
+/* convert paths to dirs */
+void test_core_path__7(void)
+{
+ check_path_to_dir("", "");
+ check_path_to_dir(".", "./");
+ check_path_to_dir("./", "./");
+ check_path_to_dir("a/", "a/");
+ check_path_to_dir("ab", "ab/");
+ /* make sure we try just under and just over an expansion that will
+ * require a realloc
+ */
+ check_path_to_dir("abcdef", "abcdef/");
+ check_path_to_dir("abcdefg", "abcdefg/");
+ check_path_to_dir("abcdefgh", "abcdefgh/");
+ check_path_to_dir("abcdefghi", "abcdefghi/");
+ check_path_to_dir(REP1024("abcd") "/", REP1024("abcd") "/");
+ check_path_to_dir(REP1024("abcd"), REP1024("abcd") "/");
+
+ check_string_to_dir("", 1, "");
+ check_string_to_dir(".", 1, ".");
+ check_string_to_dir(".", 2, "./");
+ check_string_to_dir(".", 3, "./");
+ check_string_to_dir("abcd", 3, "abcd");
+ check_string_to_dir("abcd", 4, "abcd");
+ check_string_to_dir("abcd", 5, "abcd/");
+ check_string_to_dir("abcd", 6, "abcd/");
}
diff --git a/tests-clay/core/rmdir.c b/tests-clay/core/rmdir.c
index 20cc8f5f0..369c0232a 100644
--- a/tests-clay/core/rmdir.c
+++ b/tests-clay/core/rmdir.c
@@ -5,24 +5,26 @@ static const char *empty_tmp_dir = "test_gitfo_rmdir_recurs_test";
void test_core_rmdir__initialize(void)
{
- char path[GIT_PATH_MAX];
+ git_buf path = GIT_BUF_INIT;
cl_must_pass(p_mkdir(empty_tmp_dir, 0777));
- git_path_join(path, empty_tmp_dir, "/one");
- cl_must_pass(p_mkdir(path, 0777));
+ cl_git_pass(git_buf_joinpath(&path, empty_tmp_dir, "/one"));
+ cl_must_pass(p_mkdir(path.ptr, 0777));
- git_path_join(path, empty_tmp_dir, "/one/two_one");
- cl_must_pass(p_mkdir(path, 0777));
+ cl_git_pass(git_buf_joinpath(&path, empty_tmp_dir, "/one/two_one"));
+ cl_must_pass(p_mkdir(path.ptr, 0777));
- git_path_join(path, empty_tmp_dir, "/one/two_two");
- cl_must_pass(p_mkdir(path, 0777));
+ cl_git_pass(git_buf_joinpath(&path, empty_tmp_dir, "/one/two_two"));
+ cl_must_pass(p_mkdir(path.ptr, 0777));
- git_path_join(path, empty_tmp_dir, "/one/two_two/three");
- cl_must_pass(p_mkdir(path, 0777));
+ cl_git_pass(git_buf_joinpath(&path, empty_tmp_dir, "/one/two_two/three"));
+ cl_must_pass(p_mkdir(path.ptr, 0777));
- git_path_join(path, empty_tmp_dir, "/two");
- cl_must_pass(p_mkdir(path, 0777));
+ cl_git_pass(git_buf_joinpath(&path, empty_tmp_dir, "/two"));
+ cl_must_pass(p_mkdir(path.ptr, 0777));
+
+ git_buf_free(&path);
}
/* make sure empty dir can be deleted recusively */
@@ -34,17 +36,19 @@ void test_core_rmdir__delete_recursive(void)
/* make sure non-empty dir cannot be deleted recusively */
void test_core_rmdir__fail_to_delete_non_empty_dir(void)
{
- char file[GIT_PATH_MAX];
+ git_buf file = GIT_BUF_INIT;
int fd;
- git_path_join(file, empty_tmp_dir, "/two/file.txt");
+ cl_git_pass(git_buf_joinpath(&file, empty_tmp_dir, "/two/file.txt"));
- fd = p_creat(file, 0666);
+ fd = p_creat(file.ptr, 0666);
cl_assert(fd >= 0);
cl_must_pass(p_close(fd));
cl_git_fail(git_futils_rmdir_r(empty_tmp_dir, 0));
- cl_must_pass(p_unlink(file));
+ cl_must_pass(p_unlink(file.ptr));
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, 0));
+
+ git_buf_free(&file);
}
diff --git a/tests-clay/repo/init.c b/tests-clay/repo/init.c
index 9677541ed..e235ffaeb 100644
--- a/tests-clay/repo/init.c
+++ b/tests-clay/repo/init.c
@@ -77,17 +77,19 @@ void test_repo_init__bare_repo_noslash(void)
#if 0
BEGIN_TEST(init2, "Initialize and open a bare repo with a relative path escaping out of the current working directory")
- char path_repository[GIT_PATH_MAX];
+ git_buf path_repository = GIT_BUF_INIT;
char current_workdir[GIT_PATH_MAX];
const mode_t mode = 0777;
git_repository* repo;
must_pass(p_getcwd(current_workdir, sizeof(current_workdir)));
- git_path_join(path_repository, TEMP_REPO_FOLDER, "a/b/c/");
- must_pass(git_futils_mkdir_r(path_repository, mode));
+ must_pass(git_buf_joinpath(&path_repository, TEMP_REPO_FOLDER, "a/b/c/"));
+ must_pass(git_futils_mkdir_r(path_repository.ptr, mode));
- must_pass(chdir(path_repository));
+ must_pass(chdir(path_repository.ptr));
+
+ git_buf_free(&path_repository);
must_pass(git_repository_init(&repo, "../d/e.git", 1));
must_pass(git__suffixcmp(git_repository_path(_repo), "/a/b/d/e.git/"));
diff --git a/tests-clay/repo/open.c b/tests-clay/repo/open.c
index 235af1447..05b01ceb2 100644
--- a/tests-clay/repo/open.c
+++ b/tests-clay/repo/open.c
@@ -26,23 +26,24 @@ void test_repo_open__standard_empty_repo(void)
/* TODO TODO */
#if 0
BEGIN_TEST(open2, "Open a bare repository with a relative path escaping out of the current working directory")
- char new_current_workdir[GIT_PATH_MAX];
char current_workdir[GIT_PATH_MAX];
- char path_repository[GIT_PATH_MAX];
+ git_buf new_current_workdir = GIT_BUF_INIT;
+ git_buf path_repository = GIT_BUF_INIT;
const mode_t mode = 0777;
git_repository* repo;
/* Setup the repository to open */
must_pass(p_getcwd(current_workdir, sizeof(current_workdir)));
- strcpy(path_repository, current_workdir);
- git_path_join_n(path_repository, 3, path_repository, TEMP_REPO_FOLDER, "a/d/e.git");
- must_pass(copydir_recurs(REPOSITORY_FOLDER, path_repository));
+ must_pass(git_buf_join_n(&path_repository, 3, current_workdir, TEMP_REPO_FOLDER, "a/d/e.git"));
+ must_pass(copydir_recurs(REPOSITORY_FOLDER, path_repository.ptr));
+ git_buf_free(&path_repository);
/* Change the current working directory */
- git_path_join(new_current_workdir, TEMP_REPO_FOLDER, "a/b/c/");
- must_pass(git_futils_mkdir_r(new_current_workdir, mode));
- must_pass(chdir(new_current_workdir));
+ must_pass(git_buf_joinpath(&new_current_workdir, TEMP_REPO_FOLDER, "a/b/c/"));
+ must_pass(git_futils_mkdir_r(new_current_workdir.ptr, mode));
+ must_pass(chdir(new_current_workdir.ptr));
+ git_buf_free(&new_current_workdir);
must_pass(git_repository_open(&repo, "../../d/e.git"));