Re: [PATCH 2/5] worktree.c: add is_main_worktree()
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- May 13, 2016, 16:32 UTC
- Message-ID
- <CAPig+cRFv_dkpEBGOHE-tUPPc82YNugzXAf14rh6fSiTK_6Oyw@mail.gmail.com>
- 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 <pclouds@gmail.com> wrote:
Show 11 quoted lines
> 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 <pclouds@gmail.com>
> ---
> 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?