mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-28 10:28:56 +00:00
worktree: rename variable in git_worktree_add
This commit is contained in:
parent
9dcc79bc6a
commit
7cf7a40749
@ -272,7 +272,7 @@ out:
|
||||
|
||||
int git_worktree_add(git_worktree **out, git_repository *repo, const char *name, const char *worktree)
|
||||
{
|
||||
git_buf path = GIT_BUF_INIT, buf = GIT_BUF_INIT;
|
||||
git_buf gitdir = GIT_BUF_INIT, buf = GIT_BUF_INIT;
|
||||
git_reference *ref = NULL, *head = NULL;
|
||||
git_commit *commit = NULL;
|
||||
git_repository *wt = NULL;
|
||||
@ -283,15 +283,15 @@ int git_worktree_add(git_worktree **out, git_repository *repo, const char *name,
|
||||
|
||||
*out = NULL;
|
||||
|
||||
/* Create worktree related files in commondir */
|
||||
if ((err = git_buf_joinpath(&path, repo->commondir, "worktrees")) < 0)
|
||||
/* Create gitdir directory ".git/worktrees/<name>" */
|
||||
if ((err = git_buf_joinpath(&gitdir, repo->commondir, "worktrees")) < 0)
|
||||
goto out;
|
||||
if (!git_path_exists(path.ptr))
|
||||
if ((err = git_futils_mkdir(path.ptr, 0755, GIT_MKDIR_EXCL)) < 0)
|
||||
if (!git_path_exists(gitdir.ptr))
|
||||
if ((err = git_futils_mkdir(gitdir.ptr, 0755, GIT_MKDIR_EXCL)) < 0)
|
||||
goto out;
|
||||
if ((err = git_buf_joinpath(&path, path.ptr, name)) < 0)
|
||||
if ((err = git_buf_joinpath(&gitdir, gitdir.ptr, name)) < 0)
|
||||
goto out;
|
||||
if ((err = git_futils_mkdir(path.ptr, 0755, GIT_MKDIR_EXCL)) < 0)
|
||||
if ((err = git_futils_mkdir(gitdir.ptr, 0755, GIT_MKDIR_EXCL)) < 0)
|
||||
goto out;
|
||||
|
||||
/* Create worktree work dir */
|
||||
@ -299,19 +299,19 @@ int git_worktree_add(git_worktree **out, git_repository *repo, const char *name,
|
||||
goto out;
|
||||
|
||||
/* Create worktree .git file */
|
||||
if ((err = git_buf_printf(&buf, "gitdir: %s\n", path.ptr)) < 0)
|
||||
if ((err = git_buf_printf(&buf, "gitdir: %s\n", gitdir.ptr)) < 0)
|
||||
goto out;
|
||||
if ((err = write_wtfile(worktree, ".git", &buf)) < 0)
|
||||
goto out;
|
||||
|
||||
/* Create commondir files */
|
||||
/* Create gitdir files */
|
||||
if ((err = git_buf_sets(&buf, repo->commondir)) < 0
|
||||
|| (err = git_buf_putc(&buf, '\n')) < 0
|
||||
|| (err = write_wtfile(path.ptr, "commondir", &buf)) < 0)
|
||||
|| (err = write_wtfile(gitdir.ptr, "commondir", &buf)) < 0)
|
||||
goto out;
|
||||
if ((err = git_buf_joinpath(&buf, worktree, ".git")) < 0
|
||||
|| (err = git_buf_putc(&buf, '\n')) < 0
|
||||
|| (err = write_wtfile(path.ptr, "gitdir", &buf)) < 0)
|
||||
|| (err = write_wtfile(gitdir.ptr, "gitdir", &buf)) < 0)
|
||||
goto out;
|
||||
|
||||
/* Create new branch */
|
||||
@ -323,7 +323,7 @@ int git_worktree_add(git_worktree **out, git_repository *repo, const char *name,
|
||||
goto out;
|
||||
|
||||
/* Set worktree's HEAD */
|
||||
if ((err = git_repository_create_head(path.ptr, git_reference_name(ref))) < 0)
|
||||
if ((err = git_repository_create_head(gitdir.ptr, git_reference_name(ref))) < 0)
|
||||
goto out;
|
||||
if ((err = git_repository_open(&wt, worktree)) < 0)
|
||||
goto out;
|
||||
@ -338,7 +338,7 @@ int git_worktree_add(git_worktree **out, git_repository *repo, const char *name,
|
||||
goto out;
|
||||
|
||||
out:
|
||||
git_buf_free(&path);
|
||||
git_buf_free(&gitdir);
|
||||
git_buf_free(&buf);
|
||||
git_reference_free(ref);
|
||||
git_reference_free(head);
|
||||
|
Loading…
Reference in New Issue
Block a user