#include "mailmap.h"
#include "common.h"
-#include "path.h"
+#include "config.h"
+#include "fs_path.h"
#include "repository.h"
#include "signature.h"
#include "git2/config.h"
#include "git2/revparse.h"
#include "blob.h"
#include "parse.h"
+#include "path.h"
#define MM_FILE ".mailmap"
#define MM_FILE_CONFIG "mailmap.file"
/*
* Parse a single entry from a mailmap file.
*
- * The output git_bufs will be non-owning, and should be copied before being
+ * The output git_strs will be non-owning, and should be copied before being
* persisted.
*/
static int parse_mailmap_entry(
- git_buf *real_name, git_buf *real_email,
- git_buf *replace_name, git_buf *replace_email,
+ git_str *real_name, git_str *real_email,
+ git_str *replace_name, git_str *replace_email,
git_parse_ctx *ctx)
{
const char *start;
size_t len;
- git_buf_clear(real_name);
- git_buf_clear(real_email);
- git_buf_clear(replace_name);
- git_buf_clear(replace_email);
+ git_str_clear(real_name);
+ git_str_clear(real_email);
+ git_str_clear(replace_name);
+ git_str_clear(replace_email);
git_parse_advance_ws(ctx);
if (is_eol(ctx))
if (advance_until(&start, &len, ctx, '<') < 0)
return -1;
- git_buf_attach_notowned(real_name, start, len);
- git_buf_rtrim(real_name);
+ git_str_attach_notowned(real_name, start, len);
+ git_str_rtrim(real_name);
/*
* If this is the last email in the line, this is the email to replace,
/* If we aren't at the end of the line, parse a second name and email */
if (!is_eol(ctx)) {
- git_buf_attach_notowned(real_email, start, len);
+ git_str_attach_notowned(real_email, start, len);
git_parse_advance_ws(ctx);
if (advance_until(&start, &len, ctx, '<') < 0)
return -1;
- git_buf_attach_notowned(replace_name, start, len);
- git_buf_rtrim(replace_name);
+ git_str_attach_notowned(replace_name, start, len);
+ git_str_rtrim(replace_name);
if (advance_until(&start, &len, ctx, '>') < 0)
return -1;
}
- git_buf_attach_notowned(replace_email, start, len);
+ git_str_attach_notowned(replace_email, start, len);
if (!is_eol(ctx))
return -1;
git_parse_ctx ctx;
/* Scratch buffers containing the real parsed names & emails */
- git_buf real_name = GIT_BUF_INIT;
- git_buf real_email = GIT_BUF_INIT;
- git_buf replace_name = GIT_BUF_INIT;
- git_buf replace_email = GIT_BUF_INIT;
+ git_str real_name = GIT_STR_INIT;
+ git_str real_email = GIT_STR_INIT;
+ git_str replace_name = GIT_STR_INIT;
+ git_str replace_email = GIT_STR_INIT;
/* Buffers may not contain '\0's. */
if (memchr(buf, '\0', len) != NULL)
}
cleanup:
- git_buf_dispose(&real_name);
- git_buf_dispose(&real_email);
- git_buf_dispose(&replace_name);
- git_buf_dispose(&replace_email);
+ git_str_dispose(&real_name);
+ git_str_dispose(&real_email);
+ git_str_dispose(&replace_name);
+ git_str_dispose(&replace_email);
return error;
}
{
git_object *object = NULL;
git_blob *blob = NULL;
- git_buf content = GIT_BUF_INIT;
+ git_str content = GIT_STR_INIT;
int error;
GIT_ASSERT_ARG(mm);
goto cleanup;
cleanup:
- git_buf_dispose(&content);
+ git_str_dispose(&content);
git_blob_free(blob);
git_object_free(object);
return error;
git_mailmap *mm, const char *path, git_repository *repo)
{
const char *base = repo ? git_repository_workdir(repo) : NULL;
- git_buf fullpath = GIT_BUF_INIT;
- git_buf content = GIT_BUF_INIT;
+ git_str fullpath = GIT_STR_INIT;
+ git_str content = GIT_STR_INIT;
int error;
- error = git_path_join_unrooted(&fullpath, path, base, NULL);
+ error = git_fs_path_join_unrooted(&fullpath, path, base, NULL);
if (error < 0)
goto cleanup;
- error = git_path_validate_workdir_buf(repo, &fullpath);
+ error = git_path_validate_str_length(repo, &fullpath);
if (error < 0)
goto cleanup;
goto cleanup;
cleanup:
- git_buf_dispose(&fullpath);
- git_buf_dispose(&content);
+ git_str_dispose(&fullpath);
+ git_str_dispose(&content);
return error;
}
static void mailmap_add_from_repository(git_mailmap *mm, git_repository *repo)
{
git_config *config = NULL;
- git_buf rev_buf = GIT_BUF_INIT;
- git_buf path_buf = GIT_BUF_INIT;
+ git_str rev_buf = GIT_STR_INIT;
+ git_str path_buf = GIT_STR_INIT;
const char *rev = NULL;
const char *path = NULL;
/* Try to load 'mailmap.file' and 'mailmap.blob' cfgs from the repo */
if (git_repository_config(&config, repo) == 0) {
- if (git_config_get_string_buf(&rev_buf, config, MM_BLOB_CONFIG) == 0)
+ if (git_config__get_string_buf(&rev_buf, config, MM_BLOB_CONFIG) == 0)
rev = rev_buf.ptr;
- if (git_config_get_path(&path_buf, config, MM_FILE_CONFIG) == 0)
+ if (git_config__get_path(&path_buf, config, MM_FILE_CONFIG) == 0)
path = path_buf.ptr;
}
if (path != NULL)
mailmap_add_file_ondisk(mm, path, repo);
- git_buf_dispose(&rev_buf);
- git_buf_dispose(&path_buf);
+ git_str_dispose(&rev_buf);
+ git_str_dispose(&path_buf);
git_config_free(config);
}