Re: [PATCH 07/10] worktree.c: add update_worktree_location()
On Sat, Jun 25, 2016 at 3:54 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
Show 19 quoted lines
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> diff --git a/worktree.c b/worktree.c
> +int update_worktree_location(struct worktree *wt, const char *path_)
> +{
> + struct strbuf path = STRBUF_INIT;
> + int ret = 0;
> +
> + if (is_main_worktree(wt))
> + return 0;
> +
> + strbuf_add_absolute_path(&path, path_);
> + if (fspathcmp(wt->path, path.buf)) {
> + if (!write_file_gently(git_common_path("worktrees/%s/gitdir",
> + wt->id),
> + "%s/.git", real_path(path.buf))) {
> + free(wt->path);
> + wt->path = strbuf_detach(&path, NULL);
> + ret = 0;Show 8 quoted lines
> + } else
> + ret = error_errno(_("failed to update '%s'"),
> + git_common_path("worktrees/%s/gitdir",
> + wt->id));
> + }
> + strbuf_release(&path);
> + return ret;
> +}