worktree: rename variable in `git_worktree_add`
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
diff --git a/src/worktree.c b/src/worktree.c
index f90d822..2b0ebfb 100644
--- a/src/worktree.c
+++ b/src/worktree.c
@@ -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);