On Fri, Aug 09, 2024 at 02:02:21PM -0500, Justin Tobler wrote: > On 24/08/07 08:57AM, Patrick Steinhardt wrote: > > When not provided a worktree, then `worktree_git_path()` will fall back > > to returning a path relative to the main repository. In this case, we > > implicitly rely on `the_repository` to derive the path. Remove this > > dependency by passing a `struct repository` as parameter. > > Are there many situations where `worktree_git_path()` would expect to > not be provided a worktree? I wonder whether this implicit behavior is > really necessary to begin with. Yeah, there are cases. I found that to be somewhat weird at first, but I does make the logic easier to handle because you don't need to special case whether you do or don't have a worktree. > > diff --git a/path.h b/path.h > > index 3d21b9cd16..6228ca03d7 100644 > > --- a/path.h > > +++ b/path.h > > @@ -97,9 +97,10 @@ const char *git_path(const char *fmt, ...) > > * Similar to git_path() but can produce paths for a specified > > * worktree instead of current one > > */ > > Now that the previously implicit behavior is more explicit, it might be > update the comment to explain that the provided repository is used as a > fallback. Good idea. Patrick