🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.git
16 messages
16 total messages Started by K Jayatheerth Sat, 07 Nov 2026 16:00
[GSoC Patch v8 0/7] repo: add path keys to repo info
#2610
Author: K Jayatheerth
Date: Sat, 07 Nov 2026 16:00
463 lines
31420 bytes
This patch series continues the work to expose repository paths and
metadata via the `git repo info` command. It introduces several keys for
querying repository paths in standard absolute and relative formats, as well
as refactoring `get_superproject_working_tree()` to operate on a `struct
repository *`.

The path keys added in this series are:
  - `path.toplevel.absolute` / `path.toplevel.relative`: The root directory
    of the working tree (or an empty string in bare repositories).
  - `path.superproject-root.absolute` / `path.superproject-root.relative`:
    The root of the superproject when inside a submodule.
  - `path.hooks.absolute` / `path.hooks.relative`: The repository's hooks
    directory (respecting `core.hooksPath`, including `/dev/null`).
  - `path.index.absolute` / `path.index.relative`: The repository's active
    index file.
  - `path.git-prefix`: The prefix from the worktree root to the current
    working directory.
  - `path.cdup`: The relative path from the current directory up to the
    worktree root.

Changes since v7:
  - Dropped `path.grafts`.
  - In patch 2 (`submodule: use repository to find superproject`), moved the
    test for `--git-dir` to `t/t1500-rev-parse.sh` exercising the existing
    `rev-parse --show-superproject-working-tree` interface (since
    `path.superproject-root` is only added in patch 3), and ensured clean
    isolation of test directories (`sub` and `super`).
  - In patch 3 (`path.superproject-root`), simplified the getter functions
    by eliminating redundant early returns.
  - In patch 4 (`path.hooks`):
    - Special-cased `/dev/null` in both `path.hooks.absolute` and
      `path.hooks.relative` to output `/dev/null` directly, making it easy
      for scripts to detect when hooks are disabled. Documented this
      behavior in `Documentation/git-repo.adoc`.
    - Reverted changes to the `test_repo_info_path` helper in
      `t/t1900-repo-info.sh` and wrote a standalone test block for the
      `/dev/null` case.
    - Set `hooksPath = /dev/null` directly in the config file rather than
      passing it through `git config core.hooksPath /dev/null` to prevent
      MSYS2 argument mangling on Windows (which rewrites `/dev/null` to
      `nul`), allowing the test to run portably on all platforms without
      requiring `!MINGW`.
  - In patch 7 (`path.cdup`), removed unnecessary braces on the single-line
    `if`, added an early return when invoked outside a worktree, and ensured
    `cd repo` in the test runs within a subshell.

Thanks to Justin Tobler and Lucas Seiki Oshiro for their reviews and
mentorship.

K Jayatheerth (7):
  repo: add path.toplevel with absolute and relative suffix formatting
  submodule: use repository to find superproject
  repo: add path.superproject-root with absolute and relative suffixes
  repo: add path.hooks with absolute and relative suffixes
  repo: add path.index with absolute and relative suffixes
  repo: add path.git-prefix
  repo: add path.cdup

 Documentation/git-repo.adoc |  52 ++++++++++
 builtin/repo.c              | 131 +++++++++++++++++++++++++
 builtin/rev-parse.c         |   2 +-
 submodule.c                 |  43 +++++----
 submodule.h                 |   2 +-
 t/t1500-rev-parse.sh        |  20 ++++
 t/t1900-repo-info.sh        | 185 ++++++++++++++++++++++++++++++++++++
 7 files changed, 412 insertions(+), 23 deletions(-)

