Re: [PATCH v2 0/3] worktree: stop using "the_repository" in is_current_worktree()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 15, 2026, 21:17 UTC
- Message-ID
- <xmqqzf48rdvr.fsf@gitster.g>
- In-Reply-To
- <cover.1773591528.git.phillip.wood@dunelm.org.uk>
Phillip Wood <phillip.wood123@gmail.com> writes:
Show 27 quoted lines
> Range-diff against v1:
> 1: 075700a2256 = 1: 075700a2256 worktree: remove "the_repository" from is_current_worktree()
> 2: ae2a368e7e7 ! 2: c3c5767725d worktree add: stop reading ".git/HEAD"
> @@ builtin/worktree.c: static int can_use_local_refs(const struct add_opts *opts)
> - free(wt_gitdir);
> - }
> + if (!opts->quiet)
> -+ warning(_("HEAD points to an invalid (or orphaned) reference.\n"));
> ++ warning(_("HEAD points to an invalid (or orphaned) reference.\n"));
> return 1;
> }
> return 0;
> 3: 1151b5b3020 ! 3: 75eecc8492e worktree: reject NULL worktree in get_worktree_git_dir()
> @@ worktree.c: struct worktree **get_worktrees_without_reading_head(void)
> else if (!wt->id)
> return xstrdup(repo_get_common_dir(wt->repo));
> else
> +
> + ## worktree.h ##
> +@@ worktree.h: int submodule_uses_worktrees(const char *path);
> +
> + /*
> + * Return git dir of the worktree. Note that the path may be relative.
> +- * If wt is NULL, git dir of current worktree is returned.
> + */
> + char *get_worktree_git_dir(const struct worktree *wt);
> + Ah, I somehow expected to see that we say "passing NULL to wt is an error", but that is misleading. When something expects a worktree instance, and it accepts NULL as a special case, then that is worth commenting, but otherwise, it is not worth mentioning.
All look good. Will replace. Thanks.