Commit 84f56cb0 by Patrick Steinhardt

repository: rename `path_repository` and `path_gitlink`

The `path_repository` variable is actually confusing to think
about, as it is not always clear what the repository actually is.
It may either be the path to the folder containing worktree and
.git directory, the path to .git itself, a worktree or something
entirely different. Actually, the intent of the variable is to
hold the path to the gitdir, which is either the .git directory
or the bare repository.

Rename the variable to `gitdir` to avoid confusion. While at it,
also rename `path_gitlink` to `gitlink` to improve consistency.
parent 384518d0
...@@ -28,7 +28,7 @@ static int write_cherrypick_head( ...@@ -28,7 +28,7 @@ static int write_cherrypick_head(
git_buf file_path = GIT_BUF_INIT; git_buf file_path = GIT_BUF_INIT;
int error = 0; int error = 0;
if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_CHERRYPICK_HEAD_FILE)) >= 0 && if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_CHERRYPICK_HEAD_FILE)) >= 0 &&
(error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_CHERRYPICK_FILE_MODE)) >= 0 && (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_CHERRYPICK_FILE_MODE)) >= 0 &&
(error = git_filebuf_printf(&file, "%s\n", commit_oidstr)) >= 0) (error = git_filebuf_printf(&file, "%s\n", commit_oidstr)) >= 0)
error = git_filebuf_commit(&file); error = git_filebuf_commit(&file);
...@@ -49,7 +49,7 @@ static int write_merge_msg( ...@@ -49,7 +49,7 @@ static int write_merge_msg(
git_buf file_path = GIT_BUF_INIT; git_buf file_path = GIT_BUF_INIT;
int error = 0; int error = 0;
if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_MSG_FILE)) < 0 || if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_MERGE_MSG_FILE)) < 0 ||
(error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_CHERRYPICK_FILE_MODE)) < 0 || (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_CHERRYPICK_FILE_MODE)) < 0 ||
(error = git_filebuf_printf(&file, "%s", commit_msg)) < 0) (error = git_filebuf_printf(&file, "%s", commit_msg)) < 0)
goto cleanup; goto cleanup;
......
...@@ -115,7 +115,7 @@ int git_fetchhead_write(git_repository *repo, git_vector *fetchhead_refs) ...@@ -115,7 +115,7 @@ int git_fetchhead_write(git_repository *repo, git_vector *fetchhead_refs)
assert(repo && fetchhead_refs); assert(repo && fetchhead_refs);
if (git_buf_joinpath(&path, repo->path_repository, GIT_FETCH_HEAD_FILE) < 0) if (git_buf_joinpath(&path, repo->gitdir, GIT_FETCH_HEAD_FILE) < 0)
return -1; return -1;
if (git_filebuf_open(&file, path.ptr, GIT_FILEBUF_FORCE, GIT_REFS_FILE_MODE) < 0) { if (git_filebuf_open(&file, path.ptr, GIT_FILEBUF_FORCE, GIT_REFS_FILE_MODE) < 0) {
...@@ -249,7 +249,7 @@ int git_repository_fetchhead_foreach(git_repository *repo, ...@@ -249,7 +249,7 @@ int git_repository_fetchhead_foreach(git_repository *repo,
assert(repo && cb); assert(repo && cb);
if (git_buf_joinpath(&path, repo->path_repository, GIT_FETCH_HEAD_FILE) < 0) if (git_buf_joinpath(&path, repo->gitdir, GIT_FETCH_HEAD_FILE) < 0)
return -1; return -1;
if ((error = git_futils_readbuffer(&file, git_buf_cstr(&path))) < 0) if ((error = git_futils_readbuffer(&file, git_buf_cstr(&path))) < 0)
......
...@@ -562,7 +562,7 @@ int git_repository_mergehead_foreach( ...@@ -562,7 +562,7 @@ int git_repository_mergehead_foreach(
assert(repo && cb); assert(repo && cb);
if ((error = git_buf_joinpath(&merge_head_path, repo->path_repository, if ((error = git_buf_joinpath(&merge_head_path, repo->gitdir,
GIT_MERGE_HEAD_FILE)) < 0) GIT_MERGE_HEAD_FILE)) < 0)
return error; return error;
...@@ -2277,7 +2277,7 @@ static int write_merge_head( ...@@ -2277,7 +2277,7 @@ static int write_merge_head(
assert(repo && heads); assert(repo && heads);
if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_HEAD_FILE)) < 0 || if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_MERGE_HEAD_FILE)) < 0 ||
(error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) < 0) (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) < 0)
goto cleanup; goto cleanup;
...@@ -2305,7 +2305,7 @@ static int write_merge_mode(git_repository *repo) ...@@ -2305,7 +2305,7 @@ static int write_merge_mode(git_repository *repo)
assert(repo); assert(repo);
if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_MODE_FILE)) < 0 || if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_MERGE_MODE_FILE)) < 0 ||
(error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) < 0) (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) < 0)
goto cleanup; goto cleanup;
...@@ -2536,7 +2536,7 @@ static int write_merge_msg( ...@@ -2536,7 +2536,7 @@ static int write_merge_msg(
for (i = 0; i < heads_len; i++) for (i = 0; i < heads_len; i++)
entries[i].merge_head = heads[i]; entries[i].merge_head = heads[i];
if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_MSG_FILE)) < 0 || if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_MERGE_MSG_FILE)) < 0 ||
(error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) < 0 || (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) < 0 ||
(error = git_filebuf_write(&file, "Merge ", 6)) < 0) (error = git_filebuf_write(&file, "Merge ", 6)) < 0)
goto cleanup; goto cleanup;
...@@ -2914,7 +2914,7 @@ int git_merge__append_conflicts_to_merge_msg( ...@@ -2914,7 +2914,7 @@ int git_merge__append_conflicts_to_merge_msg(
if (!git_index_has_conflicts(index)) if (!git_index_has_conflicts(index))
return 0; return 0;
if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_MSG_FILE)) < 0 || if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_MERGE_MSG_FILE)) < 0 ||
(error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_APPEND, GIT_MERGE_FILE_MODE)) < 0) (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_APPEND, GIT_MERGE_FILE_MODE)) < 0)
goto cleanup; goto cleanup;
......
...@@ -92,7 +92,7 @@ static int rebase_state_type( ...@@ -92,7 +92,7 @@ static int rebase_state_type(
git_buf path = GIT_BUF_INIT; git_buf path = GIT_BUF_INIT;
git_rebase_type_t type = GIT_REBASE_TYPE_NONE; git_rebase_type_t type = GIT_REBASE_TYPE_NONE;
if (git_buf_joinpath(&path, repo->path_repository, REBASE_APPLY_DIR) < 0) if (git_buf_joinpath(&path, repo->gitdir, REBASE_APPLY_DIR) < 0)
return -1; return -1;
if (git_path_isdir(git_buf_cstr(&path))) { if (git_path_isdir(git_buf_cstr(&path))) {
...@@ -101,7 +101,7 @@ static int rebase_state_type( ...@@ -101,7 +101,7 @@ static int rebase_state_type(
} }
git_buf_clear(&path); git_buf_clear(&path);
if (git_buf_joinpath(&path, repo->path_repository, REBASE_MERGE_DIR) < 0) if (git_buf_joinpath(&path, repo->gitdir, REBASE_MERGE_DIR) < 0)
return -1; return -1;
if (git_path_isdir(git_buf_cstr(&path))) { if (git_path_isdir(git_buf_cstr(&path))) {
...@@ -624,7 +624,7 @@ static int rebase_init_merge( ...@@ -624,7 +624,7 @@ static int rebase_init_merge(
GIT_UNUSED(upstream); GIT_UNUSED(upstream);
if ((error = git_buf_joinpath(&state_path, repo->path_repository, REBASE_MERGE_DIR)) < 0) if ((error = git_buf_joinpath(&state_path, repo->gitdir, REBASE_MERGE_DIR)) < 0)
goto done; goto done;
rebase->state_path = git_buf_detach(&state_path); rebase->state_path = git_buf_detach(&state_path);
......
...@@ -1435,13 +1435,13 @@ static int setup_namespace(git_buf *gitpath, git_repository *repo) ...@@ -1435,13 +1435,13 @@ static int setup_namespace(git_buf *gitpath, git_repository *repo)
char *parts, *start, *end; char *parts, *start, *end;
/* Not all repositories have a gitpath */ /* Not all repositories have a gitpath */
if (repo->path_repository == NULL) if (repo->gitdir == NULL)
return 0; return 0;
if (repo->commondir == NULL) if (repo->commondir == NULL)
return 0; return 0;
/* Load the path to the repo first */ /* Load the path to the repo first */
git_buf_puts(gitpath, repo->path_repository); git_buf_puts(gitpath, repo->gitdir);
/* if the repo is not namespaced, nothing else to do */ /* if the repo is not namespaced, nothing else to do */
if (repo->namespace == NULL) if (repo->namespace == NULL)
...@@ -1877,7 +1877,7 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_ ...@@ -1877,7 +1877,7 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
&normalized, new_name, GIT_REF_FORMAT_ALLOW_ONELEVEL)) < 0) &normalized, new_name, GIT_REF_FORMAT_ALLOW_ONELEVEL)) < 0)
return error; return error;
if (git_buf_joinpath(&temp_path, repo->path_repository, GIT_REFLOG_DIR) < 0) if (git_buf_joinpath(&temp_path, repo->gitdir, GIT_REFLOG_DIR) < 0)
return -1; return -1;
if (git_buf_joinpath(&old_path, git_buf_cstr(&temp_path), old_name) < 0) if (git_buf_joinpath(&old_path, git_buf_cstr(&temp_path), old_name) < 0)
......
...@@ -165,8 +165,8 @@ void git_repository_free(git_repository *repo) ...@@ -165,8 +165,8 @@ void git_repository_free(git_repository *repo)
git_buf_free(git_array_get(repo->reserved_names, i)); git_buf_free(git_array_get(repo->reserved_names, i));
git_array_clear(repo->reserved_names); git_array_clear(repo->reserved_names);
git__free(repo->path_gitlink); git__free(repo->gitlink);
git__free(repo->path_repository); git__free(repo->gitdir);
git__free(repo->commondir); git__free(repo->commondir);
git__free(repo->workdir); git__free(repo->workdir);
git__free(repo->namespace); git__free(repo->namespace);
...@@ -288,7 +288,7 @@ static int load_workdir(git_repository *repo, git_config *config, git_buf *paren ...@@ -288,7 +288,7 @@ static int load_workdir(git_repository *repo, git_config *config, git_buf *paren
if (ce && ce->value) { if (ce && ce->value) {
if ((error = git_path_prettify_dir( if ((error = git_path_prettify_dir(
&worktree, ce->value, repo->path_repository)) < 0) &worktree, ce->value, repo->gitdir)) < 0)
goto cleanup; goto cleanup;
repo->workdir = git_buf_detach(&worktree); repo->workdir = git_buf_detach(&worktree);
...@@ -296,7 +296,7 @@ static int load_workdir(git_repository *repo, git_config *config, git_buf *paren ...@@ -296,7 +296,7 @@ static int load_workdir(git_repository *repo, git_config *config, git_buf *paren
else if (parent_path && git_path_isdir(parent_path->ptr)) else if (parent_path && git_path_isdir(parent_path->ptr))
repo->workdir = git_buf_detach(parent_path); repo->workdir = git_buf_detach(parent_path);
else { else {
if (git_path_dirname_r(&worktree, repo->path_repository) < 0 || if (git_path_dirname_r(&worktree, repo->gitdir) < 0 ||
git_path_to_dir(&worktree) < 0) { git_path_to_dir(&worktree) < 0) {
error = -1; error = -1;
goto cleanup; goto cleanup;
...@@ -553,8 +553,8 @@ int git_repository_open_bare( ...@@ -553,8 +553,8 @@ int git_repository_open_bare(
repo = repository_alloc(); repo = repository_alloc();
GITERR_CHECK_ALLOC(repo); GITERR_CHECK_ALLOC(repo);
repo->path_repository = git_buf_detach(&path); repo->gitdir = git_buf_detach(&path);
GITERR_CHECK_ALLOC(repo->path_repository); GITERR_CHECK_ALLOC(repo->gitdir);
repo->commondir = git_buf_detach(&common_path); repo->commondir = git_buf_detach(&common_path);
GITERR_CHECK_ALLOC(repo->commondir); GITERR_CHECK_ALLOC(repo->commondir);
...@@ -763,19 +763,19 @@ int git_repository_open_ext( ...@@ -763,19 +763,19 @@ int git_repository_open_ext(
repo = repository_alloc(); repo = repository_alloc();
GITERR_CHECK_ALLOC(repo); GITERR_CHECK_ALLOC(repo);
repo->path_repository = git_buf_detach(&path); repo->gitdir = git_buf_detach(&path);
GITERR_CHECK_ALLOC(repo->path_repository); GITERR_CHECK_ALLOC(repo->gitdir);
if (link_path.size) { if (link_path.size) {
repo->path_gitlink = git_buf_detach(&link_path); repo->gitlink = git_buf_detach(&link_path);
GITERR_CHECK_ALLOC(repo->path_gitlink); GITERR_CHECK_ALLOC(repo->gitlink);
} }
if (common_path.size) { if (common_path.size) {
repo->commondir = git_buf_detach(&common_path); repo->commondir = git_buf_detach(&common_path);
GITERR_CHECK_ALLOC(repo->commondir); GITERR_CHECK_ALLOC(repo->commondir);
} }
if (repo->path_gitlink && repo->commondir && strcmp(repo->path_gitlink, repo->commondir)) if (repo->gitlink && repo->commondir && strcmp(repo->gitlink, repo->commondir))
repo->is_worktree = 1; repo->is_worktree = 1;
/* /*
...@@ -1114,7 +1114,7 @@ int git_repository_index__weakptr(git_index **out, git_repository *repo) ...@@ -1114,7 +1114,7 @@ int git_repository_index__weakptr(git_index **out, git_repository *repo)
git_buf index_path = GIT_BUF_INIT; git_buf index_path = GIT_BUF_INIT;
git_index *index; git_index *index;
if ((error = git_buf_joinpath(&index_path, repo->path_repository, GIT_INDEX_FILE)) < 0) if ((error = git_buf_joinpath(&index_path, repo->gitdir, GIT_INDEX_FILE)) < 0)
return error; return error;
error = git_index_open(&index, index_path.ptr); error = git_index_open(&index, index_path.ptr);
...@@ -1230,13 +1230,13 @@ bool git_repository__reserved_names( ...@@ -1230,13 +1230,13 @@ bool git_repository__reserved_names(
prefixcmp = (error || ignorecase) ? git__prefixcmp_icase : prefixcmp = (error || ignorecase) ? git__prefixcmp_icase :
git__prefixcmp; git__prefixcmp;
if (repo->path_gitlink && if (repo->gitlink &&
reserved_names_add8dot3(repo, repo->path_gitlink) < 0) reserved_names_add8dot3(repo, repo->gitlink) < 0)
goto on_error; goto on_error;
if (repo->path_repository && if (repo->gitdir &&
prefixcmp(repo->path_repository, repo->workdir) == 0 && prefixcmp(repo->gitdir, repo->workdir) == 0 &&
reserved_names_add8dot3(repo, repo->path_repository) < 0) reserved_names_add8dot3(repo, repo->gitdir) < 0)
goto on_error; goto on_error;
} }
} }
...@@ -2237,7 +2237,7 @@ int git_repository_item_path(git_buf *out, git_repository *repo, git_repository_ ...@@ -2237,7 +2237,7 @@ int git_repository_item_path(git_buf *out, git_repository *repo, git_repository_
const char *git_repository_path(git_repository *repo) const char *git_repository_path(git_repository *repo)
{ {
assert(repo); assert(repo);
return repo->path_repository; return repo->gitdir;
} }
const char *git_repository_workdir(git_repository *repo) const char *git_repository_workdir(git_repository *repo)
...@@ -2366,7 +2366,7 @@ int git_repository__set_orig_head(git_repository *repo, const git_oid *orig_head ...@@ -2366,7 +2366,7 @@ int git_repository__set_orig_head(git_repository *repo, const git_oid *orig_head
git_oid_fmt(orig_head_str, orig_head); git_oid_fmt(orig_head_str, orig_head);
if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_ORIG_HEAD_FILE)) == 0 && if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_ORIG_HEAD_FILE)) == 0 &&
(error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) == 0 && (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) == 0 &&
(error = git_filebuf_printf(&file, "%.*s\n", GIT_OID_HEXSZ, orig_head_str)) == 0) (error = git_filebuf_printf(&file, "%.*s\n", GIT_OID_HEXSZ, orig_head_str)) == 0)
error = git_filebuf_commit(&file); error = git_filebuf_commit(&file);
...@@ -2387,7 +2387,7 @@ int git_repository_message(git_buf *out, git_repository *repo) ...@@ -2387,7 +2387,7 @@ int git_repository_message(git_buf *out, git_repository *repo)
git_buf_sanitize(out); git_buf_sanitize(out);
if (git_buf_joinpath(&path, repo->path_repository, GIT_MERGE_MSG_FILE) < 0) if (git_buf_joinpath(&path, repo->gitdir, GIT_MERGE_MSG_FILE) < 0)
return -1; return -1;
if ((error = p_stat(git_buf_cstr(&path), &st)) < 0) { if ((error = p_stat(git_buf_cstr(&path), &st)) < 0) {
...@@ -2408,7 +2408,7 @@ int git_repository_message_remove(git_repository *repo) ...@@ -2408,7 +2408,7 @@ int git_repository_message_remove(git_repository *repo)
git_buf path = GIT_BUF_INIT; git_buf path = GIT_BUF_INIT;
int error; int error;
if (git_buf_joinpath(&path, repo->path_repository, GIT_MERGE_MSG_FILE) < 0) if (git_buf_joinpath(&path, repo->gitdir, GIT_MERGE_MSG_FILE) < 0)
return -1; return -1;
error = p_unlink(git_buf_cstr(&path)); error = p_unlink(git_buf_cstr(&path));
...@@ -2650,7 +2650,7 @@ int git_repository_state(git_repository *repo) ...@@ -2650,7 +2650,7 @@ int git_repository_state(git_repository *repo)
assert(repo); assert(repo);
if (git_buf_puts(&repo_path, repo->path_repository) < 0) if (git_buf_puts(&repo_path, repo->gitdir) < 0)
return -1; return -1;
if (git_path_contains_file(&repo_path, GIT_REBASE_MERGE_INTERACTIVE_FILE)) if (git_path_contains_file(&repo_path, GIT_REBASE_MERGE_INTERACTIVE_FILE))
...@@ -2692,7 +2692,7 @@ int git_repository__cleanup_files( ...@@ -2692,7 +2692,7 @@ int git_repository__cleanup_files(
for (error = 0, i = 0; !error && i < files_len; ++i) { for (error = 0, i = 0; !error && i < files_len; ++i) {
const char *path; const char *path;
if (git_buf_joinpath(&buf, repo->path_repository, files[i]) < 0) if (git_buf_joinpath(&buf, repo->gitdir, files[i]) < 0)
return -1; return -1;
path = git_buf_cstr(&buf); path = git_buf_cstr(&buf);
...@@ -2736,7 +2736,7 @@ int git_repository_is_shallow(git_repository *repo) ...@@ -2736,7 +2736,7 @@ int git_repository_is_shallow(git_repository *repo)
struct stat st; struct stat st;
int error; int error;
if ((error = git_buf_joinpath(&path, repo->path_repository, "shallow")) < 0) if ((error = git_buf_joinpath(&path, repo->gitdir, "shallow")) < 0)
return error; return error;
error = git_path_lstat(path.ptr, &st); error = git_path_lstat(path.ptr, &st);
......
...@@ -126,8 +126,8 @@ struct git_repository { ...@@ -126,8 +126,8 @@ struct git_repository {
git_attr_cache *attrcache; git_attr_cache *attrcache;
git_diff_driver_registry *diff_drivers; git_diff_driver_registry *diff_drivers;
char *path_repository; char *gitlink;
char *path_gitlink; char *gitdir;
char *commondir; char *commondir;
char *workdir; char *workdir;
char *namespace; char *namespace;
......
...@@ -27,7 +27,7 @@ static int write_revert_head( ...@@ -27,7 +27,7 @@ static int write_revert_head(
git_buf file_path = GIT_BUF_INIT; git_buf file_path = GIT_BUF_INIT;
int error = 0; int error = 0;
if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_REVERT_HEAD_FILE)) >= 0 && if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_REVERT_HEAD_FILE)) >= 0 &&
(error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_REVERT_FILE_MODE)) >= 0 && (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_REVERT_FILE_MODE)) >= 0 &&
(error = git_filebuf_printf(&file, "%s\n", commit_oidstr)) >= 0) (error = git_filebuf_printf(&file, "%s\n", commit_oidstr)) >= 0)
error = git_filebuf_commit(&file); error = git_filebuf_commit(&file);
...@@ -49,7 +49,7 @@ static int write_merge_msg( ...@@ -49,7 +49,7 @@ static int write_merge_msg(
git_buf file_path = GIT_BUF_INIT; git_buf file_path = GIT_BUF_INIT;
int error = 0; int error = 0;
if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_MSG_FILE)) < 0 || if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_MERGE_MSG_FILE)) < 0 ||
(error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_REVERT_FILE_MODE)) < 0 || (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_REVERT_FILE_MODE)) < 0 ||
(error = git_filebuf_printf(&file, "Revert \"%s\"\n\nThis reverts commit %s.\n", (error = git_filebuf_printf(&file, "Revert \"%s\"\n\nThis reverts commit %s.\n",
commit_msgline, commit_oidstr)) < 0) commit_msgline, commit_oidstr)) < 0)
......
...@@ -72,7 +72,7 @@ void test_worktree_merge__merge_setup(void) ...@@ -72,7 +72,7 @@ void test_worktree_merge__merge_setup(void)
for (i = 0; i < ARRAY_SIZE(merge_files); i++) { for (i = 0; i < ARRAY_SIZE(merge_files); i++) {
git_buf_clear(&path); git_buf_clear(&path);
cl_git_pass(git_buf_printf(&path, "%s/%s", cl_git_pass(git_buf_printf(&path, "%s/%s",
fixture.worktree->path_repository, merge_files[i])); fixture.worktree->gitdir, merge_files[i]));
cl_assert(git_path_exists(path.ptr)); cl_assert(git_path_exists(path.ptr));
} }
......
...@@ -117,8 +117,8 @@ void test_worktree_worktree__lookup(void) ...@@ -117,8 +117,8 @@ void test_worktree_worktree__lookup(void)
git_buf_printf(&gitdir_path, "%s/worktrees/%s", fixture.repo->commondir, "testrepo-worktree"); git_buf_printf(&gitdir_path, "%s/worktrees/%s", fixture.repo->commondir, "testrepo-worktree");
cl_assert_equal_s(wt->gitdir_path, gitdir_path.ptr); cl_assert_equal_s(wt->gitdir_path, gitdir_path.ptr);
cl_assert_equal_s(wt->parent_path, fixture.repo->path_repository); cl_assert_equal_s(wt->parent_path, fixture.repo->gitdir);
cl_assert_equal_s(wt->gitlink_path, fixture.worktree->path_gitlink); cl_assert_equal_s(wt->gitlink_path, fixture.worktree->gitlink);
cl_assert_equal_s(wt->commondir_path, fixture.repo->commondir); cl_assert_equal_s(wt->commondir_path, fixture.repo->commondir);
git_buf_free(&gitdir_path); git_buf_free(&gitdir_path);
...@@ -196,7 +196,7 @@ void test_worktree_worktree__open_invalid_parent(void) ...@@ -196,7 +196,7 @@ void test_worktree_worktree__open_invalid_parent(void)
cl_git_pass(git_buf_sets(&buf, "/path/to/nonexistent/gitdir")); cl_git_pass(git_buf_sets(&buf, "/path/to/nonexistent/gitdir"));
cl_git_pass(git_futils_writebuffer(&buf, cl_git_pass(git_futils_writebuffer(&buf,
fixture.worktree->path_gitlink, O_RDWR, 0644)); fixture.worktree->gitlink, O_RDWR, 0644));
cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree")); cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree"));
cl_git_fail(git_repository_open_from_worktree(&repo, wt)); cl_git_fail(git_repository_open_from_worktree(&repo, wt));
...@@ -254,7 +254,7 @@ void test_worktree_worktree__init_existing_worktree(void) ...@@ -254,7 +254,7 @@ void test_worktree_worktree__init_existing_worktree(void)
cl_git_fail(git_worktree_add(&wt, fixture.repo, "testrepo-worktree", path.ptr)); cl_git_fail(git_worktree_add(&wt, fixture.repo, "testrepo-worktree", path.ptr));
cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree")); cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree"));
cl_assert_equal_s(wt->gitlink_path, fixture.worktree->path_gitlink); cl_assert_equal_s(wt->gitlink_path, fixture.worktree->gitlink);
git_buf_free(&path); git_buf_free(&path);
git_worktree_free(wt); git_worktree_free(wt);
...@@ -271,7 +271,7 @@ void test_worktree_worktree__init_existing_path(void) ...@@ -271,7 +271,7 @@ void test_worktree_worktree__init_existing_path(void)
* the init call */ * the init call */
for (i = 0; i < ARRAY_SIZE(wtfiles); i++) { for (i = 0; i < ARRAY_SIZE(wtfiles); i++) {
cl_git_pass(git_buf_joinpath(&path, cl_git_pass(git_buf_joinpath(&path,
fixture.worktree->path_repository, wtfiles[i])); fixture.worktree->gitdir, wtfiles[i]));
cl_git_pass(p_unlink(path.ptr)); cl_git_pass(p_unlink(path.ptr));
} }
...@@ -281,7 +281,7 @@ void test_worktree_worktree__init_existing_path(void) ...@@ -281,7 +281,7 @@ void test_worktree_worktree__init_existing_path(void)
/* Verify files have not been re-created */ /* Verify files have not been re-created */
for (i = 0; i < ARRAY_SIZE(wtfiles); i++) { for (i = 0; i < ARRAY_SIZE(wtfiles); i++) {
cl_git_pass(git_buf_joinpath(&path, cl_git_pass(git_buf_joinpath(&path,
fixture.worktree->path_repository, wtfiles[i])); fixture.worktree->gitdir, wtfiles[i]));
cl_assert(!git_path_exists(path.ptr)); cl_assert(!git_path_exists(path.ptr));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment