diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2021-09-07 17:53:49 -0400 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2021-10-17 09:49:01 -0400 |
commit | f0e693b18afbe1de37d7da5b5a8967b6c87d8e53 (patch) | |
tree | be5e1cdbfa218ba81ec06bf45e45cfeb7f79a2a5 /tests/submodule | |
parent | 5346be3ddd3bcf19779c5d62e71f8442a0171133 (diff) | |
download | libgit2-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/submodule')
-rw-r--r-- | tests/submodule/add.c | 22 | ||||
-rw-r--r-- | tests/submodule/escape.c | 12 | ||||
-rw-r--r-- | tests/submodule/init.c | 18 | ||||
-rw-r--r-- | tests/submodule/inject_option.c | 12 | ||||
-rw-r--r-- | tests/submodule/lookup.c | 12 | ||||
-rw-r--r-- | tests/submodule/modify.c | 6 | ||||
-rw-r--r-- | tests/submodule/nosubs.c | 4 | ||||
-rw-r--r-- | tests/submodule/open.c | 34 | ||||
-rw-r--r-- | tests/submodule/repository_init.c | 4 | ||||
-rw-r--r-- | tests/submodule/status.c | 6 | ||||
-rw-r--r-- | tests/submodule/submodule_helpers.c | 39 |
11 files changed, 84 insertions, 85 deletions
diff --git a/tests/submodule/add.c b/tests/submodule/add.c index fc458f826..b564123dd 100644 --- a/tests/submodule/add.c +++ b/tests/submodule/add.c @@ -17,20 +17,20 @@ void test_submodule_add__cleanup(void) static void assert_submodule_url(const char* name, const char *url) { - git_buf key = GIT_BUF_INIT; + git_str key = GIT_STR_INIT; - cl_git_pass(git_buf_printf(&key, "submodule.%s.url", name)); - assert_config_entry_value(g_repo, git_buf_cstr(&key), url); + cl_git_pass(git_str_printf(&key, "submodule.%s.url", name)); + assert_config_entry_value(g_repo, git_str_cstr(&key), url); - git_buf_dispose(&key); + git_str_dispose(&key); } void test_submodule_add__url_absolute(void) { git_submodule *sm; git_repository *repo; - git_buf dot_git_content = GIT_BUF_INIT; + git_str dot_git_content = GIT_STR_INIT; g_repo = setup_fixture_submod2(); @@ -63,7 +63,7 @@ void test_submodule_add__url_absolute(void) cl_assert_equal_s("gitdir: ../.git/modules/sm_libgit2/", dot_git_content.ptr); git_repository_free(repo); - git_buf_dispose(&dot_git_content); + git_str_dispose(&dot_git_content); /* add a submodule not using a gitlink */ @@ -151,11 +151,11 @@ void test_submodule_add__path_exists_in_index(void) { git_index *index; git_submodule *sm; - git_buf filename = GIT_BUF_INIT; + git_str filename = GIT_STR_INIT; g_repo = cl_git_sandbox_init("testrepo"); - cl_git_pass(git_buf_joinpath(&filename, "subdirectory", "test.txt")); + cl_git_pass(git_str_joinpath(&filename, "subdirectory", "test.txt")); cl_git_pass(git_repository_index__weakptr(&index, g_repo)); @@ -164,14 +164,14 @@ void test_submodule_add__path_exists_in_index(void) cl_git_fail_with(git_submodule_add_setup(&sm, g_repo, "./", "subdirectory", 1), GIT_EEXISTS); git_submodule_free(sm); - git_buf_dispose(&filename); + git_str_dispose(&filename); } void test_submodule_add__file_exists_in_index(void) { git_index *index; git_submodule *sm; - git_buf name = GIT_BUF_INIT; + git_str name = GIT_STR_INIT; g_repo = cl_git_sandbox_init("testrepo"); @@ -182,7 +182,7 @@ void test_submodule_add__file_exists_in_index(void) cl_git_fail_with(git_submodule_add_setup(&sm, g_repo, "./", "subdirectory", 1), GIT_EEXISTS); git_submodule_free(sm); - git_buf_dispose(&name); + git_str_dispose(&name); } void test_submodule_add__submodule_clone(void) diff --git a/tests/submodule/escape.c b/tests/submodule/escape.c index 08eb76809..bcd52b510 100644 --- a/tests/submodule/escape.c +++ b/tests/submodule/escape.c @@ -33,17 +33,17 @@ void test_submodule_escape__from_gitdir(void) { int foundit; git_submodule *sm; - git_buf buf = GIT_BUF_INIT; + git_str buf = GIT_STR_INIT; unsigned int sm_location; g_repo = setup_fixture_submodule_simple(); - cl_git_pass(git_buf_joinpath(&buf, git_repository_workdir(g_repo), ".gitmodules")); + cl_git_pass(git_str_joinpath(&buf, git_repository_workdir(g_repo), ".gitmodules")); cl_git_rewritefile(buf.ptr, "[submodule \"" EVIL_SM_NAME "\"]\n" " path = testrepo\n" " url = ../testrepo.git\n"); - git_buf_dispose(&buf); + git_str_dispose(&buf); /* Find it all the different ways we know about it */ foundit = 0; @@ -67,17 +67,17 @@ void test_submodule_escape__from_gitdir_windows(void) { int foundit; git_submodule *sm; - git_buf buf = GIT_BUF_INIT; + git_str buf = GIT_STR_INIT; unsigned int sm_location; g_repo = setup_fixture_submodule_simple(); - cl_git_pass(git_buf_joinpath(&buf, git_repository_workdir(g_repo), ".gitmodules")); + cl_git_pass(git_str_joinpath(&buf, git_repository_workdir(g_repo), ".gitmodules")); cl_git_rewritefile(buf.ptr, "[submodule \"" EVIL_SM_NAME_WINDOWS "\"]\n" " path = testrepo\n" " url = ../testrepo.git\n"); - git_buf_dispose(&buf); + git_str_dispose(&buf); /* Find it all the different ways we know about it */ foundit = 0; diff --git a/tests/submodule/init.c b/tests/submodule/init.c index a1d870b9e..bf865a9e8 100644 --- a/tests/submodule/init.c +++ b/tests/submodule/init.c @@ -15,13 +15,13 @@ void test_submodule_init__absolute_url(void) { git_submodule *sm; git_config *cfg; - git_buf absolute_url = GIT_BUF_INIT; + git_str absolute_url = GIT_STR_INIT; const char *config_url; g_repo = setup_fixture_submodule_simple(); cl_assert(git_path_dirname_r(&absolute_url, git_repository_workdir(g_repo)) > 0); - cl_git_pass(git_buf_joinpath(&absolute_url, absolute_url.ptr, "testrepo.git")); + cl_git_pass(git_str_joinpath(&absolute_url, absolute_url.ptr, "testrepo.git")); /* write the absolute url to the .gitmodules file*/ cl_git_pass(git_submodule_set_url(g_repo, "testrepo", absolute_url.ptr)); @@ -39,7 +39,7 @@ void test_submodule_init__absolute_url(void) cl_git_pass(git_config_get_string(&config_url, cfg, "submodule.testrepo.url")); cl_assert_equal_s(absolute_url.ptr, config_url); - git_buf_dispose(&absolute_url); + git_str_dispose(&absolute_url); git_config_free(cfg); git_submodule_free(sm); } @@ -48,13 +48,13 @@ void test_submodule_init__relative_url(void) { git_submodule *sm; git_config *cfg; - git_buf absolute_url = GIT_BUF_INIT; + git_str absolute_url = GIT_STR_INIT; const char *config_url; g_repo = setup_fixture_submodule_simple(); cl_assert(git_path_dirname_r(&absolute_url, git_repository_workdir(g_repo)) > 0); - cl_git_pass(git_buf_joinpath(&absolute_url, absolute_url.ptr, "testrepo.git")); + cl_git_pass(git_str_joinpath(&absolute_url, absolute_url.ptr, "testrepo.git")); cl_git_pass(git_submodule_lookup(&sm, g_repo, "testrepo")); @@ -69,7 +69,7 @@ void test_submodule_init__relative_url(void) cl_git_pass(git_config_get_string(&config_url, cfg, "submodule.testrepo.url")); cl_assert_equal_s(absolute_url.ptr, config_url); - git_buf_dispose(&absolute_url); + git_str_dispose(&absolute_url); git_config_free(cfg); git_submodule_free(sm); } @@ -78,7 +78,7 @@ void test_submodule_init__relative_url_detached_head(void) { git_submodule *sm; git_config *cfg; - git_buf absolute_url = GIT_BUF_INIT; + git_str absolute_url = GIT_STR_INIT; const char *config_url; git_reference *head_ref = NULL; git_object *head_commit = NULL; @@ -92,7 +92,7 @@ void test_submodule_init__relative_url_detached_head(void) cl_git_pass(git_repository_set_head_detached(g_repo, git_commit_id((git_commit *)head_commit))); cl_assert(git_path_dirname_r(&absolute_url, git_repository_workdir(g_repo)) > 0); - cl_git_pass(git_buf_joinpath(&absolute_url, absolute_url.ptr, "testrepo.git")); + cl_git_pass(git_str_joinpath(&absolute_url, absolute_url.ptr, "testrepo.git")); cl_git_pass(git_submodule_lookup(&sm, g_repo, "testrepo")); @@ -107,7 +107,7 @@ void test_submodule_init__relative_url_detached_head(void) cl_git_pass(git_config_get_string(&config_url, cfg, "submodule.testrepo.url")); cl_assert_equal_s(absolute_url.ptr, config_url); - git_buf_dispose(&absolute_url); + git_str_dispose(&absolute_url); git_config_free(cfg); git_object_free(head_commit); git_reference_free(head_ref); diff --git a/tests/submodule/inject_option.c b/tests/submodule/inject_option.c index cfc02acff..e28ff8489 100644 --- a/tests/submodule/inject_option.c +++ b/tests/submodule/inject_option.c @@ -33,14 +33,14 @@ void test_submodule_inject_option__url(void) { int foundit; git_submodule *sm; - git_buf buf = GIT_BUF_INIT; + git_str buf = GIT_STR_INIT; - cl_git_pass(git_buf_joinpath(&buf, git_repository_workdir(g_repo), ".gitmodules")); + cl_git_pass(git_str_joinpath(&buf, git_repository_workdir(g_repo), ".gitmodules")); cl_git_rewritefile(buf.ptr, "[submodule \"naughty\"]\n" " path = testrepo\n" " url = -u./payload\n"); - git_buf_dispose(&buf); + git_str_dispose(&buf); /* We do want to find it, but with the appropriate field empty */ foundit = 0; @@ -58,14 +58,14 @@ void test_submodule_inject_option__path(void) { int foundit; git_submodule *sm; - git_buf buf = GIT_BUF_INIT; + git_str buf = GIT_STR_INIT; - cl_git_pass(git_buf_joinpath(&buf, git_repository_workdir(g_repo), ".gitmodules")); + cl_git_pass(git_str_joinpath(&buf, git_repository_workdir(g_repo), ".gitmodules")); cl_git_rewritefile(buf.ptr, "[submodule \"naughty\"]\n" " path = --something\n" " url = blah.git\n"); - git_buf_dispose(&buf); + git_str_dispose(&buf); /* We do want to find it, but with the appropriate field empty */ foundit = 0; diff --git a/tests/submodule/lookup.c b/tests/submodule/lookup.c index f49ebb4bd..acfdc838c 100644 --- a/tests/submodule/lookup.c +++ b/tests/submodule/lookup.c @@ -255,7 +255,7 @@ static void add_submodule_with_commit(const char *name) git_submodule *sm; git_repository *smrepo; git_index *idx; - git_buf p = GIT_BUF_INIT; + git_str p = GIT_STR_INIT; cl_git_pass(git_submodule_add_setup(&sm, g_repo, "https://github.com/libgit2/libgit2.git", name, 1)); @@ -265,9 +265,9 @@ static void add_submodule_with_commit(const char *name) cl_git_pass(git_submodule_open(&smrepo, sm)); cl_git_pass(git_repository_index(&idx, smrepo)); - cl_git_pass(git_buf_joinpath(&p, git_repository_workdir(smrepo), "file")); + cl_git_pass(git_str_joinpath(&p, git_repository_workdir(smrepo), "file")); cl_git_mkfile(p.ptr, "new file"); - git_buf_dispose(&p); + git_str_dispose(&p); cl_git_pass(git_index_add_bypath(idx, "file")); cl_git_pass(git_index_write(idx)); @@ -284,7 +284,7 @@ static void add_submodule_with_commit(const char *name) void test_submodule_lookup__just_added(void) { git_submodule *sm; - git_buf snap1 = GIT_BUF_INIT, snap2 = GIT_BUF_INIT; + git_str snap1 = GIT_STR_INIT, snap2 = GIT_STR_INIT; git_reference *original_head = NULL; refute_submodule_exists(g_repo, "sm_just_added", GIT_ENOTFOUND); @@ -333,7 +333,7 @@ void test_submodule_lookup__just_added(void) baseline_tests(); cl_git_rewritefile("submod2/.gitmodules", snap2.ptr); - git_buf_dispose(&snap2); + git_str_dispose(&snap2); refute_submodule_exists(g_repo, "mismatch_name", GIT_ENOTFOUND); refute_submodule_exists(g_repo, "mismatch_path", GIT_ENOTFOUND); @@ -344,7 +344,7 @@ void test_submodule_lookup__just_added(void) baseline_tests(); cl_git_rewritefile("submod2/.gitmodules", snap1.ptr); - git_buf_dispose(&snap1); + git_str_dispose(&snap1); refute_submodule_exists(g_repo, "mismatch_name", GIT_ENOTFOUND); refute_submodule_exists(g_repo, "mismatch_path", GIT_ENOTFOUND); diff --git a/tests/submodule/modify.c b/tests/submodule/modify.c index 654f677e6..fd3b0f80b 100644 --- a/tests/submodule/modify.c +++ b/tests/submodule/modify.c @@ -213,7 +213,7 @@ void test_submodule_modify__set_url(void) void test_submodule_modify__set_relative_url(void) { - git_buf path = GIT_BUF_INIT; + git_str path = GIT_STR_INIT; git_repository *repo; git_submodule *sm; @@ -222,12 +222,12 @@ void test_submodule_modify__set_relative_url(void) cl_git_pass(git_submodule_sync(sm)); cl_git_pass(git_submodule_open(&repo, sm)); - cl_git_pass(git_buf_joinpath(&path, clar_sandbox_path(), "relative-url")); + cl_git_pass(git_str_joinpath(&path, clar_sandbox_path(), "relative-url")); assert_config_entry_value(g_repo, "submodule."SM1".url", path.ptr); assert_config_entry_value(repo, "remote.origin.url", path.ptr); git_repository_free(repo); git_submodule_free(sm); - git_buf_dispose(&path); + git_str_dispose(&path); } diff --git a/tests/submodule/nosubs.c b/tests/submodule/nosubs.c index e47ee3983..e82230e87 100644 --- a/tests/submodule/nosubs.c +++ b/tests/submodule/nosubs.c @@ -69,7 +69,7 @@ void test_submodule_nosubs__add_and_delete(void) { git_repository *repo = cl_git_sandbox_init("status"); git_submodule *sm; - git_buf buf = GIT_BUF_INIT; + git_str buf = GIT_STR_INIT; cl_git_fail(git_submodule_lookup(NULL, repo, "libgit2")); cl_git_fail(git_submodule_lookup(NULL, repo, "submodules/libgit2")); @@ -85,7 +85,7 @@ void test_submodule_nosubs__add_and_delete(void) cl_git_pass(git_futils_readbuffer(&buf, "status/.gitmodules")); cl_assert(strstr(buf.ptr, "[submodule \"submodules/libgit2\"]") != NULL); cl_assert(strstr(buf.ptr, "path = submodules/libgit2") != NULL); - git_buf_dispose(&buf); + git_str_dispose(&buf); /* lookup */ diff --git a/tests/submodule/open.c b/tests/submodule/open.c index a8a5dccc3..4f31feedf 100644 --- a/tests/submodule/open.c +++ b/tests/submodule/open.c @@ -23,33 +23,33 @@ void test_submodule_open__cleanup(void) static void assert_sm_valid(git_repository *parent, git_repository *child, const char *sm_name) { - git_buf expected = GIT_BUF_INIT, actual = GIT_BUF_INIT; + git_str expected = GIT_STR_INIT, actual = GIT_STR_INIT; /* assert working directory */ - cl_git_pass(git_buf_joinpath(&expected, git_repository_workdir(parent), sm_name)); + cl_git_pass(git_str_joinpath(&expected, git_repository_workdir(parent), sm_name)); cl_git_pass(git_path_prettify_dir(&expected, expected.ptr, NULL)); - cl_git_pass(git_buf_sets(&actual, git_repository_workdir(child))); + cl_git_pass(git_str_sets(&actual, git_repository_workdir(child))); cl_git_pass(git_path_prettify_dir(&actual, actual.ptr, NULL)); cl_assert_equal_s(expected.ptr, actual.ptr); - git_buf_clear(&expected); - git_buf_clear(&actual); + git_str_clear(&expected); + git_str_clear(&actual); /* assert common directory */ - cl_git_pass(git_buf_joinpath(&expected, git_repository_commondir(parent), "modules")); - cl_git_pass(git_buf_joinpath(&expected, expected.ptr, sm_name)); + cl_git_pass(git_str_joinpath(&expected, git_repository_commondir(parent), "modules")); + cl_git_pass(git_str_joinpath(&expected, expected.ptr, sm_name)); cl_git_pass(git_path_prettify_dir(&expected, expected.ptr, NULL)); - cl_git_pass(git_buf_sets(&actual, git_repository_commondir(child))); + cl_git_pass(git_str_sets(&actual, git_repository_commondir(child))); cl_git_pass(git_path_prettify_dir(&actual, actual.ptr, NULL)); cl_assert_equal_s(expected.ptr, actual.ptr); /* assert git directory */ - cl_git_pass(git_buf_sets(&actual, git_repository_path(child))); + cl_git_pass(git_str_sets(&actual, git_repository_path(child))); cl_git_pass(git_path_prettify_dir(&actual, actual.ptr, NULL)); cl_assert_equal_s(expected.ptr, actual.ptr); - git_buf_dispose(&expected); - git_buf_dispose(&actual); + git_str_dispose(&expected); + git_str_dispose(&actual); } void test_submodule_open__opening_via_lookup_succeeds(void) @@ -61,18 +61,18 @@ void test_submodule_open__opening_via_lookup_succeeds(void) void test_submodule_open__direct_open_succeeds(void) { - git_buf path = GIT_BUF_INIT; + git_str path = GIT_STR_INIT; - cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_parent), "sm_unchanged")); + cl_git_pass(git_str_joinpath(&path, git_repository_workdir(g_parent), "sm_unchanged")); cl_git_pass(git_repository_open(&g_child, path.ptr)); assert_sm_valid(g_parent, g_child, "sm_unchanged"); - git_buf_dispose(&path); + git_str_dispose(&path); } void test_submodule_open__direct_open_succeeds_for_broken_sm_with_gitdir(void) { - git_buf path = GIT_BUF_INIT; + git_str path = GIT_STR_INIT; /* * This is actually not a valid submodule, but we @@ -82,9 +82,9 @@ void test_submodule_open__direct_open_succeeds_for_broken_sm_with_gitdir(void) * add a test for this. */ cl_git_mkfile("submod2/.git/modules/sm_unchanged/gitdir", ".git"); - cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_parent), "sm_unchanged")); + cl_git_pass(git_str_joinpath(&path, git_repository_workdir(g_parent), "sm_unchanged")); cl_git_pass(git_repository_open(&g_child, path.ptr)); assert_sm_valid(g_parent, g_child, "sm_unchanged"); - git_buf_dispose(&path); + git_str_dispose(&path); } diff --git a/tests/submodule/repository_init.c b/tests/submodule/repository_init.c index 9962af311..3927afc2e 100644 --- a/tests/submodule/repository_init.c +++ b/tests/submodule/repository_init.c @@ -11,7 +11,7 @@ void test_submodule_repository_init__basic(void) { git_submodule *sm; git_repository *repo; - git_buf dot_git_content = GIT_BUF_INIT; + git_str dot_git_content = GIT_STR_INIT; g_repo = setup_fixture_submod2(); @@ -34,5 +34,5 @@ void test_submodule_repository_init__basic(void) git_submodule_free(sm); git_repository_free(repo); - git_buf_dispose(&dot_git_content); + git_str_dispose(&dot_git_content); } diff --git a/tests/submodule/status.c b/tests/submodule/status.c index 06595cc9a..1d41337b7 100644 --- a/tests/submodule/status.c +++ b/tests/submodule/status.c @@ -31,10 +31,10 @@ void test_submodule_status__unchanged(void) static void rm_submodule(const char *name) { - git_buf path = GIT_BUF_INIT; - cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_repo), name)); + git_str path = GIT_STR_INIT; + cl_git_pass(git_str_joinpath(&path, git_repository_workdir(g_repo), name)); cl_git_pass(git_futils_rmdir_r(path.ptr, NULL, GIT_RMDIR_REMOVE_FILES)); - git_buf_dispose(&path); + git_str_dispose(&path); } static void add_submodule_to_index(const char *name) diff --git a/tests/submodule/submodule_helpers.c b/tests/submodule/submodule_helpers.c index 1d4759616..95d20a009 100644 --- a/tests/submodule/submodule_helpers.c +++ b/tests/submodule/submodule_helpers.c @@ -1,5 +1,4 @@ #include "clar_libgit2.h" -#include "buffer.h" #include "path.h" #include "util.h" #include "posix.h" @@ -12,12 +11,12 @@ */ void rewrite_gitmodules(const char *workdir) { - git_buf in_f = GIT_BUF_INIT, out_f = GIT_BUF_INIT, path = GIT_BUF_INIT; + git_str in_f = GIT_STR_INIT, out_f = GIT_STR_INIT, path = GIT_STR_INIT; FILE *in, *out; char line[256]; - cl_git_pass(git_buf_joinpath(&in_f, workdir, "gitmodules")); - cl_git_pass(git_buf_joinpath(&out_f, workdir, ".gitmodules")); + cl_git_pass(git_str_joinpath(&in_f, workdir, "gitmodules")); + cl_git_pass(git_str_joinpath(&out_f, workdir, ".gitmodules")); cl_assert((in = fopen(in_f.ptr, "rb")) != NULL); cl_assert((out = fopen(out_f.ptr, "wb")) != NULL); @@ -32,16 +31,16 @@ void rewrite_gitmodules(const char *workdir) scan += strlen("path ="); while (*scan == ' ') scan++; - git_buf_joinpath(&path, workdir, scan); - git_buf_rtrim(&path); - git_buf_joinpath(&path, path.ptr, ".gitted"); + git_str_joinpath(&path, workdir, scan); + git_str_rtrim(&path); + git_str_joinpath(&path, path.ptr, ".gitted"); - if (!git_buf_oom(&path) && p_access(path.ptr, F_OK) == 0) { - git_buf_joinpath(&out_f, workdir, scan); - git_buf_rtrim(&out_f); - git_buf_joinpath(&out_f, out_f.ptr, ".git"); + if (!git_str_oom(&path) && p_access(path.ptr, F_OK) == 0) { + git_str_joinpath(&out_f, workdir, scan); + git_str_rtrim(&out_f); + git_str_joinpath(&out_f, out_f.ptr, ".git"); - if (!git_buf_oom(&out_f)) + if (!git_str_oom(&out_f)) p_rename(path.ptr, out_f.ptr); } } @@ -57,18 +56,18 @@ void rewrite_gitmodules(const char *workdir) while (*scan == ' ') scan++; if (*scan == '.') { - git_buf_joinpath(&path, workdir, scan); - git_buf_rtrim(&path); + git_str_joinpath(&path, workdir, scan); + git_str_rtrim(&path); } else if (!*scan || *scan == '\n') { - git_buf_joinpath(&path, workdir, "../testrepo.git"); + git_str_joinpath(&path, workdir, "../testrepo.git"); } else { fputs(line, out); continue; } git_path_prettify(&path, path.ptr, NULL); - git_buf_putc(&path, '\n'); - cl_assert(!git_buf_oom(&path)); + git_str_putc(&path, '\n'); + cl_assert(!git_str_oom(&path)); fwrite(line, scan - line, sizeof(char), out); fputs(path.ptr, out); @@ -79,9 +78,9 @@ void rewrite_gitmodules(const char *workdir) cl_must_pass(p_unlink(in_f.ptr)); - git_buf_dispose(&in_f); - git_buf_dispose(&out_f); - git_buf_dispose(&path); + git_str_dispose(&in_f); + git_str_dispose(&out_f); + git_str_dispose(&path); } static void cleanup_fixture_submodules(void *payload) |