From: Junio C Hamano Date: Tue, 31 May 2016 17:52:47 GMT Subject: Re: [PATCH v3 3/6] worktree.c: add is_main_worktree() Message-ID: In-Reply-To: <20160530104939.28407-4-pclouds@gmail.com> Nguyễn Thái Ngọc Duy writes: > Main worktree _is_ different. You can lock a linked worktree but not the > main one, for example. Provide an API for checking that. You haven't defined what it means to "lock" a worktree, so that example does not sound convincing at all, until the reader sees what happens later in the series. I'll just take your word for it and keep reading for now ;-) > > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > worktree.c | 5 +++++ > worktree.h | 5 +++++ > 2 files changed, 10 insertions(+) > > diff --git a/worktree.c b/worktree.c > index 4dd7b77..6432eec 100644 > --- a/worktree.c > +++ b/worktree.c > @@ -250,6 +250,11 @@ struct worktree *find_worktree(struct worktree **list, > return *list; > } > > +int is_main_worktree(const struct worktree *wt) > +{ > + return !wt->id; > +} > + > int is_worktree_being_rebased(const struct worktree *wt, > const char *target) > { > diff --git a/worktree.h b/worktree.h > index 7ad15da..e1c4715 100644 > --- a/worktree.h > +++ b/worktree.h > @@ -37,6 +37,11 @@ extern struct worktree *find_worktree(struct worktree **list, > const char *prefix, > const char *arg); > > +/* > + * Return true if the given worktree is the main one. > + */ > +extern int is_main_worktree(const struct worktree *wt); > + > /* > * Free up the memory for worktree(s) > */