From: Phillip Wood Date: Tue, 24 Jan 2023 10:35:26 GMT Subject: Re: [PATCH v2 1/3] branch: fix die_if_checked_out() when ignore_current_worktree Message-ID: <1a7fa327-3833-8da3-46d7-60bfe8dae82c@dunelm.org.uk> In-Reply-To: Hi Rubén On 22/01/2023 23:21, Rubén Justo wrote: > I tried to maintain the relationship and the role, too. Just introduce > the helper, as Phillip suggested and I think it is a good idea. When I suggested adding a helper I was thinking of something like static const struct worktree *do_find_shared_symref(struct worktree **worktrees, const char *symref, const char *target, int ignore_current) { /* * Body moved from find_share_symref() with a couple * of lines added to support ignore_current /* } const struct worktree *find_shared_symref(struct worktree **worktrees, const char *symref, const char *target) { return do_find_shared_symref(worktrees, symref, target, 0) } void die_if_checked_out(const char *branch, int ignore_current_worktree) { struct worktree **worktrees = get_worktrees(); const struct worktree *wt; wt = do_find_shared_symref(worktrees, "HEAD", branch, ignore_current_worktree); /* rest unchanged */ } The aim was to avoid changing the public api Best Wishes Phillip