Re: [PATCH v3 1/2] refs: add a new function set_worktree_head_symref
- From
David Turner <dturner@twopensource.com>
- Date
- Mar 29, 2016, 02:23 UTC
- Message-ID
- <1459218192.2976.4.camel@twopensource.com>
- In-Reply-To
- <xmqq4mbqze65.fsf@gitster.mtv.corp.google.com>
On Mon, 2016-03-28 at 10:48 -0700, Junio C Hamano wrote:
Show 24 quoted lines
> Kazuki Yamaguchi <k@rhe.jp> writes:
>
> > Add a new function set_worktree_head_symref, to update HEAD symref
> > for
> > the specified worktree.
> >
> > To update HEAD of a linked working tree,
> > create_symref("worktrees/$work_tree/HEAD", "refs/heads/$branch",
> > msg)
> > could be used. However when it comes to updating HEAD of the main
> > working tree, it is unusable because it uses $GIT_DIR for
> > worktree-specific symrefs (HEAD).
> >
> > The new function takes git_dir (real directory) as an argument, and
> > updates HEAD of the working tree. This function will be used when
> > renaming a branch.
> >
> > Signed-off-by: Kazuki Yamaguchi <k@rhe.jp>
> > ---
>
> I suspect that this helper function should be in the common layer
> (refs.c) to be redirected to specific backend(s).
>
> David & Michael, what do you think?HEAD is a per-worktree ref, so it's always handled by the files backend. So this looks fine to me.
Show 6 quoted lines
> > +/*
> > + * Update HEAD of the specified gitdir.
> > + * Similar to create_symref("relative-git-dir/HEAD", target,
> > NULL), but this is
> > + * able to update the main working tree's HEAD wherever $GIT_DIR
> > points to.nit: "able to update the main working tree's HEAD regardless of where GIT_DIR points to" would be clearer.