git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 07/13] setup: move prefix into repository

From
Justin Tobler <jltobler@gmail.com>
Date
Jul 6, 2026, 22:33 UTC
Message-ID
<akwq5fqlxk-ndw_8@denethor>
In-Reply-To
<20260630-pks-setup-split-discovery-and-setup-v1-7-13864eb5a032@pks.im>
On 26/06/30 01:47PM, Patrick Steinhardt wrote:
> The repository prefix is currently stored in the startup info. This
> feels somewhat awkward though, as it is inherently a property of a given
> repository.
Agreed.
> Move the prefix into the repository accordingly.
> 
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
[snip]
Show 7 quoted lines
> @@ -832,7 +832,8 @@ int cmd_rev_parse(int argc,
>  				prefix = argv[++i];
>  				if (!prefix)
>  					die(_("--prefix requires an argument"));
> -				startup_info->prefix = prefix;
> +				FREE_AND_NULL(the_repository->prefix);
> +				the_repository->prefix = xstrdup(prefix);

git-rev-parse(1) has an option to explicitly set the prefix and we honor that here.

[snip]
Show 12 quoted lines
> @@ -2105,10 +2105,10 @@ const char *setup_git_directory_gently(struct repository *repo, int *nongit_ok)
>  	 */
>  	if (prefix) {
>  		prefix = precompose_string_if_needed(prefix);
> -		startup_info->prefix = prefix;
> +		repo->prefix = xstrdup(prefix);
>  		setenv(GIT_PREFIX_ENVIRONMENT, prefix, 1);
>  	} else {
> -		startup_info->prefix = NULL;
> +		FREE_AND_NULL(repo->prefix);
>  		setenv(GIT_PREFIX_ENVIRONMENT, "", 1);
>  	}

We set the startup_info prefix here is `setup_git_directory_gently()` aleady, so we might as well just set it in the repository. I think this is a good change.

-Justin
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 18 of 24 in “setup: split up repository discovery and setup”
  1. 00/13 setup: split up repository discovery and setupPatrick Steinhardt, Jun 30, 2026
  2. 01/13 setup: rename `check_repository_format_gently()`Patrick Steinhardt, Jun 30, 2026
  3. Justin ToblerJul 6, 2026
  4. 02/13 setup: mark bogus worktree in `apply_repository_format()`Patrick Steinhardt, Jun 30, 2026
  5. Junio C HamanoJun 30, 2026
  6. Patrick SteinhardtJul 1, 2026
  7. Justin ToblerJul 6, 2026
  8. Patrick SteinhardtJul 7, 2026
  9. 03/13 setup: unify setup of shallow filePatrick Steinhardt, Jun 30, 2026
  10. Justin ToblerJul 6, 2026
  11. Patrick SteinhardtJul 7, 2026
  12. 04/13 setup: split up concerns of `setup_git_env_internal()`Patrick Steinhardt, Jun 30, 2026
  13. 05/13 setup: introduce explicit repository discoveryPatrick Steinhardt, Jun 30, 2026
  14. Justin ToblerJul 6, 2026
  15. Patrick SteinhardtJul 7, 2026
  16. 06/13 setup: embed repository format in discoveryPatrick Steinhardt, Jun 30, 2026
  17. 07/13 setup: move prefix into repositoryPatrick Steinhardt, Jun 30, 2026
  18. Justin ToblerJul 6, 2026
  19. 08/13 setup: drop static `cwd` variablePatrick Steinhardt, Jun 30, 2026
  20. 09/13 setup: propagate prefix via repository discoveryPatrick Steinhardt, Jun 30, 2026
  21. 10/13 setup: make repository discovery self-containedPatrick Steinhardt, Jun 30, 2026
  22. 11/13 setup: drop redundant configuration of `startup_info->have_repository`Patrick Steinhardt, Jun 30, 2026
  23. 12/13 setup: pass worktree to `init_db()`Patrick Steinhardt, Jun 30, 2026
  24. 13/13 setup: mark `set_git_work_tree()` as file-localPatrick Steinhardt, Jun 30, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.