From: Eric Sunshine Date: Fri, 13 May 2016 16:32:52 GMT Subject: Re: [PATCH 2/5] worktree.c: add is_main_worktree() Message-ID: In-Reply-To: <20160510141729.23063-2-pclouds@gmail.com> On Tue, May 10, 2016 at 10:17 AM, Nguyễn Thái Ngọc Duy wrote: > Main worktree _is_ different. You can lock a linked worktree but not the > main one, for example. Provide an API for checking that. > > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > diff --git a/worktree.c b/worktree.c > @@ -238,6 +238,11 @@ struct worktree *find_worktree_by_path(struct worktree **list, > +int is_main_worktree(const struct worktree *wt) > +{ > + return wt && !wt->id; > +} Is or will there ever be a case when it is valid for 'wt' to be NULL? If not, perhaps assert() or die() if given NULL?