git/list[1] front-page[2] threads[3] people[4] search[5] about
wed 2026-10-07 17:21 UTC

Re: [PATCH v5 11/11] repo: refine path keys for repo info

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Mar 1, 2026, 10:33 UTC
Message-ID
<40a256b0-81fc-435b-b4b4-7ae1144d3672@gmail.com>
In-Reply-To
<8af17ad83115882ed174434e566523cf0bc376d9.1772220640.git.gitgitgadget@gmail.com>
Hi Eslam
On 27/02/2026 19:30, Eslam reda ragheb via GitGitGadget wrote:
Show 10 quoted lines
> From: Eslam reda ragheb <eslam.reda.div@gmail.com>
> 
> Rename path.git-prefix to path.prefix, add path.work-tree as an alias
> for path.toplevel, and drop reflog/ref-file-oriented path keys.
> 
> This narrows the path surface to keys that are less tied to direct
> file access while keeping tests and documentation in sync.
> 
> Also normalize prefix handling in repo_info context so path.prefix has
> a stable empty-string behavior.

When you change a patch series based on a reviewer's feedback, you should use "git rebase -i" to edit or fixup the existing commits rather than adding new changes on top. That keeps the history cleaner as we don't need to know "I implemented it like this and than changed it to that". It also makes the patch series easier to review as reviewers don't waste their time commenting on changes in one patch that are then deleted in a later patch.

