[GSoC Patch v4 0/4] teach git repo info to handle path keys
- From
K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
- Date
- Jun 15, 2026, 04:51 UTC
- Message-ID
- <20260615045112.50686-1-jayatheerthkulkarni2005@gmail.com>
- In-Reply-To
- <20260601151950.30686-1-jayatheerthkulkarni2005@gmail.com>
Hi!
This series teaches `git repo info` to handle `path.*` keys, allowing scripts to reliably discover core repository paths without resorting to `git rev-parse`.
The patches are structured as follows:
1. path: Extract the localized path-formatting logic out of `rev-parse` and expose it globally via `path.h` using clear append semantics.
2. rev-parse: Refactor the command to leverage the newly shared path engine.
3. repo: Introduce `path.commondir.absolute` and `path.commondir.relative` alongside a robust, isolated test helper.
4. repo: Introduce `path.gitdir.absolute` and `path.gitdir.relative` using the same standardized formatting rules.
Since all the questions were answered I have removed them from this cover letter.
Changes since v3: * Removed unnecessary double quotes around the `..` argument when calling `test-tool path-utils real_path` in the `test_repo_info_path` helper, as suggested by Lucas. * Retained the POSIX-compliant `ROOT="..." && export ROOT` syntax in the test setup. Combining them into `export ROOT="..."` triggered Git's strict `test-lint-shell-syntax` portability checks, so the separate assignment and export remains.
K Jayatheerth (4): path: introduce append_formatted_path() for shared path formatting rev-parse: use append_formatted_path() for path formatting repo: add path.commondir with absolute and relative suffix formatting repo: add path.gitdir with absolute and relative suffix formatting
Documentation/git-repo.adoc | 15 ++++++ builtin/repo.c | 50 +++++++++++++++++ builtin/rev-parse.c | 103 ++++++++---------------------------- path.c | 70 ++++++++++++++++++++++++ path.h | 36 +++++++++++++ t/t1900-repo-info.sh | 68 ++++++++++++++++++++++++ 6 files changed, 262 insertions(+), 80 deletions(-)
Range-diff against v3:
1: d276ac145e = 1: a396b4f8e6 path: introduce append_formatted_path() for shared path formatting
2: 5dba41bcb3 = 2: 16198f96d1 rev-parse: use append_formatted_path() for path formatting
3: b21c97f5d9 ! 3: b45c6f0d12 repo: add path.commondir with absolute and relative suffix formatting
@@ t/t1900-repo-info.sh: test_expect_success 'git repo info -h shows only repo info
+ test_expect_success "absolute: $label" '
+ (
+ cd "$absolute_root/sub" &&
-+ ROOT="$(test-tool path-utils real_path "..")" && export ROOT &&
++ ROOT="$(test-tool path-utils real_path ..)" && export ROOT &&
+ eval "$init_command" &&
+ expect_path="$ROOT${expect_absolute_suffix:+/$expect_absolute_suffix}" &&
+ echo "path.$field_name.absolute=$expect_path" >expect &&
@@ t/t1900-repo-info.sh: test_expect_success 'git repo info -h shows only repo info
+ test_expect_success "relative: $label" '
+ (
+ cd "$relative_root/sub" &&
-+ ROOT="$(test-tool path-utils real_path "..")" && export ROOT &&
++ ROOT="$(test-tool path-utils real_path ..)" && export ROOT &&
+ eval "$init_command" &&
+ echo "path.$field_name.relative=$expect_relative" >expect &&
+ git repo info "path.$field_name.relative" >actual &&
4: fd7a899788 = 4: b5234ffe3e repo: add path.gitdir with absolute and relative suffix formatting-- 2.54.0