Skip to content

repo: add support for path-related fields

Lucas Seiki Oshiro git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 21 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4rev-parse: prepend `path_` to path-related enumsbuiltin/rev-parse.c+28 -280 replies
2/4path: add new function strbuf_add_pathbuiltin/rev-parse.c path.c path.h+80 -660 replies
3/4repo: add the --format-path flagDocumentation/git-repo.adoc builtin/repo.c t/t1900-repo-info.sh+32 -70 replies
4/4repo: add the field path.toplevelbuiltin/repo.c t/t1900-repo-info.sh+98 -113 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/4] repo: add support for path-related fields

Hi!

This patch series adds support for path-related fields in repo-info, based on what we already have in git-rev-parse:

1. The two first patches moves the path formatting used by git-rev-parse to path.c. This will allow us to reuse this code in git-repo-info
2. The second patch add a new flag --path-format to git-repo-info, similar to the flag of git-rev-parse with the same name
3. Add the new field path.toplevel as a proof of concept.

This arises from the fact that I didn't know what should be the default behavior of git-repo-info when dealing with paths. Some ideas were:

1. Add --path-format, just like we have in git-rev-parse
2. Use what rev-parse uses by default
3. Add keys for both relative and absolute formats

In this case, I'm using 1, but I'm not sure if it's the best option. One downside that I see here is that git-repo-info won't be able to return a relative and an absolute path for different keys in the same call.

Since there are many people interested in contributing to git-repo-info, I'll leave the remaining path-related fields to them :-)

I'm CC'ing here:

- brian, who was the original author of the print_path [1]
- Ayush, Tian, Jayatheerth, Soutrik and Pushkar, since they expressed interested in contributing to git-repo-info in GSoC. (I hope that I didn't forget anyone)

This patch is based on top of master 2cc7191751 (The 8th batch, 2026-02-27) with lo/repo-leftover-bits merged.

[1] fac60b8925 (rev-parse: add option for absolute or relative path formatting, 2020-12-13)

Lucas Seiki Oshiro (4):
rev-parse: prepend path_ to path-related enums
path: add new function strbuf_add_path
repo: add the --format-path flag
repo: add the field path.toplevel

 Documentation/git-repo.adoc |  8 ++-
 builtin/repo.c              | 67 +++++++++++++++++++------
 builtin/rev-parse.c         | 98 +++++++------------------------------
 path.c                      | 51 +++++++++++++++++++
 path.h                      | 23 +++++++++
 t/t1900-repo-info.sh        | 69 ++++++++++++++++++++++++++
 6 files changed, 221 insertions(+), 95 deletions(-)
Signature · 1 line
2.50.1 (Apple Git-155)