Nguyễn Thái Ngọc Duy <pclo...@gmail.com> writes: > This gives the caller more information and they can answer things like, > "is it the main worktree" or "is it the current worktree". The latter > question is needed for the "checkout a rebase branch" case later.
That makes good sense. > diff --git a/worktree.h b/worktree.h > index 3198c8d..d71d7ec 100644 > --- a/worktree.h > +++ b/worktree.h > @@ -36,9 +36,10 @@ extern void free_worktrees(struct worktree **); > /* > * Check if a per-worktree symref points to a ref in the main worktree > * or any linked worktree, and return the path to the exising worktree > - * if it is. Returns NULL if there is no existing ref. The caller is > - * responsible for freeing the returned path. > + * if it is. Returns NULL if there is no existing ref. The result > + * may be destroyed by the next call. > */ To return and keep alive one worktree[] instance (i.e. "existing"), the code holds onto the entire return value from get_worktrees(), if I am not misreading it. Typically you would have only a handful of worktrees so this may not be an issue, though. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html