Range-diff against v7:
5:  351b4b7de7 ! 1:  27b9811163 repo: add path.grafts with absolute and relative suffixes
    @@ Metadata
     Author: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
     
      ## Commit message ##
    -    repo: add path.grafts with absolute and relative suffixes
    +    repo: add path.toplevel with absolute and relative suffix formatting
     
    -    The repository grafts file specifies alternate parent relationships for
    -    commits and may be used by repository tooling that needs to inspect or
    -    manage grafts. Scripts currently retrieve its location by invoking
    -    `git rev-parse --git-path info/grafts`.
    +    Scripts frequently need to find the root directory of a repository's
    +    working tree. Currently, this requires using `git rev-parse --show-toplevel`
    +    or inferring it from other repository information.
     
    -    Introduce `path.grafts.absolute` and `path.grafts.relative` keys to
    -    `git repo info`. This exposes the grafts file location as a scriptable
    -    config-like key using standard format rules, allowing scripts to
    -    retrieve it through the same interface as other repository path
    -    information.
    +    Introduce `path.toplevel.absolute` and `path.toplevel.relative` keys
    +    to `git repo info`. This allows scripts to retrieve the top-level
    +    working tree path in a predictable, strictly formatted manner without
    +    relying on `rev-parse`.
    +
    +    If requested in a bare repository where no working tree exists, the
    +    command returns an empty string.
     
         Mentored-by: Justin Tobler <jltobler@gmail.com>
         Mentored-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
    @@ Documentation/git-repo.adoc: values that they return:
      `path.gitdir.relative`::
      	The path to the Git repository directory relative to the current working directory.
      
    -+`path.grafts.absolute`::
    -+	The canonical absolute path to the repository's graft file.
    -+	Respects the `GIT_GRAFT_FILE` environment override. The path is
    -+	returned regardless of whether the file currently exists on disk.
    ++`path.toplevel.absolute`::
    ++	The canonical absolute path to the top-level directory of the
    ++	repository's working tree. Outputs an empty string if the repository
    ++	is bare.
     +
    -+`path.grafts.relative`::
    -+	The path to the repository's graft file relative to the current
    -+	working directory. Respects the `GIT_GRAFT_FILE` environment
    -+	override. The path is returned regardless of whether the file
    -+	currently exists on disk.
    ++`path.toplevel.relative`::
    ++	The path to the top-level directory of the repository's working
    ++	tree relative to the current working directory. Outputs an empty
    ++	string if the repository is bare.
     +
    - `path.hooks.absolute`::
    - 	The canonical absolute path to the repository's hooks directory.
    - 	Respects the `core.hooksPath` configuration. If `core.hooksPath` is
    + `references.format`::
    + 	The reference storage format. The valid values are:
    + +
     
      ## builtin/repo.c ##
     @@ builtin/repo.c: static int get_path_gitdir_relative(struct repository *repo, struct strbuf *buf)
      	return 0;
      }
      
    -+static int get_path_grafts_absolute(struct repository *repo, struct strbuf *buf)
    ++static int get_path_toplevel_absolute(struct repository *repo, struct strbuf *buf)
     +{
    -+	const char *graft_file = repo_get_graft_file(repo);
    ++	const char *work_tree = repo_get_work_tree(repo);
     +
    -+	if (!graft_file)
    -+		return error(_("unable to get graft file"));
    ++	if (!work_tree)
    ++		return 0;
     +
    -+	format_path(buf, graft_file, "", PATH_FORMAT_CANONICAL);
    ++	format_path(buf, work_tree, "", PATH_FORMAT_CANONICAL);
     +	return 0;
     +}
     +
    -+static int get_path_grafts_relative(struct repository *repo, struct strbuf *buf)
    ++static int get_path_toplevel_relative(struct repository *repo, struct strbuf *buf)
     +{
    -+	const char *graft_file = repo_get_graft_file(repo);
    ++	const char *work_tree = repo_get_work_tree(repo);
     +
    -+	if (!graft_file)
    -+		return error(_("unable to get graft file"));
    ++	if (!work_tree)
    ++		return 0;
     +
    -+	format_path(buf, graft_file, repo->prefix, PATH_FORMAT_RELATIVE);
    ++	format_path(buf, work_tree, repo->prefix, PATH_FORMAT_RELATIVE);
     +	return 0;
     +}
     +
    - static int get_path_hooks_absolute(struct repository *repo, struct strbuf *buf)
    + static int get_references_format(struct repository *repo, struct strbuf *buf)
      {
    - 	struct strbuf hooks_path = STRBUF_INIT;
    + 	strbuf_addstr(buf,
     @@ builtin/repo.c: static const struct repo_info_field repo_info_field[] = {
      	{ "path.commondir.relative", get_path_commondir_relative },
      	{ "path.gitdir.absolute", get_path_gitdir_absolute },
      	{ "path.gitdir.relative", get_path_gitdir_relative },
    -+	{ "path.grafts.absolute", get_path_grafts_absolute },
    -+	{ "path.grafts.relative", get_path_grafts_relative },
    - 	{ "path.hooks.absolute", get_path_hooks_absolute },
    - 	{ "path.hooks.relative", get_path_hooks_relative },
    - 	{ "path.index.absolute", get_path_index_absolute },
    ++	{ "path.toplevel.absolute", get_path_toplevel_absolute },
    ++	{ "path.toplevel.relative", get_path_toplevel_relative },
    + 	{ "references.format", get_references_format },
    + };
    + 
     
      ## t/t1900-repo-info.sh ##
     @@ t/t1900-repo-info.sh: test_repo_info_path 'gitdir with explicit GIT_DIR' 'gitdir' \
      	'.git' \
      	'GIT_DIR="../.git" && export GIT_DIR'
      
    -+test_repo_info_path 'grafts standard' 'grafts' '.git/info/grafts'
    ++test_expect_success 'path.toplevel absolute and relative' '
    ++	test_when_finished "rm -rf repo" &&
    ++	git init repo &&
    ++	(
    ++		mkdir -p repo/sub &&
    ++		cd repo/sub &&
     +
    -+test_repo_info_path 'grafts with GIT_GRAFT_FILE override' 'grafts' \
    -+	'custom-graft-file' \
    -+	'GIT_GRAFT_FILE="$ROOT/custom-graft-file" && export GIT_GRAFT_FILE'
    ++		ROOT="$(test-tool path-utils real_path ..)" &&
     +
    - test_repo_info_path 'hooks standard' 'hooks' '.git/hooks'
    - 
    - test_repo_info_path 'hooks with core.hooksPath override' 'hooks' \
    ++		echo "path.toplevel.absolute=$ROOT" >expect.abs &&
    ++		git repo info path.toplevel.absolute >actual.abs &&
    ++		test_cmp expect.abs actual.abs &&
    ++
    ++		echo "path.toplevel.relative=../" >expect.rel &&
    ++		git repo info path.toplevel.relative >actual.rel &&
    ++		test_cmp expect.rel actual.rel
    ++	)
    ++'
    ++
    ++test_expect_success 'path.toplevel absolute and relative in a bare repository' '
    ++	test_when_finished "rm -rf bare.git" &&
    ++	git init --bare bare.git &&
    ++	(
    ++		cd bare.git &&
    ++
    ++		echo "path.toplevel.absolute=" >expect.abs &&
    ++		git repo info path.toplevel.absolute >actual.abs &&
    ++		test_cmp expect.abs actual.abs &&
    ++
    ++		echo "path.toplevel.relative=" >expect.rel &&
    ++		git repo info path.toplevel.relative >actual.rel &&
    ++		test_cmp expect.rel actual.rel
    ++	)
    ++'
    ++
    + test_done
1:  7c90603a1b ! 2:  2274dd8be2 submodule: use repository to find superproject
    @@ submodule.h: void absorb_git_dir_into_superproject(const char *path,
      
      #endif
     
    - ## t/t7400-submodule-basic.sh ##
    -@@ t/t7400-submodule-basic.sh: test_expect_success 'submodule add fails when name is reused' '
    + ## t/t1500-rev-parse.sh ##
    +@@ t/t1500-rev-parse.sh: test_expect_success ':/ and HEAD^{/} favor more recent matching commits' '
      	)
      '
      
    -+test_expect_success 'path.superproject-root works with --git-dir' '
    ++test_expect_success '--show-superproject-working-tree works with --git-dir' '
    ++	rm -rf sub super &&
     +	test_when_finished "rm -rf sub super" &&
     +	git init sub &&
     +	test_commit -C sub initial &&
    @@ t/t7400-submodule-basic.sh: test_expect_success 'submodule add fails when name i
     +		SUPER_ROOT="$(test-tool path-utils real_path .)" &&
     +		MODULE_DIR="$SUPER_ROOT/.git/modules/sub" &&
     +
    -+		echo "path.superproject-root.absolute=$SUPER_ROOT" >expect &&
    -+		git --git-dir="$MODULE_DIR" repo info path.superproject-root.absolute >actual &&
    ++		echo "$SUPER_ROOT" >expect &&
    ++		git --git-dir="$MODULE_DIR" rev-parse --show-superproject-working-tree >actual &&
     +		test_cmp expect actual
     +	)
     +'
2:  1bfb0c8c1d ! 3:  34c54cdafd repo: add path.superproject-root with absolute and relative suffixes
    @@ builtin/repo.c: static int get_path_gitdir_relative(struct repository *repo, str
     +{
     +	struct strbuf superproject = STRBUF_INIT;
     +
    -+	if (!get_superproject_working_tree(repo, &superproject)) {
    -+		strbuf_release(&superproject);
    -+		return 0;
    -+	}
    ++	if (get_superproject_working_tree(repo, &superproject))
    ++		format_path(buf, superproject.buf, "", PATH_FORMAT_CANONICAL);
     +
    -+	format_path(buf, superproject.buf, "", PATH_FORMAT_CANONICAL);
     +	strbuf_release(&superproject);
     +	return 0;
     +}
    @@ builtin/repo.c: static int get_path_gitdir_relative(struct repository *repo, str
     +{
     +	struct strbuf superproject = STRBUF_INIT;
     +
    -+	if (!get_superproject_working_tree(repo, &superproject)) {
    -+		strbuf_release(&superproject);
    -+		return 0;
    -+	}
    ++	if (get_superproject_working_tree(repo, &superproject))
    ++		format_path(buf, superproject.buf, repo->prefix, PATH_FORMAT_RELATIVE);
     +
    -+	format_path(buf, superproject.buf, repo->prefix, PATH_FORMAT_RELATIVE);
     +	strbuf_release(&superproject);
     +	return 0;
     +}
3:  09d2937fcd ! 4:  985403c7b3 repo: add path.hooks with absolute and relative suffixes
    @@ Documentation/git-repo.adoc: values that they return:
     +
     +`path.hooks.relative`::
     +	The path to the repository's hooks directory relative to the current
    -+	working directory. Respects the `core.hooksPath` configuration.
    ++	working directory. Respects the `core.hooksPath` configuration. If
    ++	`core.hooksPath` is set to `/dev/null`, that value is returned unchanged.
     +
      `path.superproject-root.absolute`::
      	The canonical absolute path to the working tree root of the superproject
    @@ builtin/repo.c: static int get_path_gitdir_relative(struct repository *repo, str
     +	struct strbuf hooks_path = STRBUF_INIT;
     +
     +	repo_git_path_replace(repo, &hooks_path, "hooks");
    -+	format_path(buf, hooks_path.buf, "", PATH_FORMAT_CANONICAL);
    ++	if (!strcmp(hooks_path.buf, "/dev/null"))
    ++		strbuf_addstr(buf, "/dev/null");
    ++	else
    ++		format_path(buf, hooks_path.buf, "", PATH_FORMAT_CANONICAL);
    ++
     +	strbuf_release(&hooks_path);
     +	return 0;
     +}
    @@ builtin/repo.c: static int get_path_gitdir_relative(struct repository *repo, str
     +	struct strbuf hooks_path = STRBUF_INIT;
     +
     +	repo_git_path_replace(repo, &hooks_path, "hooks");
    -+	format_path(buf, hooks_path.buf, repo->prefix, PATH_FORMAT_RELATIVE);
    ++	if (!strcmp(hooks_path.buf, "/dev/null"))
    ++		strbuf_addstr(buf, "/dev/null");
    ++	else
    ++		format_path(buf, hooks_path.buf, repo->prefix, PATH_FORMAT_RELATIVE);
    ++
     +	strbuf_release(&hooks_path);
     +	return 0;
     +}
    @@ builtin/repo.c: static const struct repo_info_field repo_info_field[] = {
      	{ "path.toplevel.absolute", get_path_toplevel_absolute },
     
      ## t/t1900-repo-info.sh ##
    -@@ t/t1900-repo-info.sh: test_repo_info_path () {
    - 			cd repo/sub &&
    - 			ROOT="$(test-tool path-utils real_path ..)" && export ROOT &&
    - 			eval "$init_command" &&
    --			echo "path.$field_name.absolute=$ROOT/$expected_dir" >expect &&
    -+			case "$expected_dir" in
    -+			/*) EXPECT_ABS="$expected_dir" ;;
    -+			*) EXPECT_ABS="$ROOT/$expected_dir" ;;
    -+			esac &&
    -+			echo "path.$field_name.absolute=$EXPECT_ABS" >expect &&
    - 			git repo info "path.$field_name.absolute" >actual &&
    - 			test_cmp expect actual
    - 		)
    -@@ t/t1900-repo-info.sh: test_repo_info_path () {
    - 			cd repo/sub &&
    - 			ROOT="$(test-tool path-utils real_path ..)" && export ROOT &&
    - 			eval "$init_command" &&
    --			echo "path.$field_name.relative=../$expected_dir" >expect &&
    -+			case "$expected_dir" in
    -+			/*) EXPECT_REL="$(test-tool path-utils relative_path "$expected_dir" "$PWD")" ;;
    -+			*) EXPECT_REL="../$expected_dir" ;;
    -+			esac &&
    -+			echo "path.$field_name.relative=$EXPECT_REL" >expect &&
    - 			git repo info "path.$field_name.relative" >actual &&
    - 			test_cmp expect actual
    - 		)
     @@ t/t1900-repo-info.sh: test_repo_info_path 'gitdir with explicit GIT_DIR' 'gitdir' \
      	'.git' \
      	'GIT_DIR="../.git" && export GIT_DIR'
    @@ t/t1900-repo-info.sh: test_repo_info_path 'gitdir with explicit GIT_DIR' 'gitdir
     +	'custom-hooks' \
     +	'git config core.hooksPath "$ROOT/custom-hooks" && mkdir -p "$ROOT/custom-hooks"'
     +
    -+# /dev/null is not a real, canonicalizable filesystem path on Windows,
    -+# so path resolution for core.hooksPath=/dev/null cannot be expected to
    -+# produce a literal "/dev/null" the way it does on POSIX systems.
    -+if ! test_have_prereq MINGW
    -+then
    -+	test_repo_info_path 'hooks with core.hooksPath=/dev/null' 'hooks' \
    -+		'/dev/null' \
    -+		'git config core.hooksPath /dev/null'
    -+fi
    ++test_expect_success 'hooks with core.hooksPath=/dev/null' '
    ++	test_when_finished "rm -rf repo" &&
    ++	git init repo &&
    ++	(
    ++		mkdir -p repo/sub &&
    ++		cd repo/sub &&
    ++		cat >>../.git/config <<-\EOF &&
    ++		[core]
    ++			hooksPath = /dev/null
    ++		EOF
    ++		echo "path.hooks.absolute=/dev/null" >expect.abs &&
    ++		echo "path.hooks.relative=/dev/null" >expect.rel &&
    ++		git repo info path.hooks.absolute >actual.abs &&
    ++		git repo info path.hooks.relative >actual.rel &&
    ++		test_cmp expect.abs actual.abs &&
    ++		test_cmp expect.rel actual.rel
    ++	)
    ++'
     +
      test_expect_success 'path.superproject-root absolute and relative' '
      	test_when_finished "rm -rf sub super" &&
4:  d0c186f150 ! 5:  486836ae52 repo: add path.index with absolute and relative suffixes
    @@ Commit message
     
      ## Documentation/git-repo.adoc ##
     @@ Documentation/git-repo.adoc: values that they return:
    - 	The path to the repository's hooks directory relative to the current
    - 	working directory. Respects the `core.hooksPath` configuration.
    + 	working directory. Respects the `core.hooksPath` configuration. If
    + 	`core.hooksPath` is set to `/dev/null`, that value is returned unchanged.
      
     +`path.index.absolute`::
     +	The canonical absolute path to the repository's current index file.
    @@ builtin/repo.c: static const struct repo_info_field repo_info_field[] = {
      	{ "path.toplevel.absolute", get_path_toplevel_absolute },
     
      ## t/t1900-repo-info.sh ##
    -@@ t/t1900-repo-info.sh: then
    - 		'git config core.hooksPath /dev/null'
    - fi
    +@@ t/t1900-repo-info.sh: test_expect_success 'hooks with core.hooksPath=/dev/null' '
    + 	)
    + '
      
     +test_repo_info_path 'index standard' 'index' '.git/index'
     +
6:  ef69d4aa8c ! 6:  91a8dc3ab1 repo: add path.git-prefix
    @@ builtin/repo.c: static const struct repo_info_field repo_info_field[] = {
     +	{ "path.git-prefix", get_path_git_prefix },
      	{ "path.gitdir.absolute", get_path_gitdir_absolute },
      	{ "path.gitdir.relative", get_path_gitdir_relative },
    - 	{ "path.grafts.absolute", get_path_grafts_absolute },
    + 	{ "path.hooks.absolute", get_path_hooks_absolute },
     
      ## t/t1900-repo-info.sh ##
     @@ t/t1900-repo-info.sh: test_repo_info_path 'commondir with only GIT_DIR' 'commondir' \
7:  3e61728dba ! 7:  84a9fb4060 repo: add path.cdup
    @@ builtin/repo.c: static int get_object_format(struct repository *repo, struct str
     +	if (!is_inside_work_tree(repo)) {
     +		const char *worktree = repo_get_work_tree(repo);
     +
    -+		if (worktree) {
    ++		if (worktree)
     +			strbuf_addstr(buf, worktree);
    -+		}
    ++		return 0;
     +	}
     +
     +	while (pfx) {
    @@ t/t1900-repo-info.sh: test_repo_info_path 'commondir with only GIT_DIR' 'commond
     +test_expect_success 'path.cdup cwd outside the working tree' '
     +	test_when_finished "rm -rf repo" &&
     +	mkdir -p repo/tmp/x &&
    -+	cd repo &&
    -+	git init test &&
     +	(
    -+		echo path.cdup=$(pwd)/tmp/x >./test/expect &&
    ++		cd repo &&
    ++		git init test &&
    ++		echo "path.cdup=$(pwd)/tmp/x" >test/expect &&
     +		cd test &&
     +		GIT_WORK_TREE=../tmp/x &&
     +		export GIT_WORK_TREE &&
-- 
2.56.0-rc2
[GSoC Patch v8 1/7] repo: add path.toplevel with absolute and relative suffix formatting
#2604
Author: K Jayatheerth
Date: Sat, 07 Nov 2026 16:00
131 lines
15098 bytes
Scripts frequently need to find the root directory of a repository's
working tree. Currently, this requires using `git rev-parse --show-toplevel`
or inferring it from other repository information.

Introduce `path.toplevel.absolute` and `path.toplevel.relative` keys
to `git repo info`. This allows scripts to retrieve the top-level
working tree path in a predictable, strictly formatted manner without
relying on `rev-parse`.

If requested in a bare repository where no working tree exists, the
command returns an empty string.

Mentored-by: Justin Tobler <jltobler@gmail.com>
Mentored-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
---
 Documentation/git-repo.adoc | 10 ++++++++++
 builtin/repo.c              | 24 ++++++++++++++++++++++++
 t/t1900-repo-info.sh        | 35 +++++++++++++++++++++++++++++++++++
 3 files changed, 69 insertions(+)

diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
index ed7d80c690..e34abe5fea 100644
--- a/Documentation/git-repo.adoc
+++ b/Documentation/git-repo.adoc
@@ -119,6 +119,16 @@ values that they return:
 `path.gitdir.relative`::
 	The path to the Git repository directory relative to the current working directory.
 
+`path.toplevel.absolute`::
+	The canonical absolute path to the top-level directory of the
+	repository's working tree. Outputs an empty string if the repository
+	is bare.
+
+`path.toplevel.relative`::
+	The path to the top-level directory of the repository's working
+	tree relative to the current working directory. Outputs an empty
+	string if the repository is bare.
+
 `references.format`::
 	The reference storage format. The valid values are:
 +
diff --git a/builtin/repo.c b/builtin/repo.c
index 84e012f83f..c31e9cfa70 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -121,6 +121,28 @@ static int get_path_gitdir_relative(struct repository *repo, struct strbuf *buf)
 	return 0;
 }
 
+static int get_path_toplevel_absolute(struct repository *repo, struct strbuf *buf)
+{
+	const char *work_tree = repo_get_work_tree(repo);
+
+	if (!work_tree)
+		return 0;
+
+	format_path(buf, work_tree, "", PATH_FORMAT_CANONICAL);
+	return 0;
+}
+
+static int get_path_toplevel_relative(struct repository *repo, struct strbuf *buf)
+{
+	const char *work_tree = repo_get_work_tree(repo);
+
+	if (!work_tree)
+		return 0;
+
+	format_path(buf, work_tree, repo->prefix, PATH_FORMAT_RELATIVE);
+	return 0;
+}
+
 static int get_references_format(struct repository *repo, struct strbuf *buf)
 {
 	strbuf_addstr(buf,
@@ -137,6 +159,8 @@ static const struct repo_info_field repo_info_field[] = {
 	{ "path.commondir.relative", get_path_commondir_relative },
 	{ "path.gitdir.absolute", get_path_gitdir_absolute },
 	{ "path.gitdir.relative", get_path_gitdir_relative },
+	{ "path.toplevel.absolute", get_path_toplevel_absolute },
+	{ "path.toplevel.relative", get_path_toplevel_relative },
 	{ "references.format", get_references_format },
 };
 
diff --git a/t/t1900-repo-info.sh b/t/t1900-repo-info.sh
index c85d390f43..9417d1ab65 100755
--- a/t/t1900-repo-info.sh
+++ b/t/t1900-repo-info.sh
@@ -213,4 +213,39 @@ test_repo_info_path 'gitdir with explicit GIT_DIR' 'gitdir' \
 	'.git' \
 	'GIT_DIR="../.git" && export GIT_DIR'
 
+test_expect_success 'path.toplevel absolute and relative' '
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		mkdir -p repo/sub &&
+		cd repo/sub &&
+
+		ROOT="$(test-tool path-utils real_path ..)" &&
+
+		echo "path.toplevel.absolute=$ROOT" >expect.abs &&
+		git repo info path.toplevel.absolute >actual.abs &&
+		test_cmp expect.abs actual.abs &&
+
+		echo "path.toplevel.relative=../" >expect.rel &&
+		git repo info path.toplevel.relative >actual.rel &&
+		test_cmp expect.rel actual.rel
+	)
+'
+
+test_expect_success 'path.toplevel absolute and relative in a bare repository' '
+	test_when_finished "rm -rf bare.git" &&
+	git init --bare bare.git &&
+	(
+		cd bare.git &&
+
+		echo "path.toplevel.absolute=" >expect.abs &&
+		git repo info path.toplevel.absolute >actual.abs &&
+		test_cmp expect.abs actual.abs &&
+
+		echo "path.toplevel.relative=" >expect.rel &&
+		git repo info path.toplevel.relative >actual.rel &&
+		test_cmp expect.rel actual.rel
+	)
+'
+
 test_done
-- 
2.56.0-rc2
[GSoC Patch v8 2/7] submodule: use repository to find superproject
#2615
Author: K Jayatheerth
Date: Sat, 07 Nov 2026 16:00
187 lines
16999 bytes
`get_superproject_working_tree()` currently uses `xgetcwd()` to
determine the repository whose superproject should be checked.

This is incorrect when `--git-dir` points to a repository different
from the one associated with the current working directory. In that
case, the current working directory may cause the function to return
the wrong superproject or an empty result.

Pass the `repository` to `get_superproject_working_tree()` so that the
superproject is determined from the repository being inspected rather
than the current working directory.

Mentored-by: Justin Tobler <jltobler@gmail.com>
Mentored-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
---
 builtin/rev-parse.c  |  2 +-
 submodule.c          | 43 ++++++++++++++++++++++---------------------
 submodule.h          |  2 +-
 t/t1500-rev-parse.sh | 20 ++++++++++++++++++++
 4 files changed, 44 insertions(+), 23 deletions(-)

diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 43693454d5..e1a6da0076 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -997,7 +997,7 @@ int cmd_rev_parse(int argc,
 			}
 			if (!strcmp(arg, "--show-superproject-working-tree")) {
 				struct strbuf superproject = STRBUF_INIT;
-				if (get_superproject_working_tree(&superproject))
+				if (get_superproject_working_tree(the_repository, &superproject))
 					print_path(superproject.buf, prefix, format, DEFAULT_UNMODIFIED);
 				strbuf_release(&superproject);
 				continue;
diff --git a/submodule.c b/submodule.c
index 6fcb606f7e..4db90ef9b0 100644
--- a/submodule.c
+++ b/submodule.c
@@ -2610,34 +2610,35 @@ void absorb_git_dir_into_superproject(const char *path,
 	absorb_git_dir_into_superproject_recurse(path, super_prefix);
 }
 
-int get_superproject_working_tree(struct strbuf *buf)
+int get_superproject_working_tree(struct repository *r, struct strbuf *buf)
 {
 	struct child_process cp = CHILD_PROCESS_INIT;
 	struct strbuf sb = STRBUF_INIT;
 	struct strbuf one_up = STRBUF_INIT;
-	char *cwd = xgetcwd();
+	struct strbuf target_wt = STRBUF_INIT;
+	const char *worktree;
 	int ret = 0;
 	const char *subpath;
 	int code;
 	ssize_t len;
 
-	if (!is_inside_work_tree(the_repository))
-		/*
-		 * FIXME:
-		 * We might have a superproject, but it is harder
-		 * to determine.
-		 */
+	worktree = repo_get_work_tree(r);
+	if (!worktree)
+		goto out;
+
+	if (!strbuf_realpath(&target_wt, worktree, 0))
 		goto out;
 
-	if (!strbuf_realpath(&one_up, "../", 0))
+	strbuf_addf(&one_up, "%s/..", target_wt.buf);
+	if (!strbuf_realpath(&one_up, one_up.buf, 0))
 		goto out;
 
-	subpath = relative_path(cwd, one_up.buf, &sb);
+	subpath = relative_path(target_wt.buf, one_up.buf, &sb);
 
 	prepare_submodule_repo_env(&cp.env);
 	strvec_pop(&cp.env);
 
-	strvec_pushl(&cp.args, "--literal-pathspecs", "-C", "..",
+	strvec_pushl(&cp.args, "--literal-pathspecs", "-C", one_up.buf,
 		     "ls-files", "-z", "--stage", "--full-name", "--",
 		     subpath, NULL);
 	strbuf_reset(&sb);
@@ -2648,14 +2649,14 @@ int get_superproject_working_tree(struct strbuf *buf)
 	cp.git_cmd = 1;
 
 	if (start_command(&cp))
-		die(_("could not start ls-files in .."));
+		die(_("could not start ls-files in %s"), one_up.buf);
 
 	len = strbuf_read(&sb, cp.out, PATH_MAX);
 	close(cp.out);
 
 	if (starts_with(sb.buf, "160000")) {
 		int super_sub_len;
-		int cwd_len = strlen(cwd);
+		int wt_len = target_wt.len;
 		char *super_sub, *super_wt;
 
 		/*
@@ -2666,12 +2667,12 @@ int get_superproject_working_tree(struct strbuf *buf)
 		super_sub = strchr(sb.buf, '\t') + 1;
 		super_sub_len = strlen(super_sub);
 
-		if (super_sub_len > cwd_len ||
-		    strcmp(&cwd[cwd_len - super_sub_len], super_sub))
-			BUG("returned path string doesn't match cwd?");
+		if (super_sub_len > wt_len ||
+		    strcmp(&target_wt.buf[wt_len - super_sub_len], super_sub))
+			BUG("returned path string doesn't match worktree?");
 
-		super_wt = xstrdup(cwd);
-		super_wt[cwd_len - super_sub_len] = '\0';
+		super_wt = xstrdup(target_wt.buf);
+		super_wt[wt_len - super_sub_len] = '\0';
 
 		strbuf_realpath(buf, super_wt, 1);
 		ret = 1;
@@ -2681,10 +2682,10 @@ int get_superproject_working_tree(struct strbuf *buf)
 	code = finish_command(&cp);
 
 	if (code == 128)
-		/* '../' is not a git repository */
+		/* parent directory is not a git repository */
 		ret = 0;
 	else if (code == 0 && len == 0)
-		/* There is an unrelated git repository at '../' */
+		/* There is an unrelated git repository at parent directory */
 		ret = 0;
 	else if (code)
 		die(_("ls-tree returned unexpected return code %d"), code);
@@ -2692,7 +2693,7 @@ int get_superproject_working_tree(struct strbuf *buf)
 out:
 	strbuf_release(&sb);
 	strbuf_release(&one_up);
-	free(cwd);
+	strbuf_release(&target_wt);
 	return ret;
 }
 
diff --git a/submodule.h b/submodule.h
index b10e16e6c0..1a465a1208 100644
--- a/submodule.h
+++ b/submodule.h
@@ -170,6 +170,6 @@ void absorb_git_dir_into_superproject(const char *path,
  * project is a submodule of. If this repository is not a submodule of
  * another repository, return 0.
  */
-int get_superproject_working_tree(struct strbuf *buf);
+int get_superproject_working_tree(struct repository *r, struct strbuf *buf);
 
 #endif
diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
index 4174ca40c3..98e139f478 100755
--- a/t/t1500-rev-parse.sh
+++ b/t/t1500-rev-parse.sh
@@ -383,4 +383,24 @@ test_expect_success ':/ and HEAD^{/} favor more recent matching commits' '
 	)
 '
 
+test_expect_success '--show-superproject-working-tree works with --git-dir' '
+	rm -rf sub super &&
+	test_when_finished "rm -rf sub super" &&
+	git init sub &&
+	test_commit -C sub initial &&
+	git init super &&
+	(
+		cd super &&
+		git -c protocol.file.allow=always submodule add "../sub" sub &&
+		git commit -m "add submodule" &&
+
+		SUPER_ROOT="$(test-tool path-utils real_path .)" &&
+		MODULE_DIR="$SUPER_ROOT/.git/modules/sub" &&
+
+		echo "$SUPER_ROOT" >expect &&
+		git --git-dir="$MODULE_DIR" rev-parse --show-superproject-working-tree >actual &&
+		test_cmp expect actual
+	)
+'
+
 test_done
-- 
2.56.0-rc2
[GSoC Patch v8 3/7] repo: add path.superproject-root with absolute and relative suffixes
#2607
Author: K Jayatheerth
Date: Sat, 07 Nov 2026 16:00
146 lines
16078 bytes
Scripts working in multi-repository setups often need to identify the
top-level working tree of a superproject from within a submodule.
Currently, this is only exposed via `git rev-parse
--show-superproject-working-tree`.

Introduce `path.superproject-root.absolute` and
`path.superproject-root.relative` keys to `git repo info`.
This exposes the core submodule context via a scriptable config-like key
using standard format rules.

If requested when not inside a submodule, the command returns an empty
string.

Mentored-by: Justin Tobler <jltobler@gmail.com>
Mentored-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
---
 Documentation/git-repo.adoc | 10 ++++++++++
 builtin/repo.c              | 25 ++++++++++++++++++++++++
 t/t1900-repo-info.sh        | 39 +++++++++++++++++++++++++++++++++++++
 3 files changed, 74 insertions(+)

diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
index e34abe5fea..e524a07f53 100644
--- a/Documentation/git-repo.adoc
+++ b/Documentation/git-repo.adoc
@@ -119,6 +119,16 @@ values that they return:
 `path.gitdir.relative`::
 	The path to the Git repository directory relative to the current working directory.
 
+`path.superproject-root.absolute`::
+	The canonical absolute path to the working tree root of the superproject
+	if the current repository is an initialized submodule. Outputs an empty
+	string if not in a submodule.
+
+`path.superproject-root.relative`::
+	The path to the working tree root of the superproject relative to the
+	current working directory if the current repository is an initialized
+	submodule. Outputs an empty string if not in a submodule.
+
 `path.toplevel.absolute`::
 	The canonical absolute path to the top-level directory of the
 	repository's working tree. Outputs an empty string if the repository
diff --git a/builtin/repo.c b/builtin/repo.c
index c31e9cfa70..c17a8a3b35 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -18,6 +18,7 @@
 #include "strbuf.h"
 #include "string-list.h"
 #include "shallow.h"
+#include "submodule.h"
 #include "tree.h"
 #include "tree-walk.h"
 #include "utf8.h"
@@ -121,6 +122,28 @@ static int get_path_gitdir_relative(struct repository *repo, struct strbuf *buf)
 	return 0;
 }
 
+static int get_path_superproject_absolute(struct repository *repo, struct strbuf *buf)
+{
+	struct strbuf superproject = STRBUF_INIT;
+
+	if (get_superproject_working_tree(repo, &superproject))
+		format_path(buf, superproject.buf, "", PATH_FORMAT_CANONICAL);
+
+	strbuf_release(&superproject);
+	return 0;
+}
+
+static int get_path_superproject_relative(struct repository *repo, struct strbuf *buf)
+{
+	struct strbuf superproject = STRBUF_INIT;
+
+	if (get_superproject_working_tree(repo, &superproject))
+		format_path(buf, superproject.buf, repo->prefix, PATH_FORMAT_RELATIVE);
+
+	strbuf_release(&superproject);
+	return 0;
+}
+
 static int get_path_toplevel_absolute(struct repository *repo, struct strbuf *buf)
 {
 	const char *work_tree = repo_get_work_tree(repo);
@@ -159,6 +182,8 @@ static const struct repo_info_field repo_info_field[] = {
 	{ "path.commondir.relative", get_path_commondir_relative },
 	{ "path.gitdir.absolute", get_path_gitdir_absolute },
 	{ "path.gitdir.relative", get_path_gitdir_relative },
+	{ "path.superproject-root.absolute", get_path_superproject_absolute },
+	{ "path.superproject-root.relative", get_path_superproject_relative },
 	{ "path.toplevel.absolute", get_path_toplevel_absolute },
 	{ "path.toplevel.relative", get_path_toplevel_relative },
 	{ "references.format", get_references_format },
diff --git a/t/t1900-repo-info.sh b/t/t1900-repo-info.sh
index 9417d1ab65..eec576a1d9 100755
--- a/t/t1900-repo-info.sh
+++ b/t/t1900-repo-info.sh
@@ -213,6 +213,45 @@ test_repo_info_path 'gitdir with explicit GIT_DIR' 'gitdir' \
 	'.git' \
 	'GIT_DIR="../.git" && export GIT_DIR'
 
+test_expect_success 'path.superproject-root absolute and relative' '
+	test_when_finished "rm -rf sub super" &&
+	git init sub &&
+	test_commit -C sub initial &&
+	git init super &&
+	(
+		cd super &&
+		git -c protocol.file.allow=always submodule add "../sub" sub &&
+		git commit -m "add submodule" &&
+
+		cd sub &&
+		ROOT="$(test-tool path-utils real_path ..)" &&
+
+		echo "path.superproject-root.absolute=$ROOT" >expect.abs &&
+		git repo info path.superproject-root.absolute >actual.abs &&
+		test_cmp expect.abs actual.abs &&
+
+		echo "path.superproject-root.relative=../" >expect.rel &&
+		git repo info path.superproject-root.relative >actual.rel &&
+		test_cmp expect.rel actual.rel
+	)
+'
+
+test_expect_success 'path.superproject-root returns empty when not in a submodule' '
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
+
+		echo "path.superproject-root.absolute=" >expect.abs &&
+		git repo info path.superproject-root.absolute >actual.abs &&
+		test_cmp expect.abs actual.abs &&
+
+		echo "path.superproject-root.relative=" >expect.rel &&
+		git repo info path.superproject-root.relative >actual.rel &&
+		test_cmp expect.rel actual.rel
+	)
+'
+
 test_expect_success 'path.toplevel absolute and relative' '
 	test_when_finished "rm -rf repo" &&
 	git init repo &&
-- 
2.56.0-rc2
[GSoC Patch v8 4/7] repo: add path.hooks with absolute and relative suffixes
#2609
Author: K Jayatheerth
Date: Sat, 07 Nov 2026 16:00
128 lines
15621 bytes
Hooks are an integral part of a repository's configuration and are
commonly used by tooling to automate repository-specific workflows.
Currently, scripts typically retrieve the hooks directory by invoking
`git rev-parse --git-path hooks`.

Introduce `path.hooks.absolute` and `path.hooks.relative` keys to
`git repo info`. This exposes the hooks directory as a scriptable
config-like key using standard format rules, allowing scripts to
retrieve it through the same interface as other repository path
information.

Mentored-by: Justin Tobler <jltobler@gmail.com>
Mentored-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
---
 Documentation/git-repo.adoc | 10 ++++++++++
 builtin/repo.c              | 30 ++++++++++++++++++++++++++++++
 t/t1900-repo-info.sh        | 25 +++++++++++++++++++++++++
 3 files changed, 65 insertions(+)

diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
index e524a07f53..526a4ccfbd 100644
--- a/Documentation/git-repo.adoc
+++ b/Documentation/git-repo.adoc
@@ -119,6 +119,16 @@ values that they return:
 `path.gitdir.relative`::
 	The path to the Git repository directory relative to the current working directory.
 
+`path.hooks.absolute`::
+	The canonical absolute path to the repository's hooks directory.
+	Respects the `core.hooksPath` configuration. If `core.hooksPath` is
+	set to `/dev/null`, that value is returned unchanged.
+
+`path.hooks.relative`::
+	The path to the repository's hooks directory relative to the current
+	working directory. Respects the `core.hooksPath` configuration. If
+	`core.hooksPath` is set to `/dev/null`, that value is returned unchanged.
+
 `path.superproject-root.absolute`::
 	The canonical absolute path to the working tree root of the superproject
 	if the current repository is an initialized submodule. Outputs an empty
diff --git a/builtin/repo.c b/builtin/repo.c
index c17a8a3b35..739ac2974c 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -122,6 +122,34 @@ static int get_path_gitdir_relative(struct repository *repo, struct strbuf *buf)
 	return 0;
 }
 
+static int get_path_hooks_absolute(struct repository *repo, struct strbuf *buf)
+{
+	struct strbuf hooks_path = STRBUF_INIT;
+
+	repo_git_path_replace(repo, &hooks_path, "hooks");
+	if (!strcmp(hooks_path.buf, "/dev/null"))
+		strbuf_addstr(buf, "/dev/null");
+	else
+		format_path(buf, hooks_path.buf, "", PATH_FORMAT_CANONICAL);
+
+	strbuf_release(&hooks_path);
+	return 0;
+}
+
+static int get_path_hooks_relative(struct repository *repo, struct strbuf *buf)
+{
+	struct strbuf hooks_path = STRBUF_INIT;
+
+	repo_git_path_replace(repo, &hooks_path, "hooks");
+	if (!strcmp(hooks_path.buf, "/dev/null"))
+		strbuf_addstr(buf, "/dev/null");
+	else
+		format_path(buf, hooks_path.buf, repo->prefix, PATH_FORMAT_RELATIVE);
+
+	strbuf_release(&hooks_path);
+	return 0;
+}
+
 static int get_path_superproject_absolute(struct repository *repo, struct strbuf *buf)
 {
 	struct strbuf superproject = STRBUF_INIT;
@@ -182,6 +210,8 @@ static const struct repo_info_field repo_info_field[] = {
 	{ "path.commondir.relative", get_path_commondir_relative },
 	{ "path.gitdir.absolute", get_path_gitdir_absolute },
 	{ "path.gitdir.relative", get_path_gitdir_relative },
+	{ "path.hooks.absolute", get_path_hooks_absolute },
+	{ "path.hooks.relative", get_path_hooks_relative },
 	{ "path.superproject-root.absolute", get_path_superproject_absolute },
 	{ "path.superproject-root.relative", get_path_superproject_relative },
 	{ "path.toplevel.absolute", get_path_toplevel_absolute },
diff --git a/t/t1900-repo-info.sh b/t/t1900-repo-info.sh
index eec576a1d9..5fefb0ca79 100755
--- a/t/t1900-repo-info.sh
+++ b/t/t1900-repo-info.sh
@@ -213,6 +213,31 @@ test_repo_info_path 'gitdir with explicit GIT_DIR' 'gitdir' \
 	'.git' \
 	'GIT_DIR="../.git" && export GIT_DIR'
 
+test_repo_info_path 'hooks standard' 'hooks' '.git/hooks'
+
+test_repo_info_path 'hooks with core.hooksPath override' 'hooks' \
+	'custom-hooks' \
+	'git config core.hooksPath "$ROOT/custom-hooks" && mkdir -p "$ROOT/custom-hooks"'
+
+test_expect_success 'hooks with core.hooksPath=/dev/null' '
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		mkdir -p repo/sub &&
+		cd repo/sub &&
+		cat >>../.git/config <<-\EOF &&
+		[core]
+			hooksPath = /dev/null
+		EOF
+		echo "path.hooks.absolute=/dev/null" >expect.abs &&
+		echo "path.hooks.relative=/dev/null" >expect.rel &&
+		git repo info path.hooks.absolute >actual.abs &&
+		git repo info path.hooks.relative >actual.rel &&
+		test_cmp expect.abs actual.abs &&
+		test_cmp expect.rel actual.rel
+	)
+'
+
 test_expect_success 'path.superproject-root absolute and relative' '
 	test_when_finished "rm -rf sub super" &&
 	git init sub &&
-- 
2.56.0-rc2
[GSoC Patch v8 5/7] repo: add path.index with absolute and relative suffixes
#2608
Author: K Jayatheerth
Date: Sat, 07 Nov 2026 16:00
116 lines
15271 bytes
The repository index is a fundamental component used by Git and related
tooling to track the working tree state. Scripts that interact with the
index currently retrieve its location by invoking
`git rev-parse --git-path index`.

Introduce `path.index.absolute` and `path.index.relative` keys to
`git repo info`. This exposes the index file location as a scriptable
config-like key using standard format rules, allowing scripts to
retrieve it through the same interface as other repository path
information.

Mentored-by: Justin Tobler <jltobler@gmail.com>
Mentored-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
---
 Documentation/git-repo.adoc | 12 ++++++++++++
 builtin/repo.c              | 18 ++++++++++++++++++
 t/t1900-repo-info.sh        | 23 +++++++++++++++++++++++
 3 files changed, 53 insertions(+)

diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
index 526a4ccfbd..2240aae73e 100644
--- a/Documentation/git-repo.adoc
+++ b/Documentation/git-repo.adoc
@@ -129,6 +129,18 @@ values that they return:
 	working directory. Respects the `core.hooksPath` configuration. If
 	`core.hooksPath` is set to `/dev/null`, that value is returned unchanged.
 
+`path.index.absolute`::
+	The canonical absolute path to the repository's current index file.
+	Respects the `GIT_INDEX_FILE` environment override. Returns the
+	configured index path even if the repository is bare or the file does
+	not exist.
+
+`path.index.relative`::
+	The path to the repository's current index file relative to the current
+	working directory. Respects the `GIT_INDEX_FILE` environment override.
+	Returns the configured index path even if the repository is bare or the
+	file does not exist.
+
 `path.superproject-root.absolute`::
 	The canonical absolute path to the working tree root of the superproject
 	if the current repository is an initialized submodule. Outputs an empty
diff --git a/builtin/repo.c b/builtin/repo.c
index 739ac2974c..859bd87617 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -150,6 +150,22 @@ static int get_path_hooks_relative(struct repository *repo, struct strbuf *buf)
 	return 0;
 }
 
+static int get_path_index_absolute(struct repository *repo, struct strbuf *buf)
+{
+	const char *index_file = repo_get_index_file(repo);
+
+	format_path(buf, index_file, "", PATH_FORMAT_CANONICAL);
+	return 0;
+}
+
+static int get_path_index_relative(struct repository *repo, struct strbuf *buf)
+{
+	const char *index_file = repo_get_index_file(repo);
+
+	format_path(buf, index_file, repo->prefix, PATH_FORMAT_RELATIVE);
+	return 0;
+}
+
 static int get_path_superproject_absolute(struct repository *repo, struct strbuf *buf)
 {
 	struct strbuf superproject = STRBUF_INIT;
@@ -212,6 +228,8 @@ static const struct repo_info_field repo_info_field[] = {
 	{ "path.gitdir.relative", get_path_gitdir_relative },
 	{ "path.hooks.absolute", get_path_hooks_absolute },
 	{ "path.hooks.relative", get_path_hooks_relative },
+	{ "path.index.absolute", get_path_index_absolute },
+	{ "path.index.relative", get_path_index_relative },
 	{ "path.superproject-root.absolute", get_path_superproject_absolute },
 	{ "path.superproject-root.relative", get_path_superproject_relative },
 	{ "path.toplevel.absolute", get_path_toplevel_absolute },
diff --git a/t/t1900-repo-info.sh b/t/t1900-repo-info.sh
index 5fefb0ca79..140dfbe68a 100755
--- a/t/t1900-repo-info.sh
+++ b/t/t1900-repo-info.sh
@@ -238,6 +238,29 @@ test_expect_success 'hooks with core.hooksPath=/dev/null' '
 	)
 '
 
+test_repo_info_path 'index standard' 'index' '.git/index'
+
+test_repo_info_path 'index with GIT_INDEX_FILE override' 'index' \
+	'custom-index-file' \
+	'GIT_INDEX_FILE="$ROOT/custom-index-file" && export GIT_INDEX_FILE'
+
+test_expect_success 'path.index in a bare repository returns default index location' '
+	test_when_finished "rm -rf bare.git" &&
+	git init --bare bare.git &&
+	(
+		cd bare.git &&
+		ROOT="$(test-tool path-utils real_path .)" &&
+
+		echo "path.index.absolute=$ROOT/index" >expect.abs &&
+		git repo info path.index.absolute >actual.abs &&
+		test_cmp expect.abs actual.abs &&
+
+		echo "path.index.relative=index" >expect.rel &&
+		git repo info path.index.relative >actual.rel &&
+		test_cmp expect.rel actual.rel
+	)
+'
+
 test_expect_success 'path.superproject-root absolute and relative' '
 	test_when_finished "rm -rf sub super" &&
 	git init sub &&
-- 
2.56.0-rc2
[GSoC Patch v8 6/7] repo: add path.git-prefix
#2605
Author: K Jayatheerth
Date: Sat, 07 Nov 2026 16:00
100 lines
14237 bytes
Scripts sometimes need the path from the repository's working tree root
to the current working directory. While this information can be derived
through existing Git commands, `git repo info` does not currently expose
it as a scriptable key.

Introduce the `path.git-prefix` key to `git repo info`. The key returns
the path from the working tree root to the current working directory,
returning the empty string when invoked from the working tree root.

Mentored-by: Justin Tobler <jltobler@gmail.com>
Mentored-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
---
 Documentation/git-repo.adoc |  5 +++++
 builtin/repo.c              | 11 +++++++++++
 t/t1900-repo-info.sh        | 23 +++++++++++++++++++++++
 3 files changed, 39 insertions(+)

diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
index 2240aae73e..c0d595cdc5 100644
--- a/Documentation/git-repo.adoc
+++ b/Documentation/git-repo.adoc
@@ -113,6 +113,11 @@ values that they return:
 	The path to the Git repository's common directory relative to
 	the current working directory.
 
+`path.git-prefix`::
+	The path from the root of the working tree to the current working
+	directory. Returns the empty string when the current working directory
+	is the root of the working tree.
+
 `path.gitdir.absolute`::
 	The canonical absolute path to the Git repository directory (the `.git` directory).
 
diff --git a/builtin/repo.c b/builtin/repo.c
index 859bd87617..0c63c0280f 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -100,6 +100,16 @@ static int get_path_commondir_relative(struct repository *repo, struct strbuf *b
 	return 0;
 }
 
+static int get_path_git_prefix(struct repository *repo, struct strbuf *buf)
+{
+	/*
+	 * repo->prefix is NULL when the current working directory is
+	 * the worktree root.
+	 */
+	strbuf_addstr(buf, repo->prefix ? repo->prefix : "");
+	return 0;
+}
+
 static int get_path_gitdir_absolute(struct repository *repo, struct strbuf *buf)
 {
 	const char *git_dir = repo_get_git_dir(repo);
@@ -224,6 +234,7 @@ static const struct repo_info_field repo_info_field[] = {
 	{ "object.format", get_object_format },
 	{ "path.commondir.absolute", get_path_commondir_absolute },
 	{ "path.commondir.relative", get_path_commondir_relative },
+	{ "path.git-prefix", get_path_git_prefix },
 	{ "path.gitdir.absolute", get_path_gitdir_absolute },
 	{ "path.gitdir.relative", get_path_gitdir_relative },
 	{ "path.hooks.absolute", get_path_hooks_absolute },
diff --git a/t/t1900-repo-info.sh b/t/t1900-repo-info.sh
index 140dfbe68a..b41fdeee77 100755
--- a/t/t1900-repo-info.sh
+++ b/t/t1900-repo-info.sh
@@ -207,6 +207,29 @@ test_repo_info_path 'commondir with only GIT_DIR' 'commondir' \
 	'.git' \
 	'GIT_DIR="../.git" && export GIT_DIR'
 
+test_expect_success 'path.git-prefix at repository root' '
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
+		echo "path.git-prefix=" >expect &&
+		git repo info path.git-prefix >actual &&
+		test_cmp expect actual
+	)
+'
+
+test_expect_success 'path.git-prefix in subdirectory' '
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	mkdir -p repo/sub/dir &&
+	(
+		cd repo/sub/dir &&
+		echo "path.git-prefix=sub/dir/" >expect &&
+		git repo info path.git-prefix >actual &&
+		test_cmp expect actual
+	)
+'
+
 test_repo_info_path 'gitdir standard' 'gitdir' '.git'
 
 test_repo_info_path 'gitdir with explicit GIT_DIR' 'gitdir' \
-- 
2.56.0-rc2
[GSoC Patch v8 7/7] repo: add path.cdup
#2606
Author: K Jayatheerth
Date: Sat, 07 Nov 2026 16:01
129 lines
14765 bytes
Scripts sometimes need the relative path from the current working
directory to the repository's working tree root (cdup). While this
information can be retrieved through `git rev-parse --show-cdup`,
`git repo info` does not currently expose it as a scriptable key.

Introduce the `path.cdup` key to `git repo info`. The key returns the
path from the current working directory to the root of the working tree,
returning the empty string when invoked from the working tree root.

Mentored-by: Justin Tobler <jltobler@gmail.com>
Mentored-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
---
 Documentation/git-repo.adoc |  5 +++++
 builtin/repo.c              | 23 +++++++++++++++++++++
 t/t1900-repo-info.sh        | 40 +++++++++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+)

diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
index c0d595cdc5..281c600175 100644
--- a/Documentation/git-repo.adoc
+++ b/Documentation/git-repo.adoc
@@ -104,6 +104,11 @@ values that they return:
 `object.format`::
 	The object format (hash algorithm) used in the repository.
 
+`path.cdup`::
+	When the command is invoked from a subdirectory, show the
+	path of the top-level directory relative to the current
+	directory (typically a sequence of "../", or an empty string).
+
 `path.commondir.absolute`::
 	The canonical absolute path to the Git repository's common
 	directory (the shared `.git` directory containing objects,
diff --git a/builtin/repo.c b/builtin/repo.c
index 0c63c0280f..3e5572f6cf 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -78,6 +78,28 @@ static int get_object_format(struct repository *repo, struct strbuf *buf)
 	return 0;
 }
 
+static int get_path_cdup(struct repository *repo, struct strbuf *buf)
+{
+	const char *pfx = repo->prefix;
+
+	if (!is_inside_work_tree(repo)) {
+		const char *worktree = repo_get_work_tree(repo);
+
+		if (worktree)
+			strbuf_addstr(buf, worktree);
+		return 0;
+	}
+
+	while (pfx) {
+		pfx = strchr(pfx, '/');
+		if (pfx) {
+			pfx++;
+			strbuf_addstr(buf, "../");
+		}
+	}
+	return 0;
+}
+
 static int get_path_commondir_absolute(struct repository *repo, struct strbuf *buf)
 {
 	const char *common_dir = repo_get_common_dir(repo);
@@ -232,6 +254,7 @@ static const struct repo_info_field repo_info_field[] = {
 	{ "layout.bare", get_layout_bare },
 	{ "layout.shallow", get_layout_shallow },
 	{ "object.format", get_object_format },
+	{ "path.cdup", get_path_cdup },
 	{ "path.commondir.absolute", get_path_commondir_absolute },
 	{ "path.commondir.relative", get_path_commondir_relative },
 	{ "path.git-prefix", get_path_git_prefix },
diff --git a/t/t1900-repo-info.sh b/t/t1900-repo-info.sh
index b41fdeee77..a3c1be97c3 100755
--- a/t/t1900-repo-info.sh
+++ b/t/t1900-repo-info.sh
@@ -207,6 +207,46 @@ test_repo_info_path 'commondir with only GIT_DIR' 'commondir' \
 	'.git' \
 	'GIT_DIR="../.git" && export GIT_DIR'
 
+test_expect_success 'path.cdup at repository root' '
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
+		echo "path.cdup=" >expect &&
+		git repo info path.cdup >actual &&
+		test_cmp expect actual
+	)
+'
+
+test_expect_success 'path.cdup in subdirectory' '
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	mkdir -p repo/sub/dir &&
+	(
+		cd repo/sub/dir &&
+		echo "path.cdup=../../" >expect &&
+		git repo info path.cdup >actual &&
+		test_cmp expect actual
+	)
+'
+
+test_expect_success 'path.cdup cwd outside the working tree' '
+	test_when_finished "rm -rf repo" &&
+	mkdir -p repo/tmp/x &&
+	(
+		cd repo &&
+		git init test &&
+		echo "path.cdup=$(pwd)/tmp/x" >test/expect &&
+		cd test &&
+		GIT_WORK_TREE=../tmp/x &&
+		export GIT_WORK_TREE &&
+		GIT_DIR=$(pwd)/.git &&
+		export GIT_DIR &&
+		git repo info path.cdup >actual &&
+		test_cmp expect actual
+	)
+'
+
 test_expect_success 'path.git-prefix at repository root' '
 	test_when_finished "rm -rf repo" &&
 	git init repo &&
-- 
2.56.0-rc2
Re: [GSoC Patch v8 0/7] repo: add path keys to repo info
#2617
Author: Phillip Wood
Date: Sat, 07 Nov 2026 19:57
499 lines
34614 bytes
On 07/11/2026 16:00, K Jayatheerth wrote:

I'm a bit late to the party, I like the idea of adding some more paths 
to "git repo", but I have a few comments about the design of this series.

> This patch series continues the work to expose repository paths and
> metadata via the `git repo info` command. It introduces several keys for
> querying repository paths in standard absolute and relative formats, as well
> as refactoring `get_superproject_working_tree()` to operate on a `struct
> repository *`.
> 
> The path keys added in this series are:
>    - `path.toplevel.absolute` / `path.toplevel.relative`: The root directory
>      of the working tree (or an empty string in bare repositories).

In our documentation and glossary, we call this directory the "working 
tree" so I think "path.working-tree.*" would be a better name, rather 
than copying the name from the equivalent rev-parse option.

>    - `path.superproject-root.absolute` / `path.superproject-root.relative`:
>      The root of the superproject when inside a submodule.

Personally, I'd prefer "path.superproject-working-tree.*" here, though I 
see Justin thought that was a bit of a mouthful. As this command is for 
use in scripts I'd rather have a descriptive name.

>    - `path.hooks.absolute` / `path.hooks.relative`: The repository's hooks
>      directory (respecting `core.hooksPath`, including `/dev/null`).

Given we have config based hooks now, do we really want to add this? 
Scripts that want to run hooks should be using "git hook run" and 
scripts that want to install hooks should be using the config based 
hooks so that they co-exist with the user's existing hooks.

>    - `path.index.absolute` / `path.index.relative`: The repository's active
>      index file.
>    - `path.git-prefix`: The prefix from the worktree root to the current
>      working directory.

The "git-" prefix seems a bit odd to me, maybe "path.prefix" would be a 
better name for an option that returns the prefix to add to paths?

>    - `path.cdup`: The relative path from the current directory up to the
>      worktree root.

How does this differ from path.working-tree.relative? I've never really 
understood "git rev-parse --cdup" - if you're in the repository root 
directory, 'cd "$(git rev-parse --cdup)"' dumps you in your home 
directory which has always seemed a bit surprising to me.

One note on the tests - our test suite is quite slow, so it would be 
good to avoid initializing new repositories for each test where we are 
checking these paths.

Thanks

Phillip

> Changes since v7:
>    - Dropped `path.grafts`.
>    - In patch 2 (`submodule: use repository to find superproject`), moved the
>      test for `--git-dir` to `t/t1500-rev-parse.sh` exercising the existing
>      `rev-parse --show-superproject-working-tree` interface (since
>      `path.superproject-root` is only added in patch 3), and ensured clean
>      isolation of test directories (`sub` and `super`).
>    - In patch 3 (`path.superproject-root`), simplified the getter functions
>      by eliminating redundant early returns.
>    - In patch 4 (`path.hooks`):
>      - Special-cased `/dev/null` in both `path.hooks.absolute` and
>        `path.hooks.relative` to output `/dev/null` directly, making it easy
>        for scripts to detect when hooks are disabled. Documented this
>        behavior in `Documentation/git-repo.adoc`.
>      - Reverted changes to the `test_repo_info_path` helper in
>        `t/t1900-repo-info.sh` and wrote a standalone test block for the
>        `/dev/null` case.
>      - Set `hooksPath = /dev/null` directly in the config file rather than
>        passing it through `git config core.hooksPath /dev/null` to prevent
>        MSYS2 argument mangling on Windows (which rewrites `/dev/null` to
>        `nul`), allowing the test to run portably on all platforms without
>        requiring `!MINGW`.
>    - In patch 7 (`path.cdup`), removed unnecessary braces on the single-line
>      `if`, added an early return when invoked outside a worktree, and ensured
>      `cd repo` in the test runs within a subshell.
> 
> Thanks to Justin Tobler and Lucas Seiki Oshiro for their reviews and
> mentorship.
> 
> K Jayatheerth (7):
>    repo: add path.toplevel with absolute and relative suffix formatting
>    submodule: use repository to find superproject
>    repo: add path.superproject-root with absolute and relative suffixes
>    repo: add path.hooks with absolute and relative suffixes
>    repo: add path.index with absolute and relative suffixes
>    repo: add path.git-prefix
>    repo: add path.cdup
> 
>   Documentation/git-repo.adoc |  52 ++++++++++
>   builtin/repo.c              | 131 +++++++++++++++++++++++++
>   builtin/rev-parse.c         |   2 +-
>   submodule.c                 |  43 +++++----
>   submodule.h                 |   2 +-
>   t/t1500-rev-parse.sh        |  20 ++++
>   t/t1900-repo-info.sh        | 185 ++++++++++++++++++++++++++++++++++++
>   7 files changed, 412 insertions(+), 23 deletions(-)
> 
> Range-diff against v7:
> 5:  351b4b7de7 ! 1:  27b9811163 repo: add path.grafts with absolute and relative suffixes
>      @@ Metadata
>       Author: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
>       
>        ## Commit message ##
>      -    repo: add path.grafts with absolute and relative suffixes
>      +    repo: add path.toplevel with absolute and relative suffix formatting
>       
>      -    The repository grafts file specifies alternate parent relationships for
>      -    commits and may be used by repository tooling that needs to inspect or
>      -    manage grafts. Scripts currently retrieve its location by invoking
>      -    `git rev-parse --git-path info/grafts`.
>      +    Scripts frequently need to find the root directory of a repository's
>      +    working tree. Currently, this requires using `git rev-parse --show-toplevel`
>      +    or inferring it from other repository information.
>       
>      -    Introduce `path.grafts.absolute` and `path.grafts.relative` keys to
>      -    `git repo info`. This exposes the grafts file location as a scriptable
>      -    config-like key using standard format rules, allowing scripts to
>      -    retrieve it through the same interface as other repository path
>      -    information.
>      +    Introduce `path.toplevel.absolute` and `path.toplevel.relative` keys
>      +    to `git repo info`. This allows scripts to retrieve the top-level
>      +    working tree path in a predictable, strictly formatted manner without
>      +    relying on `rev-parse`.
>      +
>      +    If requested in a bare repository where no working tree exists, the
>      +    command returns an empty string.
>       
>           Mentored-by: Justin Tobler <jltobler@gmail.com>
>           Mentored-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
>      @@ Documentation/git-repo.adoc: values that they return:
>        `path.gitdir.relative`::
>        	The path to the Git repository directory relative to the current working directory.
>        
>      -+`path.grafts.absolute`::
>      -+	The canonical absolute path to the repository's graft file.
>      -+	Respects the `GIT_GRAFT_FILE` environment override. The path is
>      -+	returned regardless of whether the file currently exists on disk.
>      ++`path.toplevel.absolute`::
>      ++	The canonical absolute path to the top-level directory of the
>      ++	repository's working tree. Outputs an empty string if the repository
>      ++	is bare.
>       +
>      -+`path.grafts.relative`::
>      -+	The path to the repository's graft file relative to the current
>      -+	working directory. Respects the `GIT_GRAFT_FILE` environment
>      -+	override. The path is returned regardless of whether the file
>      -+	currently exists on disk.
>      ++`path.toplevel.relative`::
>      ++	The path to the top-level directory of the repository's working
>      ++	tree relative to the current working directory. Outputs an empty
>      ++	string if the repository is bare.
>       +
>      - `path.hooks.absolute`::
>      - 	The canonical absolute path to the repository's hooks directory.
>      - 	Respects the `core.hooksPath` configuration. If `core.hooksPath` is
>      + `references.format`::
>      + 	The reference storage format. The valid values are:
>      + +
>       
>        ## builtin/repo.c ##
>       @@ builtin/repo.c: static int get_path_gitdir_relative(struct repository *repo, struct strbuf *buf)
>        	return 0;
>        }
>        
>      -+static int get_path_grafts_absolute(struct repository *repo, struct strbuf *buf)
>      ++static int get_path_toplevel_absolute(struct repository *repo, struct strbuf *buf)
>       +{
>      -+	const char *graft_file = repo_get_graft_file(repo);
>      ++	const char *work_tree = repo_get_work_tree(repo);
>       +
>      -+	if (!graft_file)
>      -+		return error(_("unable to get graft file"));
>      ++	if (!work_tree)
>      ++		return 0;
>       +
>      -+	format_path(buf, graft_file, "", PATH_FORMAT_CANONICAL);
>      ++	format_path(buf, work_tree, "", PATH_FORMAT_CANONICAL);
>       +	return 0;
>       +}
>       +
>      -+static int get_path_grafts_relative(struct repository *repo, struct strbuf *buf)
>      ++static int get_path_toplevel_relative(struct repository *repo, struct strbuf *buf)
>       +{
>      -+	const char *graft_file = repo_get_graft_file(repo);
>      ++	const char *work_tree = repo_get_work_tree(repo);
>       +
>      -+	if (!graft_file)
>      -+		return error(_("unable to get graft file"));
>      ++	if (!work_tree)
>      ++		return 0;
>       +
>      -+	format_path(buf, graft_file, repo->prefix, PATH_FORMAT_RELATIVE);
>      ++	format_path(buf, work_tree, repo->prefix, PATH_FORMAT_RELATIVE);
>       +	return 0;
>       +}
>       +
>      - static int get_path_hooks_absolute(struct repository *repo, struct strbuf *buf)
>      + static int get_references_format(struct repository *repo, struct strbuf *buf)
>        {
>      - 	struct strbuf hooks_path = STRBUF_INIT;
>      + 	strbuf_addstr(buf,
>       @@ builtin/repo.c: static const struct repo_info_field repo_info_field[] = {
>        	{ "path.commondir.relative", get_path_commondir_relative },
>        	{ "path.gitdir.absolute", get_path_gitdir_absolute },
>        	{ "path.gitdir.relative", get_path_gitdir_relative },
>      -+	{ "path.grafts.absolute", get_path_grafts_absolute },
>      -+	{ "path.grafts.relative", get_path_grafts_relative },
>      - 	{ "path.hooks.absolute", get_path_hooks_absolute },
>      - 	{ "path.hooks.relative", get_path_hooks_relative },
>      - 	{ "path.index.absolute", get_path_index_absolute },
>      ++	{ "path.toplevel.absolute", get_path_toplevel_absolute },
>      ++	{ "path.toplevel.relative", get_path_toplevel_relative },
>      + 	{ "references.format", get_references_format },
>      + };
>      +
>       
>        ## t/t1900-repo-info.sh ##
>       @@ t/t1900-repo-info.sh: test_repo_info_path 'gitdir with explicit GIT_DIR' 'gitdir' \
>        	'.git' \
>        	'GIT_DIR="../.git" && export GIT_DIR'
>        
>      -+test_repo_info_path 'grafts standard' 'grafts' '.git/info/grafts'
>      ++test_expect_success 'path.toplevel absolute and relative' '
>      ++	test_when_finished "rm -rf repo" &&
>      ++	git init repo &&
>      ++	(
>      ++		mkdir -p repo/sub &&
>      ++		cd repo/sub &&
>       +
>      -+test_repo_info_path 'grafts with GIT_GRAFT_FILE override' 'grafts' \
>      -+	'custom-graft-file' \
>      -+	'GIT_GRAFT_FILE="$ROOT/custom-graft-file" && export GIT_GRAFT_FILE'
>      ++		ROOT="$(test-tool path-utils real_path ..)" &&
>       +
>      - test_repo_info_path 'hooks standard' 'hooks' '.git/hooks'
>      -
>      - test_repo_info_path 'hooks with core.hooksPath override' 'hooks' \
>      ++		echo "path.toplevel.absolute=$ROOT" >expect.abs &&
>      ++		git repo info path.toplevel.absolute >actual.abs &&
>      ++		test_cmp expect.abs actual.abs &&
>      ++
>      ++		echo "path.toplevel.relative=../" >expect.rel &&
>      ++		git repo info path.toplevel.relative >actual.rel &&
>      ++		test_cmp expect.rel actual.rel
>      ++	)
>      ++'
>      ++
>      ++test_expect_success 'path.toplevel absolute and relative in a bare repository' '
>      ++	test_when_finished "rm -rf bare.git" &&
>      ++	git init --bare bare.git &&
>      ++	(
>      ++		cd bare.git &&
>      ++
>      ++		echo "path.toplevel.absolute=" >expect.abs &&
>      ++		git repo info path.toplevel.absolute >actual.abs &&
>      ++		test_cmp expect.abs actual.abs &&
>      ++
>      ++		echo "path.toplevel.relative=" >expect.rel &&
>      ++		git repo info path.toplevel.relative >actual.rel &&
>      ++		test_cmp expect.rel actual.rel
>      ++	)
>      ++'
>      ++
>      + test_done
> 1:  7c90603a1b ! 2:  2274dd8be2 submodule: use repository to find superproject
>      @@ submodule.h: void absorb_git_dir_into_superproject(const char *path,
>        
>        #endif
>       
>      - ## t/t7400-submodule-basic.sh ##
>      -@@ t/t7400-submodule-basic.sh: test_expect_success 'submodule add fails when name is reused' '
>      + ## t/t1500-rev-parse.sh ##
>      +@@ t/t1500-rev-parse.sh: test_expect_success ':/ and HEAD^{/} favor more recent matching commits' '
>        	)
>        '
>        
>      -+test_expect_success 'path.superproject-root works with --git-dir' '
>      ++test_expect_success '--show-superproject-working-tree works with --git-dir' '
>      ++	rm -rf sub super &&
>       +	test_when_finished "rm -rf sub super" &&
>       +	git init sub &&
>       +	test_commit -C sub initial &&
>      @@ t/t7400-submodule-basic.sh: test_expect_success 'submodule add fails when name i
>       +		SUPER_ROOT="$(test-tool path-utils real_path .)" &&
>       +		MODULE_DIR="$SUPER_ROOT/.git/modules/sub" &&
>       +
>      -+		echo "path.superproject-root.absolute=$SUPER_ROOT" >expect &&
>      -+		git --git-dir="$MODULE_DIR" repo info path.superproject-root.absolute >actual &&
>      ++		echo "$SUPER_ROOT" >expect &&
>      ++		git --git-dir="$MODULE_DIR" rev-parse --show-superproject-working-tree >actual &&
>       +		test_cmp expect actual
>       +	)
>       +'
> 2:  1bfb0c8c1d ! 3:  34c54cdafd repo: add path.superproject-root with absolute and relative suffixes
>      @@ builtin/repo.c: static int get_path_gitdir_relative(struct repository *repo, str
>       +{
>       +	struct strbuf superproject = STRBUF_INIT;
>       +
>      -+	if (!get_superproject_working_tree(repo, &superproject)) {
>      -+		strbuf_release(&superproject);
>      -+		return 0;
>      -+	}
>      ++	if (get_superproject_working_tree(repo, &superproject))
>      ++		format_path(buf, superproject.buf, "", PATH_FORMAT_CANONICAL);
>       +
>      -+	format_path(buf, superproject.buf, "", PATH_FORMAT_CANONICAL);
>       +	strbuf_release(&superproject);
>       +	return 0;
>       +}
>      @@ builtin/repo.c: static int get_path_gitdir_relative(struct repository *repo, str
>       +{
>       +	struct strbuf superproject = STRBUF_INIT;
>       +
>      -+	if (!get_superproject_working_tree(repo, &superproject)) {
>      -+		strbuf_release(&superproject);
>      -+		return 0;
>      -+	}
>      ++	if (get_superproject_working_tree(repo, &superproject))
>      ++		format_path(buf, superproject.buf, repo->prefix, PATH_FORMAT_RELATIVE);
>       +
>      -+	format_path(buf, superproject.buf, repo->prefix, PATH_FORMAT_RELATIVE);
>       +	strbuf_release(&superproject);
>       +	return 0;
>       +}
> 3:  09d2937fcd ! 4:  985403c7b3 repo: add path.hooks with absolute and relative suffixes
>      @@ Documentation/git-repo.adoc: values that they return:
>       +
>       +`path.hooks.relative`::
>       +	The path to the repository's hooks directory relative to the current
>      -+	working directory. Respects the `core.hooksPath` configuration.
>      ++	working directory. Respects the `core.hooksPath` configuration. If
>      ++	`core.hooksPath` is set to `/dev/null`, that value is returned unchanged.
>       +
>        `path.superproject-root.absolute`::
>        	The canonical absolute path to the working tree root of the superproject
>      @@ builtin/repo.c: static int get_path_gitdir_relative(struct repository *repo, str
>       +	struct strbuf hooks_path = STRBUF_INIT;
>       +
>       +	repo_git_path_replace(repo, &hooks_path, "hooks");
>      -+	format_path(buf, hooks_path.buf, "", PATH_FORMAT_CANONICAL);
>      ++	if (!strcmp(hooks_path.buf, "/dev/null"))
>      ++		strbuf_addstr(buf, "/dev/null");
>      ++	else
>      ++		format_path(buf, hooks_path.buf, "", PATH_FORMAT_CANONICAL);
>      ++
>       +	strbuf_release(&hooks_path);
>       +	return 0;
>       +}
>      @@ builtin/repo.c: static int get_path_gitdir_relative(struct repository *repo, str
>       +	struct strbuf hooks_path = STRBUF_INIT;
>       +
>       +	repo_git_path_replace(repo, &hooks_path, "hooks");
>      -+	format_path(buf, hooks_path.buf, repo->prefix, PATH_FORMAT_RELATIVE);
>      ++	if (!strcmp(hooks_path.buf, "/dev/null"))
>      ++		strbuf_addstr(buf, "/dev/null");
>      ++	else
>      ++		format_path(buf, hooks_path.buf, repo->prefix, PATH_FORMAT_RELATIVE);
>      ++
>       +	strbuf_release(&hooks_path);
>       +	return 0;
>       +}
>      @@ builtin/repo.c: static const struct repo_info_field repo_info_field[] = {
>        	{ "path.toplevel.absolute", get_path_toplevel_absolute },
>       
>        ## t/t1900-repo-info.sh ##
>      -@@ t/t1900-repo-info.sh: test_repo_info_path () {
>      - 			cd repo/sub &&
>      - 			ROOT="$(test-tool path-utils real_path ..)" && export ROOT &&
>      - 			eval "$init_command" &&
>      --			echo "path.$field_name.absolute=$ROOT/$expected_dir" >expect &&
>      -+			case "$expected_dir" in
>      -+			/*) EXPECT_ABS="$expected_dir" ;;
>      -+			*) EXPECT_ABS="$ROOT/$expected_dir" ;;
>      -+			esac &&
>      -+			echo "path.$field_name.absolute=$EXPECT_ABS" >expect &&
>      - 			git repo info "path.$field_name.absolute" >actual &&
>      - 			test_cmp expect actual
>      - 		)
>      -@@ t/t1900-repo-info.sh: test_repo_info_path () {
>      - 			cd repo/sub &&
>      - 			ROOT="$(test-tool path-utils real_path ..)" && export ROOT &&
>      - 			eval "$init_command" &&
>      --			echo "path.$field_name.relative=../$expected_dir" >expect &&
>      -+			case "$expected_dir" in
>      -+			/*) EXPECT_REL="$(test-tool path-utils relative_path "$expected_dir" "$PWD")" ;;
>      -+			*) EXPECT_REL="../$expected_dir" ;;
>      -+			esac &&
>      -+			echo "path.$field_name.relative=$EXPECT_REL" >expect &&
>      - 			git repo info "path.$field_name.relative" >actual &&
>      - 			test_cmp expect actual
>      - 		)
>       @@ t/t1900-repo-info.sh: test_repo_info_path 'gitdir with explicit GIT_DIR' 'gitdir' \
>        	'.git' \
>        	'GIT_DIR="../.git" && export GIT_DIR'
>      @@ t/t1900-repo-info.sh: test_repo_info_path 'gitdir with explicit GIT_DIR' 'gitdir
>       +	'custom-hooks' \
>       +	'git config core.hooksPath "$ROOT/custom-hooks" && mkdir -p "$ROOT/custom-hooks"'
>       +
>      -+# /dev/null is not a real, canonicalizable filesystem path on Windows,
>      -+# so path resolution for core.hooksPath=/dev/null cannot be expected to
>      -+# produce a literal "/dev/null" the way it does on POSIX systems.
>      -+if ! test_have_prereq MINGW
>      -+then
>      -+	test_repo_info_path 'hooks with core.hooksPath=/dev/null' 'hooks' \
>      -+		'/dev/null' \
>      -+		'git config core.hooksPath /dev/null'
>      -+fi
>      ++test_expect_success 'hooks with core.hooksPath=/dev/null' '
>      ++	test_when_finished "rm -rf repo" &&
>      ++	git init repo &&
>      ++	(
>      ++		mkdir -p repo/sub &&
>      ++		cd repo/sub &&
>      ++		cat >>../.git/config <<-\EOF &&
>      ++		[core]
>      ++			hooksPath = /dev/null
>      ++		EOF
>      ++		echo "path.hooks.absolute=/dev/null" >expect.abs &&
>      ++		echo "path.hooks.relative=/dev/null" >expect.rel &&
>      ++		git repo info path.hooks.absolute >actual.abs &&
>      ++		git repo info path.hooks.relative >actual.rel &&
>      ++		test_cmp expect.abs actual.abs &&
>      ++		test_cmp expect.rel actual.rel
>      ++	)
>      ++'
>       +
>        test_expect_success 'path.superproject-root absolute and relative' '
>        	test_when_finished "rm -rf sub super" &&
> 4:  d0c186f150 ! 5:  486836ae52 repo: add path.index with absolute and relative suffixes
>      @@ Commit message
>       
>        ## Documentation/git-repo.adoc ##
>       @@ Documentation/git-repo.adoc: values that they return:
>      - 	The path to the repository's hooks directory relative to the current
>      - 	working directory. Respects the `core.hooksPath` configuration.
>      + 	working directory. Respects the `core.hooksPath` configuration. If
>      + 	`core.hooksPath` is set to `/dev/null`, that value is returned unchanged.
>        
>       +`path.index.absolute`::
>       +	The canonical absolute path to the repository's current index file.
>      @@ builtin/repo.c: static const struct repo_info_field repo_info_field[] = {
>        	{ "path.toplevel.absolute", get_path_toplevel_absolute },
>       
>        ## t/t1900-repo-info.sh ##
>      -@@ t/t1900-repo-info.sh: then
>      - 		'git config core.hooksPath /dev/null'
>      - fi
>      +@@ t/t1900-repo-info.sh: test_expect_success 'hooks with core.hooksPath=/dev/null' '
>      + 	)
>      + '
>        
>       +test_repo_info_path 'index standard' 'index' '.git/index'
>       +
> 6:  ef69d4aa8c ! 6:  91a8dc3ab1 repo: add path.git-prefix
>      @@ builtin/repo.c: static const struct repo_info_field repo_info_field[] = {
>       +	{ "path.git-prefix", get_path_git_prefix },
>        	{ "path.gitdir.absolute", get_path_gitdir_absolute },
>        	{ "path.gitdir.relative", get_path_gitdir_relative },
>      - 	{ "path.grafts.absolute", get_path_grafts_absolute },
>      + 	{ "path.hooks.absolute", get_path_hooks_absolute },
>       
>        ## t/t1900-repo-info.sh ##
>       @@ t/t1900-repo-info.sh: test_repo_info_path 'commondir with only GIT_DIR' 'commondir' \
> 7:  3e61728dba ! 7:  84a9fb4060 repo: add path.cdup
>      @@ builtin/repo.c: static int get_object_format(struct repository *repo, struct str
>       +	if (!is_inside_work_tree(repo)) {
>       +		const char *worktree = repo_get_work_tree(repo);
>       +
>      -+		if (worktree) {
>      ++		if (worktree)
>       +			strbuf_addstr(buf, worktree);
>      -+		}
>      ++		return 0;
>       +	}
>       +
>       +	while (pfx) {
>      @@ t/t1900-repo-info.sh: test_repo_info_path 'commondir with only GIT_DIR' 'commond
>       +test_expect_success 'path.cdup cwd outside the working tree' '
>       +	test_when_finished "rm -rf repo" &&
>       +	mkdir -p repo/tmp/x &&
>      -+	cd repo &&
>      -+	git init test &&
>       +	(
>      -+		echo path.cdup=$(pwd)/tmp/x >./test/expect &&
>      ++		cd repo &&
>      ++		git init test &&
>      ++		echo "path.cdup=$(pwd)/tmp/x" >test/expect &&
>       +		cd test &&
>       +		GIT_WORK_TREE=../tmp/x &&
>       +		export GIT_WORK_TREE &&
Re: [GSoC Patch v8 0/7] repo: add path keys to repo info
#2726
Author: K Jayatheerth
Date: Mon, 09 Nov 2026 16:52
118 lines
16134 bytes
Hey Phillip,

On Sun, Nov 8, 2026 at 1:27 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
>
> On 07/11/2026 16:00, K Jayatheerth wrote:
>
> I'm a bit late to the party, I like the idea of adding some more paths
> to "git repo", but I have a few comments about the design of this series.
>
> > This patch series continues the work to expose repository paths and
> > metadata via the `git repo info` command. It introduces several keys for
> > querying repository paths in standard absolute and relative formats, as well
> > as refactoring `get_superproject_working_tree()` to operate on a `struct
> > repository *`.
> >
> > The path keys added in this series are:
> >    - `path.toplevel.absolute` / `path.toplevel.relative`: The root directory
> >      of the working tree (or an empty string in bare repositories).
>
> In our documentation and glossary, we call this directory the "working
> tree" so I think "path.working-tree.*" would be a better name, rather
> than copying the name from the equivalent rev-parse option.
>
> >    - `path.superproject-root.absolute` / `path.superproject-root.relative`:
> >      The root of the superproject when inside a submodule.
>
> Personally, I'd prefer "path.superproject-working-tree.*" here, though I
> see Justin thought that was a bit of a mouthful. As this command is for
> use in scripts I'd rather have a descriptive name.
>

I don't have an opinion on the name itself, but, that said:
I think superproject-working-tree is a more suiting name.
It is becuase you may have a working tree in a different place and it
might not be the root itself.
I think the same logic applies for toplevel too.

Any more thoughts from Justin, Lucas, Junio or any other reviewer
would be better I reckon.

> >    - `path.hooks.absolute` / `path.hooks.relative`: The repository's hooks
> >      directory (respecting `core.hooksPath`, including `/dev/null`).
>
> Given we have config based hooks now, do we really want to add this?
> Scripts that want to run hooks should be using "git hook run" and
> scripts that want to install hooks should be using the config based
> hooks so that they co-exist with the user's existing hooks.
>

I believe that is a fair point for new tooling, though wouldn't many
existing scripts
and third-party tools still learn about hooks directly via `git
rev-parse --git-path hooks`?

Since the main goal of `git repo info` is to provide an alternative
to `rev-parse`'s various path flags, `path.hooks` still seems useful for scripts
migrating over, unless the consensus is to deprecate querying the hooks
directory altogether.

> >    - `path.index.absolute` / `path.index.relative`: The repository's active
> >      index file.
> >    - `path.git-prefix`: The prefix from the worktree root to the current
> >      working directory.
>
> The "git-" prefix seems a bit odd to me, maybe "path.prefix" would be a
> better name for an option that returns the prefix to add to paths?
>

Agreed, I would change this in the next patch series.

> >    - `path.cdup`: The relative path from the current directory up to the
> >      worktree root.
>
> How does this differ from path.working-tree.relative? I've never really
> understood "git rev-parse --cdup" - if you're in the repository root
> directory, 'cd "$(git rev-parse --cdup)"' dumps you in your home
> directory which has always seemed a bit surprising to me.
>

Well looking at the code itself
What I can say is I find couple of edge cases,

The cdup command relies on a slash counting loop on the prefix string
to output directory-up
sequences like '../', returns an empty string at the root and falls
back to the worktree path when outside.

On the contrary, relative formatting uses Git's path utility library
to compute true relative
filesystem paths, outputting '.' at the root instead of leaving it blank.

> One note on the tests - our test suite is quite slow, so it would be
> good to avoid initializing new repositories for each test where we are
> checking these paths.
>

Alright, I will look into them and see how I can optimize them.

> Thanks
>
> Phillip
>
[snip]

Thank you,
- K Jayatheerth
Re: [GSoC Patch v8 0/7] repo: add path keys to repo info
#2744
Author: Junio C Hamano
Date: Mon, 09 Nov 2026 19:53
23 lines
13635 bytes
K Jayatheerth <jayatheerthkulkarni2005@gmail.com> writes:

>> >    - `path.superproject-root.absolute` / `path.superproject-root.relative`:
>> >      The root of the superproject when inside a submodule.
>>
>> Personally, I'd prefer "path.superproject-working-tree.*" here, though I
>> see Justin thought that was a bit of a mouthful. As this command is for
>> use in scripts I'd rather have a descriptive name.
>
> I don't have an opinion on the name itself, but, that said:
> I think superproject-working-tree is a more suiting name.

Syntactically you could put anything at the second level of
three-level configuration variable names, but I thought we avoid '-'
in configuration variable names in general.

We can see that we made many mistakes in the 'maintenance.'
hierarchy ...

$ git grep -h -E '^`?[^ ]*::$' Documentation/config/ | grep -e -

... but nowhere else.
Re: [GSoC Patch v8 0/7] repo: add path keys to repo info
#2839
Author: Phillip Wood
Date: Tue, 10 Nov 2026 14:40
90 lines
15263 bytes
On 09/11/2026 16:52, K Jayatheerth wrote:
> On Sun, Nov 8, 2026 at 1:27 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
>>>
>>> The path keys added in this series are:
>>>     - `path.toplevel.absolute` / `path.toplevel.relative`: The root directory
>>>       of the working tree (or an empty string in bare repositories).
>>
>> In our documentation and glossary, we call this directory the "working
>> tree" so I think "path.working-tree.*" would be a better name, rather
>> than copying the name from the equivalent rev-parse option.
>>
>>>     - `path.superproject-root.absolute` / `path.superproject-root.relative`:
>>>       The root of the superproject when inside a submodule.
>>
>> Personally, I'd prefer "path.superproject-working-tree.*" here, though I
>> see Justin thought that was a bit of a mouthful. As this command is for
>> use in scripts I'd rather have a descriptive name.
>>
> 
> I don't have an opinion on the name itself, but, that said:
> I think superproject-working-tree is a more suiting name.
> It is becuase you may have a working tree in a different place and it
> might not be the root itself.
> I think the same logic applies for toplevel too.
> 
> Any more thoughts from Justin, Lucas, Junio or any other reviewer
> would be better I reckon.

Yes, that would be helpful

>>>     - `path.hooks.absolute` / `path.hooks.relative`: The repository's hooks
>>>       directory (respecting `core.hooksPath`, including `/dev/null`).
>>
>> Given we have config based hooks now, do we really want to add this?
>> Scripts that want to run hooks should be using "git hook run" and
>> scripts that want to install hooks should be using the config based
>> hooks so that they co-exist with the user's existing hooks.
>>
> 
> I believe that is a fair point for new tooling, though wouldn't many
> existing scripts
> and third-party tools still learn about hooks directly via `git
> rev-parse --git-path hooks`?
> 
> Since the main goal of `git repo info` is to provide an alternative
> to `rev-parse`'s various path flags, `path.hooks` still seems useful for scripts
> migrating over, unless the consensus is to deprecate querying the hooks
> directory altogether.

Isn't the goal to provide a better interface than rev-parse, rather than 
just porting the various path related options across unchanged? My worry 
is that by adding "path.hooks.*" we're encouraging people to use an 
outdated interface that ignores the existence of config based hooks. 
Anyone who wants to keep using "git rev-parse --git-path hooks" can do 
so, but I'd rather we didn't encourage that pattern by supporting it in 
new commands.
>>>     - `path.cdup`: The relative path from the current directory up to the
>>>       worktree root.
>>
>> How does this differ from path.working-tree.relative? I've never really
>> understood "git rev-parse --cdup" - if you're in the repository root
>> directory, 'cd "$(git rev-parse --cdup)"' dumps you in your home
>> directory which has always seemed a bit surprising to me.
>>
> 
> Well looking at the code itself
> What I can say is I find couple of edge cases,
> 
> The cdup command relies on a slash counting loop on the prefix string
> to output directory-up
> sequences like '../', returns an empty string at the root and falls
> back to the worktree path when outside.
> 
> On the contrary, relative formatting uses Git's path utility library
> to compute true relative
> filesystem paths, outputting '.' at the root instead of leaving it blank.

Right - but what practical benefit does "path.cdup" offer over 
"path.working-tree.relative"? "git rev-parse --cdup" was added in 
5f94c730f3 (rev-parse: --show-cdup, 2005-12-22), four years before 
"--show-toplevel" in 7cceca5ccc (Add 'git rev-parse --show-toplevel' 
option., 2010-01-12) and 15 years before support for relative paths in 
fac60b8925 (rev-parse: add option for absolute or relative path 
formatting, 2020-12-13). So when it was added "--cdup" was the only way 
to find the root of the repository working tree, which is not the case now.

Thanks

Phillip
Re: [GSoC Patch v8 0/7] repo: add path keys to repo info
#2870
Author: Phillip Wood
Date: Tue, 10 Nov 2026 14:43
24 lines
11983 bytes
Hi Junio

On 09/11/2026 19:53, Junio C Hamano wrote:
> 
> Syntactically you could put anything at the second level of
> three-level configuration variable names, but I thought we avoid '-'
> in configuration variable names in general.
> 
> We can see that we made many mistakes in the 'maintenance.'
> hierarchy ...
> 
> $ git grep -h -E '^`?[^ ]*::$' Documentation/config/ | grep -e -
> 
> ... but nowhere else.

These aren't actually config keys, but we do seem to have added 
"path.gitdir.*" and "path.commondir.*" rather than "path.git-dir.*" and 
"path.common-dir.*" so dropping the dashes would be consistent with the 
existing path keys.

Thanks

Phillip
Re: [GSoC Patch v8 0/7] repo: add path keys to repo info
#2913
Author: K Jayatheerth
Date: Wed, 11 Nov 2026 09:03
120 lines
16726 bytes
On Tue, Nov 10, 2026 at 8:10 PM Phillip Wood <phillip.wood123@gmail.com> wrote:
>
> On 09/11/2026 16:52, K Jayatheerth wrote:
> > On Sun, Nov 8, 2026 at 1:27 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
> >>>
> >>> The path keys added in this series are:
> >>>     - `path.toplevel.absolute` / `path.toplevel.relative`: The root directory
> >>>       of the working tree (or an empty string in bare repositories).
> >>
> >> In our documentation and glossary, we call this directory the "working
> >> tree" so I think "path.working-tree.*" would be a better name, rather
> >> than copying the name from the equivalent rev-parse option.
> >>
> >>>     - `path.superproject-root.absolute` / `path.superproject-root.relative`:
> >>>       The root of the superproject when inside a submodule.
> >>
> >> Personally, I'd prefer "path.superproject-working-tree.*" here, though I
> >> see Justin thought that was a bit of a mouthful. As this command is for
> >> use in scripts I'd rather have a descriptive name.
> >>
> >
> > I don't have an opinion on the name itself, but, that said:
> > I think superproject-working-tree is a more suiting name.
> > It is becuase you may have a working tree in a different place and it
> > might not be the root itself.
> > I think the same logic applies for toplevel too.
> >
> > Any more thoughts from Justin, Lucas, Junio or any other reviewer
> > would be better I reckon.
>
> Yes, that would be helpful
>
> >>>     - `path.hooks.absolute` / `path.hooks.relative`: The repository's hooks
> >>>       directory (respecting `core.hooksPath`, including `/dev/null`).
> >>
> >> Given we have config based hooks now, do we really want to add this?
> >> Scripts that want to run hooks should be using "git hook run" and
> >> scripts that want to install hooks should be using the config based
> >> hooks so that they co-exist with the user's existing hooks.
> >>
> >
> > I believe that is a fair point for new tooling, though wouldn't many
> > existing scripts
> > and third-party tools still learn about hooks directly via `git
> > rev-parse --git-path hooks`?
> >
> > Since the main goal of `git repo info` is to provide an alternative
> > to `rev-parse`'s various path flags, `path.hooks` still seems useful for scripts
> > migrating over, unless the consensus is to deprecate querying the hooks
> > directory altogether.
>
> Isn't the goal to provide a better interface than rev-parse, rather than
> just porting the various path related options across unchanged? My worry
> is that by adding "path.hooks.*" we're encouraging people to use an
> outdated interface that ignores the existence of config based hooks.
> Anyone who wants to keep using "git rev-parse --git-path hooks" can do
> so, but I'd rather we didn't encourage that pattern by supporting it in
> new commands.

Well, rev-parse is one way people can use it to access, so sure, I
will drop this patch.

> >>>     - `path.cdup`: The relative path from the current directory up to the
> >>>       worktree root.
> >>
> >> How does this differ from path.working-tree.relative? I've never really
> >> understood "git rev-parse --cdup" - if you're in the repository root
> >> directory, 'cd "$(git rev-parse --cdup)"' dumps you in your home
> >> directory which has always seemed a bit surprising to me.
> >>
> >
> > Well looking at the code itself
> > What I can say is I find couple of edge cases,
> >
> > The cdup command relies on a slash counting loop on the prefix string
> > to output directory-up
> > sequences like '../', returns an empty string at the root and falls
> > back to the worktree path when outside.
> >
> > On the contrary, relative formatting uses Git's path utility library
> > to compute true relative
> > filesystem paths, outputting '.' at the root instead of leaving it blank.
>
> Right - but what practical benefit does "path.cdup" offer over
> "path.working-tree.relative"? "git rev-parse --cdup" was added in
> 5f94c730f3 (rev-parse: --show-cdup, 2005-12-22), four years before
> "--show-toplevel" in 7cceca5ccc (Add 'git rev-parse --show-toplevel'
> option., 2010-01-12) and 15 years before support for relative paths in
> fac60b8925 (rev-parse: add option for absolute or relative path
> formatting, 2020-12-13). So when it was added "--cdup" was the only way
> to find the root of the repository working tree, which is not the case now.
>

Well, you are right, it adds nothing new per se.
I was replicating rev-parse without any benefit in both these cases.

Same logic applies, I will drop both these patches.

> Thanks
>
> Phillip
>

Thanks for the review Phillip!

Regards,
- K Jayatheerth
Re: [GSoC Patch v8 0/7] repo: add path keys to repo info
#2914
Author: K Jayatheerth
Date: Wed, 11 Nov 2026 09:05
35 lines
12702 bytes
On Tue, Nov 10, 2026 at 1:23 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> K Jayatheerth <jayatheerthkulkarni2005@gmail.com> writes:
>
> >> >    - `path.superproject-root.absolute` / `path.superproject-root.relative`:
> >> >      The root of the superproject when inside a submodule.
> >>
> >> Personally, I'd prefer "path.superproject-working-tree.*" here, though I
> >> see Justin thought that was a bit of a mouthful. As this command is for
> >> use in scripts I'd rather have a descriptive name.
> >
> > I don't have an opinion on the name itself, but, that said:
> > I think superproject-working-tree is a more suiting name.
>
> Syntactically you could put anything at the second level of
> three-level configuration variable names, but I thought we avoid '-'
> in configuration variable names in general.
>
> We can see that we made many mistakes in the 'maintenance.'
> hierarchy ...
>
> $ git grep -h -E '^`?[^ ]*::$' Documentation/config/ | grep -e -
>
> ... but nowhere else.

As echoed by Phillip below, I will avoid the hyphens.

Thank you!

- K Jayatheerth
Re: [GSoC Patch v8 0/7] repo: add path keys to repo info
#2922
Author: Phillip Wood
Date: Wed, 11 Nov 2026 14:03
15 lines
11456 bytes
Hi

On 11/11/2026 09:03, K Jayatheerth wrote:
> 
> Well, you are right, it adds nothing new per se.
> I was replicating rev-parse without any benefit in both these cases.
> 
> Same logic applies, I will drop both these patches.

That's great, I look forward to reading V9

Thanks

Phillip
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads