From 7cf7a407497dab6978ca6b8fc68713e2a50eb803 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 17 Mar 2017 08:06:49 +0100 Subject: [PATCH] worktree: rename variable in `git_worktree_add` --- src/worktree.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/worktree.c b/src/worktree.c index f90d8222a..2b0ebfb83 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/" */ + 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);