Re: [PATCH 2/7] worktree.c: add update_worktree_location()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 24, 2018 at 4:53 AM, Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> wrote:
> diff --git a/worktree.c b/worktree.c
> @@ -326,6 +326,24 @@ int validate_worktree(const struct worktree *wt, struct strbuf *errmsg)
> +void update_worktree_location(struct worktree *wt, const char *path_)
> +{
> +       struct strbuf path = STRBUF_INIT;
> +
> +       if (is_main_worktree(wt))
> +               die("BUG: can't relocate main worktree");
> +
> +       strbuf_add_absolute_path(&path, path_);
> +       if (fspathcmp(wt->path, path.buf)) {
> +               write_file(git_common_path("worktrees/%s/gitdir",
> +                                          wt->id),
> +                          "%s/.git", real_path(path.buf));

For the path stored in 'worktrees/<id>/gitdir' (and in wt->path), this
and other worktree-related code sometimes treats it only as "absolute
path" and sometimes as "real path". As a reviewer, I'm having trouble
understanding the logic of why, how, and when this distinction is
made. Can you explain a bit to help clarify when "absolute path" is
good enough and when "real path" is needed?

> +               free(wt->path);
> +               wt->path = strbuf_detach(&path, NULL);
> +       }
> +       strbuf_release(&path);
> +}




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux