Commit 7cf7a407 by Patrick Steinhardt

worktree: rename variable in `git_worktree_add`

parent 9dcc79bc
...@@ -272,7 +272,7 @@ out: ...@@ -272,7 +272,7 @@ out:
int git_worktree_add(git_worktree **out, git_repository *repo, const char *name, const char *worktree) 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_reference *ref = NULL, *head = NULL;
git_commit *commit = NULL; git_commit *commit = NULL;
git_repository *wt = NULL; git_repository *wt = NULL;
...@@ -283,15 +283,15 @@ int git_worktree_add(git_worktree **out, git_repository *repo, const char *name, ...@@ -283,15 +283,15 @@ int git_worktree_add(git_worktree **out, git_repository *repo, const char *name,
*out = NULL; *out = NULL;
/* Create worktree related files in commondir */ /* Create gitdir directory ".git/worktrees/<name>" */
if ((err = git_buf_joinpath(&path, repo->commondir, "worktrees")) < 0) if ((err = git_buf_joinpath(&gitdir, repo->commondir, "worktrees")) < 0)
goto out; goto out;
if (!git_path_exists(path.ptr)) if (!git_path_exists(gitdir.ptr))
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; goto out;
if ((err = git_buf_joinpath(&path, path.ptr, name)) < 0) if ((err = git_buf_joinpath(&gitdir, gitdir.ptr, name)) < 0)
goto out; 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; goto out;
/* Create worktree work dir */ /* Create worktree work dir */
...@@ -299,19 +299,19 @@ int git_worktree_add(git_worktree **out, git_repository *repo, const char *name, ...@@ -299,19 +299,19 @@ int git_worktree_add(git_worktree **out, git_repository *repo, const char *name,
goto out; goto out;
/* Create worktree .git file */ /* 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; goto out;
if ((err = write_wtfile(worktree, ".git", &buf)) < 0) if ((err = write_wtfile(worktree, ".git", &buf)) < 0)
goto out; goto out;
/* Create commondir files */ /* Create gitdir files */
if ((err = git_buf_sets(&buf, repo->commondir)) < 0 if ((err = git_buf_sets(&buf, repo->commondir)) < 0
|| (err = git_buf_putc(&buf, '\n')) < 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; goto out;
if ((err = git_buf_joinpath(&buf, worktree, ".git")) < 0 if ((err = git_buf_joinpath(&buf, worktree, ".git")) < 0
|| (err = git_buf_putc(&buf, '\n')) < 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; goto out;
/* Create new branch */ /* Create new branch */
...@@ -323,7 +323,7 @@ int git_worktree_add(git_worktree **out, git_repository *repo, const char *name, ...@@ -323,7 +323,7 @@ int git_worktree_add(git_worktree **out, git_repository *repo, const char *name,
goto out; goto out;
/* Set worktree's HEAD */ /* 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; goto out;
if ((err = git_repository_open(&wt, worktree)) < 0) if ((err = git_repository_open(&wt, worktree)) < 0)
goto out; goto out;
...@@ -338,7 +338,7 @@ int git_worktree_add(git_worktree **out, git_repository *repo, const char *name, ...@@ -338,7 +338,7 @@ int git_worktree_add(git_worktree **out, git_repository *repo, const char *name,
goto out; goto out;
out: out:
git_buf_free(&path); git_buf_free(&gitdir);
git_buf_free(&buf); git_buf_free(&buf);
git_reference_free(ref); git_reference_free(ref);
git_reference_free(head); git_reference_free(head);
......
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