Thanks
Phillip
Show 250 quoted lines
> Signed-off-by: Eslam reda ragheb <eslam.reda.div@gmail.com>
> ---
>   Documentation/git-repo.adoc | 14 ++++-------
>   builtin/repo.c              | 45 ++++++++--------------------------
>   t/t1900-repo.sh             | 48 +++++++++++++++++--------------------
>   3 files changed, 36 insertions(+), 71 deletions(-)
> 
> diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
> index b575977a4b..3d34c6edca 100644
> --- a/Documentation/git-repo.adoc
> +++ b/Documentation/git-repo.adoc
> @@ -114,7 +114,7 @@ Here's a list of the available keys and the values that they return:
>   `path.git-dir`::
>   	The path to the git directory.
>   
> -`path.git-prefix`::
> +`path.prefix`::
>   	The path of the current working directory relative to the top-level
>   	directory.
>   
> @@ -127,18 +127,9 @@ Here's a list of the available keys and the values that they return:
>   `path.index-file`::
>   	The path to the index file.
>   
> -`path.logs-directory`::
> -	The path to the `logs` directory.
> -
>   `path.objects-directory`::
>   	The path to the objects directory.
>   
> -`path.packed-refs-file`::
> -	The path to the `packed-refs` file.
> -
> -`path.refs-directory`::
> -	The path to the `refs` directory.
> -
>   `path.shallow-file`::
>   	The path to the `shallow` file.
>   
> @@ -150,6 +141,9 @@ Here's a list of the available keys and the values that they return:
>   	The path to the top-level working tree directory, or an empty string
>   	for bare repositories.
>   
> +`path.work-tree`::
> +	Alias for `path.toplevel`.
> +
>   `references.format`::
>   	The reference storage format. The valid values are:
>   +
> diff --git a/builtin/repo.c b/builtin/repo.c
> index ecd9d3aee5..9fbd13a358 100644
> --- a/builtin/repo.c
> +++ b/builtin/repo.c
> @@ -109,10 +109,9 @@ static int get_path_git_dir(struct repo_info *info, struct strbuf *buf)
>   	return 0;
>   }
>   
> -static int get_path_git_prefix(struct repo_info *info, struct strbuf *buf)
> +static int get_path_prefix(struct repo_info *info, struct strbuf *buf)
>   {
> -	if (info->prefix)
> -		strbuf_addstr(buf, info->prefix);
> +	strbuf_addstr(buf, info->prefix);
>   	return 0;
>   }
>   
> @@ -137,39 +136,12 @@ static int get_path_index_file(struct repo_info *info, struct strbuf *buf)
>   	return 0;
>   }
>   
> -static int get_path_logs_directory(struct repo_info *info, struct strbuf *buf)
> -{
> -	struct strbuf path = STRBUF_INIT;
> -
> -	repo_info_add_path(info, buf, repo_git_path_replace(info->repo, &path, "logs"));
> -	strbuf_release(&path);
> -	return 0;
> -}
> -
>   static int get_path_objects_directory(struct repo_info *info, struct strbuf *buf)
>   {
>   	repo_info_add_path(info, buf, repo_get_object_directory(info->repo));
>   	return 0;
>   }
>   
> -static int get_path_packed_refs_file(struct repo_info *info, struct strbuf *buf)
> -{
> -	struct strbuf path = STRBUF_INIT;
> -
> -	repo_info_add_path(info, buf, repo_git_path_replace(info->repo, &path, "packed-refs"));
> -	strbuf_release(&path);
> -	return 0;
> -}
> -
> -static int get_path_refs_directory(struct repo_info *info, struct strbuf *buf)
> -{
> -	struct strbuf path = STRBUF_INIT;
> -
> -	repo_info_add_path(info, buf, repo_git_path_replace(info->repo, &path, "refs"));
> -	strbuf_release(&path);
> -	return 0;
> -}
> -
>   static int get_path_shallow_file(struct repo_info *info, struct strbuf *buf)
>   {
>   	struct strbuf path = STRBUF_INIT;
> @@ -201,6 +173,11 @@ static int get_path_toplevel(struct repo_info *info, struct strbuf *buf)
>   	return 0;
>   }
>   
> +static int get_path_work_tree(struct repo_info *info, struct strbuf *buf)
> +{
> +	return get_path_toplevel(info, buf);
> +}
> +
>   static int get_references_format(struct repo_info *info, struct strbuf *buf)
>   {
>   	struct repository *repo = info->repo;
> @@ -217,17 +194,15 @@ static const struct field repo_info_fields[] = {
>   	{ "path.common-dir", get_path_common_dir },
>   	{ "path.config-file", get_path_config_file },
>   	{ "path.git-dir", get_path_git_dir },
> -	{ "path.git-prefix", get_path_git_prefix },
>   	{ "path.grafts-file", get_path_grafts_file },
>   	{ "path.hooks-directory", get_path_hooks_directory },
>   	{ "path.index-file", get_path_index_file },
> -	{ "path.logs-directory", get_path_logs_directory },
>   	{ "path.objects-directory", get_path_objects_directory },
> -	{ "path.packed-refs-file", get_path_packed_refs_file },
> -	{ "path.refs-directory", get_path_refs_directory },
> +	{ "path.prefix", get_path_prefix },
>   	{ "path.shallow-file", get_path_shallow_file },
>   	{ "path.superproject-working-tree", get_path_superproject_working_tree },
>   	{ "path.toplevel", get_path_toplevel },
> +	{ "path.work-tree", get_path_work_tree },
>   	{ "references.format", get_references_format },
>   };
>   
> @@ -378,7 +353,7 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,
>   	enum output_format format = FORMAT_KEYVALUE;
>   	struct repo_info info = {
>   		.repo = repo,
> -		.prefix = prefix,
> +		.prefix = prefix ? prefix : "",
>   		.path_format = PATH_FORMAT_ABSOLUTE,
>   	};
>   	int all_keys = 0;
> diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh
> index dcacf84cc3..2351b772b2 100755
> --- a/t/t1900-repo.sh
> +++ b/t/t1900-repo.sh
> @@ -13,17 +13,15 @@ REPO_INFO_KEYS='
>   	path.common-dir
>   	path.config-file
>   	path.git-dir
> -	path.git-prefix
>   	path.grafts-file
>   	path.hooks-directory
>   	path.index-file
> -	path.logs-directory
>   	path.objects-directory
> -	path.packed-refs-file
> -	path.refs-directory
> +	path.prefix
>   	path.shallow-file
>   	path.superproject-working-tree
>   	path.toplevel
> +	path.work-tree
>   	references.format
>   '
>   
> @@ -31,17 +29,15 @@ REPO_INFO_PATH_KEYS='
>   	path.common-dir
>   	path.config-file
>   	path.git-dir
> -	path.git-prefix
>   	path.grafts-file
>   	path.hooks-directory
>   	path.index-file
> -	path.logs-directory
>   	path.objects-directory
> -	path.packed-refs-file
> -	path.refs-directory
> +	path.prefix
>   	path.shallow-file
>   	path.superproject-working-tree
>   	path.toplevel
> +	path.work-tree
>   '
>   
>   # Test whether a key-value pair is correctly returned
> @@ -172,12 +168,12 @@ test_expect_success 'path.toplevel is empty in bare repository' '
>   	test_cmp expect actual
>   '
>   
> -test_expect_success 'path.git-prefix matches rev-parse --show-prefix' '
> +test_expect_success 'path.prefix matches rev-parse --show-prefix' '
>   	git init path-prefix &&
>   	mkdir -p path-prefix/a/b &&
>   	expected_value=$(git -C path-prefix/a/b rev-parse --show-prefix) &&
> -	echo "path.git-prefix=$expected_value" >expect &&
> -	git -C path-prefix/a/b repo info path.git-prefix >actual &&
> +	echo "path.prefix=$expected_value" >expect &&
> +	git -C path-prefix/a/b repo info path.prefix >actual &&
>   	test_cmp expect actual
>   '
>   
> @@ -209,27 +205,27 @@ test_expect_success 'git-path style keys match rev-parse --git-path' '
>   	git -C path-git-path repo info path.config-file >actual &&
>   	test_cmp expect actual &&
>   
> -	expected_value=$(git -C path-git-path rev-parse --path-format=absolute --git-path logs) &&
> -	echo "path.logs-directory=$expected_value" >expect &&
> -	git -C path-git-path repo info path.logs-directory >actual &&
> -	test_cmp expect actual &&
> -
> -	expected_value=$(git -C path-git-path rev-parse --path-format=absolute --git-path packed-refs) &&
> -	echo "path.packed-refs-file=$expected_value" >expect &&
> -	git -C path-git-path repo info path.packed-refs-file >actual &&
> -	test_cmp expect actual &&
> -
> -	expected_value=$(git -C path-git-path rev-parse --path-format=absolute --git-path refs) &&
> -	echo "path.refs-directory=$expected_value" >expect &&
> -	git -C path-git-path repo info path.refs-directory >actual &&
> -	test_cmp expect actual &&
> -
>   	expected_value=$(git -C path-git-path rev-parse --path-format=absolute --git-path shallow) &&
>   	echo "path.shallow-file=$expected_value" >expect &&
>   	git -C path-git-path repo info path.shallow-file >actual &&
>   	test_cmp expect actual
>   '
>   
> +test_expect_success 'path.work-tree matches path.toplevel' '
> +	git init path-work-tree &&
> +	expected_value=$(git -C path-work-tree rev-parse --show-toplevel) &&
> +	echo "path.work-tree=$expected_value" >expect &&
> +	git -C path-work-tree repo info path.work-tree >actual &&
> +	test_cmp expect actual
> +'
> +
> +test_expect_success 'path.work-tree is empty in bare repository' '
> +	git init --bare bare-path-work-tree &&
> +	echo "path.work-tree=" >expect &&
> +	git -C bare-path-work-tree repo info path.work-tree >actual &&
> +	test_cmp expect actual
> +'
> +
>   test_expect_success 'path.superproject-working-tree is empty when not a submodule' '
>   	git init path-superproject &&
>   	echo "path.superproject-working-tree=" >expect &&
Previous: Lucas Seiki OshiroNext: Phillip Wood
Message 53 of 68 in “repo: extend info path reporting and structure statistics”
  1. 0/3 repo: extend info path reporting and structure statisticseslam reda via GitGitGadget, Feb 22, 2026
  2. 1/3 repo: extend info paths and structure statisticseslam-reda-div via GitGitGadget, Feb 22, 2026
  3. 2/3 t1900,t1901: make repo tests hash-agnostic and wc-portableEslam reda ragheb via GitGitGadget, Feb 22, 2026
  4. 3/3 t1900,t1901: fix test portability issuesEslam reda ragheb via GitGitGadget, Feb 22, 2026
  5. Lucas Seiki OshiroFeb 22, 2026
  6. Lucas Seiki OshiroFeb 22, 2026
  7. Junio C HamanoFeb 22, 2026
  8. Justin ToblerFeb 23, 2026
  9. 0/9 repo: extend info path reporting and structure statisticseslam reda via GitGitGadget, Feb 23, 2026
  10. 1/9 repo: teach info context and category keysEslam reda ragheb via GitGitGadget, Feb 23, 2026
  11. 2/9 repo: add path keys to repo infoEslam reda ragheb via GitGitGadget, Feb 23, 2026
  12. 4/9 repo: add structure max object size metricsEslam reda ragheb via GitGitGadget, Feb 23, 2026
  13. 5/9 repo: add structure topology and path-depth metricsEslam reda ragheb via GitGitGadget, Feb 23, 2026
  14. 6/9 repo: add aggregate structure totals to keyvalue outputEslam reda ragheb via GitGitGadget, Feb 23, 2026
  15. 7/9 t1900: cover repo info path keys and path-formatEslam reda ragheb via GitGitGadget, Feb 23, 2026
  16. 8/9 t1901: extend structure metric coverage and portabilityEslam reda ragheb via GitGitGadget, Feb 23, 2026
  17. 9/9 docs: describe repo info path keys and structure metricsEslam reda ragheb via GitGitGadget, Feb 23, 2026
  18. 0/5 repo: extend info path reporting and structure statisticseslam reda via GitGitGadget, Feb 23, 2026
  19. 1/5 repo: teach info context and category keysEslam reda ragheb via GitGitGadget, Feb 23, 2026
  20. 2/5 repo: add path keys to repo infoEslam reda ragheb via GitGitGadget, Feb 23, 2026
  21. 3/5 repo: add --path-format for info path outputEslam reda ragheb via GitGitGadget, Feb 23, 2026
  22. 4/5 t1900: cover repo info path keys and path-formatEslam reda ragheb via GitGitGadget, Feb 23, 2026
  23. 5/5 docs: describe repo info path keysEslam reda ragheb via GitGitGadget, Feb 23, 2026
  24. 00/10 repo info: add category/path keys and --path-formateslam reda via GitGitGadget, Feb 26, 2026
  25. 01/10 repo: teach info context and category keysEslam reda ragheb via GitGitGadget, Feb 26, 2026
  26. 02/10 repo: add path keys to repo infoEslam reda ragheb via GitGitGadget, Feb 26, 2026
  27. 03/10 repo: add --path-format for info path outputEslam reda ragheb via GitGitGadget, Feb 26, 2026
  28. 04/10 repo: add structure max object size metricsEslam reda ragheb via GitGitGadget, Feb 26, 2026
  29. 05/10 repo: add structure topology and path-depth metricsEslam reda ragheb via GitGitGadget, Feb 26, 2026
  30. 06/10 repo: add aggregate structure totals to keyvalue outputEslam reda ragheb via GitGitGadget, Feb 26, 2026
  31. 07/10 t1900: cover repo info path keys and path-formatEslam reda ragheb via GitGitGadget, Feb 26, 2026
  32. 08/10 t1901: extend structure metric coverage and portabilityEslam reda ragheb via GitGitGadget, Feb 26, 2026
  33. 09/10 docs: describe repo info path keys and structure metricsEslam reda ragheb via GitGitGadget, Feb 26, 2026
  34. 10/10 repo: reduce repetition in structure keyvalue outputEslam reda ragheb via GitGitGadget, Feb 26, 2026
  35. Junio C HamanoFeb 26, 2026
  36. Junio C HamanoFeb 26, 2026
  37. Phillip WoodFeb 27, 2026
  38. 00/11 repo info: add category/path keys and --path-formateslam reda via GitGitGadget, Feb 27, 2026
  39. 01/11 repo: teach info context and category keysEslam reda ragheb via GitGitGadget, Feb 27, 2026
  40. 02/11 repo: add path keys to repo infoEslam reda ragheb via GitGitGadget, Feb 27, 2026
  41. 03/11 repo: add --path-format for info path outputEslam reda ragheb via GitGitGadget, Feb 27, 2026
  42. 04/11 repo: add structure max object size metricsEslam reda ragheb via GitGitGadget, Feb 27, 2026
  43. 05/11 repo: add structure topology and path-depth metricsEslam reda ragheb via GitGitGadget, Feb 27, 2026
  44. 06/11 repo: add aggregate structure totals to keyvalue outputEslam reda ragheb via GitGitGadget, Feb 27, 2026
  45. 07/11 t1900: cover repo info path keys and path-formatEslam reda ragheb via GitGitGadget, Feb 27, 2026
  46. 08/11 t1901: extend structure metric coverage and portabilityEslam reda ragheb via GitGitGadget, Feb 27, 2026
  47. 09/11 docs: describe repo info path keys and structure metricsEslam reda ragheb via GitGitGadget, Feb 27, 2026
  48. 10/11 repo: reduce repetition in structure keyvalue outputEslam reda ragheb via GitGitGadget, Feb 27, 2026
  49. 11/11 repo: refine path keys for repo infoEslam reda ragheb via GitGitGadget, Feb 27, 2026
  50. Junio C HamanoFeb 27, 2026
  51. Lucas Seiki OshiroFeb 27, 2026
  52. Lucas Seiki OshiroFeb 27, 2026
  53. Phillip WoodMar 1, 2026
  54. Phillip WoodMar 1, 2026
  55. 0/6 repo info: add category/path keys and --path-formateslam reda via GitGitGadget, Mar 2, 2026
  56. 1/6 repo: introduce repo_info context plumbingEslam reda ragheb via GitGitGadget, Mar 2, 2026
  57. 2/6 repo: support category requests in repo infoEslam reda ragheb via GitGitGadget, Mar 2, 2026
  58. 3/6 repo: add path keys to repo infoEslam reda ragheb via GitGitGadget, Mar 2, 2026
  59. 4/6 repo: add --path-format for info path outputEslam reda ragheb via GitGitGadget, Mar 2, 2026
  60. 5/6 t1900: cover repo info path keys and path-formatEslam reda ragheb via GitGitGadget, Mar 2, 2026
  61. 6/6 docs: describe repo info path keysEslam reda ragheb via GitGitGadget, Mar 2, 2026
  62. Junio C HamanoMar 2, 2026
  63. Jialong WangMar 18, 2026
  64. K JayatheerthMar 19, 2026
  65. Jerry WangMar 19, 2026
  66. t1900: cover repo info path keys in non-default layoutsJialong Wang, Mar 19, 2026
  67. Jialong WangMar 19, 2026
  68. K JayatheerthMar 20, 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.