summaryrefslogtreecommitdiff
path: root/src/refdb_fs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/refdb_fs.c')
-rw-r--r--src/refdb_fs.c264
1 files changed, 132 insertions, 132 deletions
diff --git a/src/refdb_fs.c b/src/refdb_fs.c
index 24cb22fb0..37eb85ecc 100644
--- a/src/refdb_fs.c
+++ b/src/refdb_fs.c
@@ -69,11 +69,11 @@ typedef struct refdb_fs_backend {
static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name);
GIT_INLINE(int) loose_path(
- git_buf *out,
+ git_str *out,
const char *base,
const char *refname)
{
- if (git_buf_joinpath(out, base, refname) < 0)
+ if (git_str_joinpath(out, base, refname) < 0)
return -1;
return git_path_validate_filesystem_with_suffix(out->ptr, out->size,
@@ -81,7 +81,7 @@ GIT_INLINE(int) loose_path(
}
GIT_INLINE(int) reflog_path(
- git_buf *out,
+ git_str *out,
git_repository *repo,
const char *refname)
{
@@ -91,7 +91,7 @@ GIT_INLINE(int) reflog_path(
base = (strcmp(refname, GIT_HEAD_FILE) == 0) ? repo->gitdir :
repo->commondir;
- if ((error = git_buf_joinpath(out, base, GIT_REFLOG_DIR)) < 0)
+ if ((error = git_str_joinpath(out, base, GIT_REFLOG_DIR)) < 0)
return error;
return loose_path(out, out->ptr, refname);
@@ -106,7 +106,7 @@ static int packref_cmp(const void *a_, const void *b_)
static int packed_reload(refdb_fs_backend *backend)
{
int error;
- git_buf packedrefs = GIT_BUF_INIT;
+ git_str packedrefs = GIT_STR_INIT;
char *scan, *eof, *eol;
if (!backend->gitpath)
@@ -212,7 +212,7 @@ static int packed_reload(refdb_fs_backend *backend)
}
git_sortedcache_wunlock(backend->refcache);
- git_buf_dispose(&packedrefs);
+ git_str_dispose(&packedrefs);
return 0;
@@ -221,17 +221,17 @@ parse_failed:
GIT_UNUSED(git_sortedcache_clear(backend->refcache, false));
git_sortedcache_wunlock(backend->refcache);
- git_buf_dispose(&packedrefs);
+ git_str_dispose(&packedrefs);
return -1;
}
static int loose_parse_oid(
- git_oid *oid, const char *filename, git_buf *file_content)
+ git_oid *oid, const char *filename, git_str *file_content)
{
- const char *str = git_buf_cstr(file_content);
+ const char *str = git_str_cstr(file_content);
- if (git_buf_len(file_content) < GIT_OID_HEXSZ)
+ if (git_str_len(file_content) < GIT_OID_HEXSZ)
goto corrupted;
/* we need to get 40 OID characters from the file */
@@ -248,13 +248,13 @@ corrupted:
return -1;
}
-static int loose_readbuffer(git_buf *buf, const char *base, const char *path)
+static int loose_readbuffer(git_str *buf, const char *base, const char *path)
{
int error;
if ((error = loose_path(buf, base, path)) < 0 ||
(error = git_futils_readbuffer(buf, buf->ptr)) < 0)
- git_buf_dispose(buf);
+ git_str_dispose(buf);
return error;
}
@@ -262,7 +262,7 @@ static int loose_readbuffer(git_buf *buf, const char *base, const char *path)
static int loose_lookup_to_packfile(refdb_fs_backend *backend, const char *name)
{
int error = 0;
- git_buf ref_file = GIT_BUF_INIT;
+ git_str ref_file = GIT_STR_INIT;
struct packref *ref = NULL;
git_oid oid;
@@ -275,7 +275,7 @@ static int loose_lookup_to_packfile(refdb_fs_backend *backend, const char *name)
}
/* skip symbolic refs */
- if (!git__prefixcmp(git_buf_cstr(&ref_file), GIT_SYMREF))
+ if (!git__prefixcmp(git_str_cstr(&ref_file), GIT_SYMREF))
goto done;
/* parse OID from file */
@@ -295,11 +295,11 @@ static int loose_lookup_to_packfile(refdb_fs_backend *backend, const char *name)
git_sortedcache_wunlock(backend->refcache);
done:
- git_buf_dispose(&ref_file);
+ git_str_dispose(&ref_file);
return error;
}
-static int _dirent_loose_load(void *payload, git_buf *full_path)
+static int _dirent_loose_load(void *payload, git_str *full_path)
{
refdb_fs_backend *backend = payload;
const char *file_path;
@@ -333,9 +333,9 @@ static int _dirent_loose_load(void *payload, git_buf *full_path)
static int packed_loadloose(refdb_fs_backend *backend)
{
int error;
- git_buf refs_path = GIT_BUF_INIT;
+ git_str refs_path = GIT_STR_INIT;
- if (git_buf_joinpath(&refs_path, backend->gitpath, GIT_REFS_DIR) < 0)
+ if (git_str_joinpath(&refs_path, backend->gitpath, GIT_REFS_DIR) < 0)
return -1;
/*
@@ -346,7 +346,7 @@ static int packed_loadloose(refdb_fs_backend *backend)
error = git_path_direach(
&refs_path, backend->direach_flags, _dirent_loose_load, backend);
- git_buf_dispose(&refs_path);
+ git_str_dispose(&refs_path);
return error;
}
@@ -357,7 +357,7 @@ static int refdb_fs_backend__exists(
const char *ref_name)
{
refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
- git_buf ref_path = GIT_BUF_INIT;
+ git_str ref_path = GIT_STR_INIT;
int error;
GIT_ASSERT_ARG(backend);
@@ -381,18 +381,18 @@ static int refdb_fs_backend__exists(
}
out:
- git_buf_dispose(&ref_path);
+ git_str_dispose(&ref_path);
return error;
}
-static const char *loose_parse_symbolic(git_buf *file_content)
+static const char *loose_parse_symbolic(git_str *file_content)
{
const unsigned int header_len = (unsigned int)strlen(GIT_SYMREF);
const char *refname_start;
refname_start = (const char *)file_content->ptr;
- if (git_buf_len(file_content) < header_len + 1) {
+ if (git_str_len(file_content) < header_len + 1) {
git_error_set(GIT_ERROR_REFERENCE, "corrupted loose reference file");
return NULL;
}
@@ -424,7 +424,7 @@ static int loose_lookup(
refdb_fs_backend *backend,
const char *ref_name)
{
- git_buf ref_file = GIT_BUF_INIT;
+ git_str ref_file = GIT_STR_INIT;
int error = 0;
const char *ref_dir;
@@ -438,10 +438,10 @@ static int loose_lookup(
if ((error = loose_readbuffer(&ref_file, ref_dir, ref_name)) < 0)
/* cannot read loose ref file - gah */;
- else if (git__prefixcmp(git_buf_cstr(&ref_file), GIT_SYMREF) == 0) {
+ else if (git__prefixcmp(git_str_cstr(&ref_file), GIT_SYMREF) == 0) {
const char *target;
- git_buf_rtrim(&ref_file);
+ git_str_rtrim(&ref_file);
if (!(target = loose_parse_symbolic(&ref_file)))
error = -1;
@@ -455,7 +455,7 @@ static int loose_lookup(
*out = git_reference__alloc(ref_name, &oid, NULL);
}
- git_buf_dispose(&ref_file);
+ git_str_dispose(&ref_file);
return error;
}
@@ -542,7 +542,7 @@ static void refdb_fs_backend__iterator_free(git_reference_iterator *_iter)
static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
{
int error = 0;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
git_iterator *fsit = NULL;
git_iterator_options fsit_opts = GIT_ITERATOR_OPTIONS_INIT;
const git_index_entry *entry = NULL;
@@ -578,26 +578,26 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
}
}
- if ((error = git_buf_puts(&path, backend->commonpath)) < 0 ||
- (error = git_buf_put(&path, ref_prefix, ref_prefix_len)) < 0) {
- git_buf_dispose(&path);
+ if ((error = git_str_puts(&path, backend->commonpath)) < 0 ||
+ (error = git_str_put(&path, ref_prefix, ref_prefix_len)) < 0) {
+ git_str_dispose(&path);
return error;
}
if ((error = git_iterator_for_filesystem(&fsit, path.ptr, &fsit_opts)) < 0) {
- git_buf_dispose(&path);
+ git_str_dispose(&path);
return (iter->glob && error == GIT_ENOTFOUND)? 0 : error;
}
- error = git_buf_sets(&path, ref_prefix);
+ error = git_str_sets(&path, ref_prefix);
while (!error && !git_iterator_advance(&entry, fsit)) {
const char *ref_name;
char *ref_dup;
- git_buf_truncate(&path, ref_prefix_len);
- git_buf_puts(&path, entry->path);
- ref_name = git_buf_cstr(&path);
+ git_str_truncate(&path, ref_prefix_len);
+ git_str_puts(&path, entry->path);
+ ref_name = git_str_cstr(&path);
if (git__suffixcmp(ref_name, ".lock") == 0 ||
(iter->glob && wildmatch(iter->glob, ref_name, 0) != 0))
@@ -611,7 +611,7 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
}
git_iterator_free(fsit);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
return error;
}
@@ -810,7 +810,7 @@ static int reference_path_available(
static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *name)
{
int error, filebuf_flags;
- git_buf ref_path = GIT_BUF_INIT;
+ git_str ref_path = GIT_STR_INIT;
const char *basedir;
GIT_ASSERT_ARG(file);
@@ -845,7 +845,7 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
if (error == GIT_EDIRECTORY)
git_error_set(GIT_ERROR_REFERENCE, "cannot lock ref '%s', there are refs beneath that folder", name);
- git_buf_dispose(&ref_path);
+ git_str_dispose(&ref_path);
return error;
}
@@ -1013,7 +1013,7 @@ static int packed_remove_loose(refdb_fs_backend *backend)
{
size_t i;
git_filebuf lock = GIT_FILEBUF_INIT;
- git_buf ref_content = GIT_BUF_INIT;
+ git_str ref_content = GIT_STR_INIT;
int error = 0;
/* backend->refcache is already locked when this is called */
@@ -1034,7 +1034,7 @@ static int packed_remove_loose(refdb_fs_backend *backend)
continue;
if (error < 0) {
- git_buf_dispose(&ref_content);
+ git_str_dispose(&ref_content);
git_error_set(GIT_ERROR_REFERENCE, "failed to lock loose reference '%s'", ref->name);
return error;
}
@@ -1065,7 +1065,7 @@ static int packed_remove_loose(refdb_fs_backend *backend)
p_unlink(lock.path_original);
}
- git_buf_dispose(&ref_content);
+ git_str_dispose(&ref_content);
git_filebuf_cleanup(&lock);
return 0;
}
@@ -1333,32 +1333,32 @@ static int refdb_fs_backend__prune_refs(
const char *ref_name,
const char *prefix)
{
- git_buf relative_path = GIT_BUF_INIT;
- git_buf base_path = GIT_BUF_INIT;
+ git_str relative_path = GIT_STR_INIT;
+ git_str base_path = GIT_STR_INIT;
size_t commonlen;
int error;
GIT_ASSERT_ARG(backend);
GIT_ASSERT_ARG(ref_name);
- if ((error = git_buf_sets(&relative_path, ref_name)) < 0)
+ if ((error = git_str_sets(&relative_path, ref_name)) < 0)
goto cleanup;
git_path_squash_slashes(&relative_path);
- if ((commonlen = git_path_common_dirlen("refs/heads/", git_buf_cstr(&relative_path))) == strlen("refs/heads/") ||
- (commonlen = git_path_common_dirlen("refs/tags/", git_buf_cstr(&relative_path))) == strlen("refs/tags/") ||
- (commonlen = git_path_common_dirlen("refs/remotes/", git_buf_cstr(&relative_path))) == strlen("refs/remotes/")) {
+ if ((commonlen = git_path_common_dirlen("refs/heads/", git_str_cstr(&relative_path))) == strlen("refs/heads/") ||
+ (commonlen = git_path_common_dirlen("refs/tags/", git_str_cstr(&relative_path))) == strlen("refs/tags/") ||
+ (commonlen = git_path_common_dirlen("refs/remotes/", git_str_cstr(&relative_path))) == strlen("refs/remotes/")) {
- git_buf_truncate(&relative_path, commonlen);
+ git_str_truncate(&relative_path, commonlen);
if (prefix)
- error = git_buf_join3(&base_path, '/',
+ error = git_str_join3(&base_path, '/',
backend->commonpath, prefix,
- git_buf_cstr(&relative_path));
+ git_str_cstr(&relative_path));
else
- error = git_buf_joinpath(&base_path,
+ error = git_str_joinpath(&base_path,
backend->commonpath,
- git_buf_cstr(&relative_path));
+ git_str_cstr(&relative_path));
if (!error)
error = git_path_validate_filesystem(base_path.ptr, base_path.size);
@@ -1367,7 +1367,7 @@ static int refdb_fs_backend__prune_refs(
goto cleanup;
error = git_futils_rmdir_r(ref_name + commonlen,
- git_buf_cstr(&base_path),
+ git_str_cstr(&base_path),
GIT_RMDIR_EMPTY_PARENTS | GIT_RMDIR_SKIP_ROOT);
if (error == GIT_ENOTFOUND)
@@ -1375,8 +1375,8 @@ static int refdb_fs_backend__prune_refs(
}
cleanup:
- git_buf_dispose(&relative_path);
- git_buf_dispose(&base_path);
+ git_str_dispose(&relative_path);
+ git_str_dispose(&base_path);
return error;
}
@@ -1405,7 +1405,7 @@ static int refdb_fs_backend__delete(
static int loose_delete(refdb_fs_backend *backend, const char *ref_name)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
int error = 0;
if ((error = loose_path(&path, backend->commonpath, ref_name)) < 0)
@@ -1417,7 +1417,7 @@ static int loose_delete(refdb_fs_backend *backend, const char *ref_name)
else if (error != 0)
error = -1;
- git_buf_dispose(&path);
+ git_str_dispose(&path);
return error;
}
@@ -1574,17 +1574,17 @@ static void refdb_fs_backend__free(git_refdb_backend *_backend)
static char *setup_namespace(git_repository *repo, const char *in)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
char *parts, *start, *end, *out = NULL;
if (!in)
goto done;
- git_buf_puts(&path, in);
+ git_str_puts(&path, in);
/* if the repo is not namespaced, nothing else to do */
if (repo->namespace == NULL) {
- out = git_buf_detach(&path);
+ out = git_str_detach(&path);
goto done;
}
@@ -1599,23 +1599,23 @@ static char *setup_namespace(git_repository *repo, const char *in)
* refs under refs/namespaces/foo/refs/namespaces/bar/
*/
while ((start = git__strsep(&end, "/")) != NULL)
- git_buf_printf(&path, "refs/namespaces/%s/", start);
+ git_str_printf(&path, "refs/namespaces/%s/", start);
- git_buf_printf(&path, "refs/namespaces/%s/refs", end);
+ git_str_printf(&path, "refs/namespaces/%s/refs", end);
git__free(parts);
/* Make sure that the folder with the namespace exists */
- if (git_futils_mkdir_relative(git_buf_cstr(&path), in, 0777,
+ if (git_futils_mkdir_relative(git_str_cstr(&path), in, 0777,
GIT_MKDIR_PATH, NULL) < 0)
goto done;
/* Return root of the namespaced gitpath, i.e. without the trailing 'refs' */
- git_buf_rtruncate_at_char(&path, '/');
- git_buf_putc(&path, '/');
- out = git_buf_detach(&path);
+ git_str_rtruncate_at_char(&path, '/');
+ git_str_putc(&path, '/');
+ out = git_str_detach(&path);
done:
- git_buf_dispose(&path);
+ git_str_dispose(&path);
return out;
}
@@ -1716,7 +1716,7 @@ static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *
{
refdb_fs_backend *backend;
git_repository *repo;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
int error;
GIT_ASSERT_ARG(_backend && name);
@@ -1727,8 +1727,8 @@ static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *
if ((error = reflog_path(&path, repo, name)) < 0)
return error;
- error = create_new_reflog_file(git_buf_cstr(&path));
- git_buf_dispose(&path);
+ error = create_new_reflog_file(git_str_cstr(&path));
+ git_str_dispose(&path);
return error;
}
@@ -1736,15 +1736,15 @@ static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *
static int has_reflog(git_repository *repo, const char *name)
{
int ret = 0;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
if (reflog_path(&path, repo, name) < 0)
goto cleanup;
- ret = git_path_isfile(git_buf_cstr(&path));
+ ret = git_path_isfile(git_str_cstr(&path));
cleanup:
- git_buf_dispose(&path);
+ git_str_dispose(&path);
return ret;
}
@@ -1763,8 +1763,8 @@ static int refdb_reflog_fs__has_log(git_refdb_backend *_backend, const char *nam
static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend, const char *name)
{
int error = -1;
- git_buf log_path = GIT_BUF_INIT;
- git_buf log_file = GIT_BUF_INIT;
+ git_str log_path = GIT_STR_INIT;
+ git_str log_file = GIT_STR_INIT;
git_reflog *log = NULL;
git_repository *repo;
refdb_fs_backend *backend;
@@ -1782,16 +1782,16 @@ static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend,
if (reflog_path(&log_path, repo, name) < 0)
goto cleanup;
- error = git_futils_readbuffer(&log_file, git_buf_cstr(&log_path));
+ error = git_futils_readbuffer(&log_file, git_str_cstr(&log_path));
if (error < 0 && error != GIT_ENOTFOUND)
goto cleanup;
if ((error == GIT_ENOTFOUND) &&
- ((error = create_new_reflog_file(git_buf_cstr(&log_path))) < 0))
+ ((error = create_new_reflog_file(git_str_cstr(&log_path))) < 0))
goto cleanup;
if ((error = reflog_parse(log,
- git_buf_cstr(&log_file), git_buf_len(&log_file))) < 0)
+ git_str_cstr(&log_file), git_str_len(&log_file))) < 0)
goto cleanup;
*out = log;
@@ -1801,14 +1801,14 @@ cleanup:
git_reflog_free(log);
success:
- git_buf_dispose(&log_file);
- git_buf_dispose(&log_path);
+ git_str_dispose(&log_file);
+ git_str_dispose(&log_path);
return error;
}
static int serialize_reflog_entry(
- git_buf *buf,
+ git_str *buf,
const git_oid *oid_old,
const git_oid *oid_new,
const git_signature *committer,
@@ -1820,38 +1820,38 @@ static int serialize_reflog_entry(
git_oid_tostr(raw_old, GIT_OID_HEXSZ+1, oid_old);
git_oid_tostr(raw_new, GIT_OID_HEXSZ+1, oid_new);
- git_buf_clear(buf);
+ git_str_clear(buf);
- git_buf_puts(buf, raw_old);
- git_buf_putc(buf, ' ');
- git_buf_puts(buf, raw_new);
+ git_str_puts(buf, raw_old);
+ git_str_putc(buf, ' ');
+ git_str_puts(buf, raw_new);
git_signature__writebuf(buf, " ", committer);
/* drop trailing LF */
- git_buf_rtrim(buf);
+ git_str_rtrim(buf);
if (msg) {
size_t i;
- git_buf_putc(buf, '\t');
- git_buf_puts(buf, msg);
+ git_str_putc(buf, '\t');
+ git_str_puts(buf, msg);
for (i = 0; i < buf->size - 2; i++)
if (buf->ptr[i] == '\n')
buf->ptr[i] = ' ';
- git_buf_rtrim(buf);
+ git_str_rtrim(buf);
}
- git_buf_putc(buf, '\n');
+ git_str_putc(buf, '\n');
- return git_buf_oom(buf);
+ return git_str_oom(buf);
}
static int lock_reflog(git_filebuf *file, refdb_fs_backend *backend, const char *refname)
{
git_repository *repo;
- git_buf log_path = GIT_BUF_INIT;
+ git_str log_path = GIT_STR_INIT;
int error;
repo = backend->repo;
@@ -1864,17 +1864,17 @@ static int lock_reflog(git_filebuf *file, refdb_fs_backend *backend, const char
if (reflog_path(&log_path, repo, refname) < 0)
return -1;
- if (!git_path_isfile(git_buf_cstr(&log_path))) {
+ if (!git_path_isfile(git_str_cstr(&log_path))) {
git_error_set(GIT_ERROR_INVALID,
"log file for reference '%s' doesn't exist", refname);
error = -1;
goto cleanup;
}
- error = git_filebuf_open(file, git_buf_cstr(&log_path), 0, GIT_REFLOG_FILE_MODE);
+ error = git_filebuf_open(file, git_str_cstr(&log_path), 0, GIT_REFLOG_FILE_MODE);
cleanup:
- git_buf_dispose(&log_path);
+ git_str_dispose(&log_path);
return error;
}
@@ -1885,7 +1885,7 @@ static int refdb_reflog_fs__write(git_refdb_backend *_backend, git_reflog *reflo
unsigned int i;
git_reflog_entry *entry;
refdb_fs_backend *backend;
- git_buf log = GIT_BUF_INIT;
+ git_str log = GIT_STR_INIT;
git_filebuf fbuf = GIT_FILEBUF_INIT;
GIT_ASSERT_ARG(_backend);
@@ -1911,7 +1911,7 @@ cleanup:
git_filebuf_cleanup(&fbuf);
success:
- git_buf_dispose(&log);
+ git_str_dispose(&log);
return error;
}
@@ -1921,7 +1921,7 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
{
int error, is_symbolic, open_flags;
git_oid old_id = {{0}}, new_id = {{0}};
- git_buf buf = GIT_BUF_INIT, path = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT, path = GIT_STR_INIT;
git_repository *repo = backend->repo;
is_symbolic = ref->type == GIT_REFERENCE_SYMBOLIC;
@@ -1965,7 +1965,7 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
if ((error = reflog_path(&path, repo, ref->name)) < 0)
goto cleanup;
- if (((error = git_futils_mkpath2file(git_buf_cstr(&path), 0777)) < 0) &&
+ if (((error = git_futils_mkpath2file(git_str_cstr(&path), 0777)) < 0) &&
(error != GIT_EEXISTS)) {
goto cleanup;
}
@@ -1973,11 +1973,11 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
/* If the new branch matches part of the namespace of a previously deleted branch,
* there maybe an obsolete/unused directory (or directory hierarchy) in the way.
*/
- if (git_path_isdir(git_buf_cstr(&path))) {
- if ((error = git_futils_rmdir_r(git_buf_cstr(&path), NULL, GIT_RMDIR_SKIP_NONEMPTY)) < 0) {
+ if (git_path_isdir(git_str_cstr(&path))) {
+ if ((error = git_futils_rmdir_r(git_str_cstr(&path), NULL, GIT_RMDIR_SKIP_NONEMPTY)) < 0) {
if (error == GIT_ENOTFOUND)
error = 0;
- } else if (git_path_isdir(git_buf_cstr(&path))) {
+ } else if (git_path_isdir(git_str_cstr(&path))) {
git_error_set(GIT_ERROR_REFERENCE, "cannot create reflog at '%s', there are reflogs beneath that folder",
ref->name);
error = GIT_EDIRECTORY;
@@ -1992,11 +1992,11 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
if (backend->fsync)
open_flags |= O_FSYNC;
- error = git_futils_writebuffer(&buf, git_buf_cstr(&path), open_flags, GIT_REFLOG_FILE_MODE);
+ error = git_futils_writebuffer(&buf, git_str_cstr(&path), open_flags, GIT_REFLOG_FILE_MODE);
cleanup:
- git_buf_dispose(&buf);
- git_buf_dispose(&path);
+ git_str_dispose(&buf);
+ git_str_dispose(&path);
return error;
}
@@ -2004,10 +2004,10 @@ cleanup:
static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_name, const char *new_name)
{
int error = 0, fd;
- git_buf old_path = GIT_BUF_INIT;
- git_buf new_path = GIT_BUF_INIT;
- git_buf temp_path = GIT_BUF_INIT;
- git_buf normalized = GIT_BUF_INIT;
+ git_str old_path = GIT_STR_INIT;
+ git_str new_path = GIT_STR_INIT;
+ git_str temp_path = GIT_STR_INIT;
+ git_str normalized = GIT_STR_INIT;
git_repository *repo;
refdb_fs_backend *backend;
@@ -2022,16 +2022,16 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
&normalized, new_name, GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL)) < 0)
return error;
- if (git_buf_joinpath(&temp_path, repo->gitdir, GIT_REFLOG_DIR) < 0)
+ if (git_str_joinpath(&temp_path, repo->gitdir, GIT_REFLOG_DIR) < 0)
return -1;
- if ((error = loose_path(&old_path, git_buf_cstr(&temp_path), old_name)) < 0)
+ if ((error = loose_path(&old_path, git_str_cstr(&temp_path), old_name)) < 0)
return error;
- if ((error = loose_path(&new_path, git_buf_cstr(&temp_path), git_buf_cstr(&normalized))) < 0)
+ if ((error = loose_path(&new_path, git_str_cstr(&temp_path), git_str_cstr(&normalized))) < 0)
return error;
- if (!git_path_exists(git_buf_cstr(&old_path))) {
+ if (!git_path_exists(git_str_cstr(&old_path))) {
error = GIT_ENOTFOUND;
goto cleanup;
}
@@ -2043,43 +2043,43 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
* - a/b -> a/b/c
* - a/b/c/d -> a/b/c
*/
- if ((error = loose_path(&temp_path, git_buf_cstr(&temp_path), "temp_reflog")) < 0)
+ if ((error = loose_path(&temp_path, git_str_cstr(&temp_path), "temp_reflog")) < 0)
return error;
- if ((fd = git_futils_mktmp(&temp_path, git_buf_cstr(&temp_path), GIT_REFLOG_FILE_MODE)) < 0) {
+ if ((fd = git_futils_mktmp(&temp_path, git_str_cstr(&temp_path), GIT_REFLOG_FILE_MODE)) < 0) {
error = -1;
goto cleanup;
}
p_close(fd);
- if (p_rename(git_buf_cstr(&old_path), git_buf_cstr(&temp_path)) < 0) {
+ if (p_rename(git_str_cstr(&old_path), git_str_cstr(&temp_path)) < 0) {
git_error_set(GIT_ERROR_OS, "failed to rename reflog for %s", new_name);
error = -1;
goto cleanup;
}
- if (git_path_isdir(git_buf_cstr(&new_path)) &&
- (git_futils_rmdir_r(git_buf_cstr(&new_path), NULL, GIT_RMDIR_SKIP_NONEMPTY) < 0)) {
+ if (git_path_isdir(git_str_cstr(&new_path)) &&
+ (git_futils_rmdir_r(git_str_cstr(&new_path), NULL, GIT_RMDIR_SKIP_NONEMPTY) < 0)) {
error = -1;
goto cleanup;
}
- if (git_futils_mkpath2file(git_buf_cstr(&new_path), GIT_REFLOG_DIR_MODE) < 0) {
+ if (git_futils_mkpath2file(git_str_cstr(&new_path), GIT_REFLOG_DIR_MODE) < 0) {
error = -1;
goto cleanup;
}
- if (p_rename(git_buf_cstr(&temp_path), git_buf_cstr(&new_path)) < 0) {
+ if (p_rename(git_str_cstr(&temp_path), git_str_cstr(&new_path)) < 0) {
git_error_set(GIT_ERROR_OS, "failed to rename reflog for %s", new_name);
error = -1;
}
cleanup:
- git_buf_dispose(&temp_path);
- git_buf_dispose(&old_path);
- git_buf_dispose(&new_path);
- git_buf_dispose(&normalized);
+ git_str_dispose(&temp_path);
+ git_str_dispose(&old_path);
+ git_str_dispose(&new_path);
+ git_str_dispose(&normalized);
return error;
}
@@ -2087,7 +2087,7 @@ cleanup:
static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name)
{
refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
int error;
GIT_ASSERT_ARG(_backend);
@@ -2105,7 +2105,7 @@ static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name
error = refdb_fs_backend__prune_refs(backend, name, GIT_REFLOG_DIR);
out:
- git_buf_dispose(&path);
+ git_str_dispose(&path);
return error;
}
@@ -2115,7 +2115,7 @@ int git_refdb_backend_fs(
git_repository *repository)
{
int t = 0;
- git_buf gitpath = GIT_BUF_INIT;
+ git_str gitpath = GIT_STR_INIT;
refdb_fs_backend *backend;
backend = git__calloc(1, sizeof(refdb_fs_backend));
@@ -2140,13 +2140,13 @@ int git_refdb_backend_fs(
goto fail;
}
- if (git_buf_joinpath(&gitpath, backend->commonpath, GIT_PACKEDREFS_FILE) < 0 ||
+ if (git_str_joinpath(&gitpath, backend->commonpath, GIT_PACKEDREFS_FILE) < 0 ||
git_sortedcache_new(
&backend->refcache, offsetof(struct packref, name),
- NULL, NULL, packref_cmp, git_buf_cstr(&gitpath)) < 0)
+ NULL, NULL, packref_cmp, git_str_cstr(&gitpath)) < 0)
goto fail;
- git_buf_dispose(&gitpath);
+ git_str_dispose(&gitpath);
if (!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_IGNORECASE) && t) {
backend->iterator_flags |= GIT_ITERATOR_IGNORE_CASE;
@@ -2182,7 +2182,7 @@ int git_refdb_backend_fs(
return 0;
fail:
- git_buf_dispose(&gitpath);
+ git_str_dispose(&gitpath);
git__free(backend->gitpath);
git__free(backend->commonpath);
git__free(backend);