From: Junio C Hamano Date: Thu, 30 Jul 2026 17:44:37 +0000 (-0700) Subject: Merge branch 'kj/repo-info-more-path-keys' into seen X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=62bfa5d55613526f9dbcfdf750f783cfc151884a;p=thirdparty%2Fgit.git Merge branch 'kj/repo-info-more-path-keys' into seen The 'git repo info' command has been taught more keys to output paths of various repository components (such as the working tree root, superproject working tree, object database, etc.), supporting both absolute and relative path formats. * kj/repo-info-more-path-keys: repo: add path.git-prefix path key repo: add path.grafts with absolute and relative suffix formatting repo: add path.index with absolute and relative suffix formatting repo: add path.hooks with absolute and relative suffix formatting repo: add path.objects with absolute and relative suffix formatting repo: add path.superproject-working-tree with absolute and relative suffixes repo: add path.toplevel with absolute and relative suffix formatting --- 62bfa5d55613526f9dbcfdf750f783cfc151884a diff --cc builtin/repo.c index 84e012f83f,b93c140c74..742bc8d44a --- a/builtin/repo.c +++ b/builtin/repo.c @@@ -99,6 -100,16 +100,16 @@@ static int get_path_commondir_relative( return 0; } -static int get_path_git_prefix(struct repository *repo UNUSED, struct strbuf *buf) ++static int get_path_git_prefix(struct repository *repo, struct strbuf *buf) + { + /* - * startup_info->prefix is NULL if we are at the working tree root. ++ * repo->prefix is NULL if we are at the working tree root. + * We add an empty string to ensure the buffer is cleanly initialized. + */ - strbuf_addstr(buf, startup_info->prefix ? startup_info->prefix : ""); ++ 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); @@@ -121,6 -132,148 +132,148 @@@ static int get_path_gitdir_relative(str return 0; } + static int get_path_grafts_absolute(struct repository *repo, struct strbuf *buf) + { + const char *graft_file = repo_get_graft_file(repo); + + if (!graft_file) + return error(_("unable to get graft file")); + - format_path(buf, graft_file, startup_info->prefix, PATH_FORMAT_CANONICAL); ++ format_path(buf, graft_file, repo->prefix, PATH_FORMAT_CANONICAL); + return 0; + } + + static int get_path_grafts_relative(struct repository *repo, struct strbuf *buf) + { + const char *graft_file = repo_get_graft_file(repo); + + if (!graft_file) + return error(_("unable to get graft file")); + - format_path(buf, graft_file, startup_info->prefix, PATH_FORMAT_RELATIVE); ++ format_path(buf, graft_file, repo->prefix, PATH_FORMAT_RELATIVE); + 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"); - format_path(buf, hooks_path.buf, startup_info->prefix, PATH_FORMAT_CANONICAL); ++ format_path(buf, hooks_path.buf, repo->prefix, 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"); - format_path(buf, hooks_path.buf, startup_info->prefix, PATH_FORMAT_RELATIVE); ++ format_path(buf, hooks_path.buf, repo->prefix, PATH_FORMAT_RELATIVE); + strbuf_release(&hooks_path); + return 0; + } + + static int get_path_index_absolute(struct repository *repo, struct strbuf *buf) + { + const char *index_file = repo_get_index_file(repo); + + if (!index_file) + return error(_("unable to get index file")); + - format_path(buf, index_file, startup_info->prefix, PATH_FORMAT_CANONICAL); ++ format_path(buf, index_file, repo->prefix, 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); + + if (!index_file) + return error(_("unable to get index file")); + - format_path(buf, index_file, startup_info->prefix, PATH_FORMAT_RELATIVE); ++ format_path(buf, index_file, repo->prefix, PATH_FORMAT_RELATIVE); + return 0; + } + + static int get_path_objects_absolute(struct repository *repo, struct strbuf *buf) + { + const char *obj_dir = repo_get_object_directory(repo); + + if (!obj_dir) + return error(_("unable to get object directory")); + - format_path(buf, obj_dir, startup_info->prefix, PATH_FORMAT_CANONICAL); ++ format_path(buf, obj_dir, repo->prefix, PATH_FORMAT_CANONICAL); + return 0; + } + + static int get_path_objects_relative(struct repository *repo, struct strbuf *buf) + { + const char *obj_dir = repo_get_object_directory(repo); + + if (!obj_dir) + return error(_("unable to get object directory")); + - format_path(buf, obj_dir, startup_info->prefix, PATH_FORMAT_RELATIVE); ++ format_path(buf, obj_dir, repo->prefix, PATH_FORMAT_RELATIVE); + return 0; + } + -static int get_path_superproject_absolute(struct repository *repo UNUSED, struct strbuf *buf) ++static int get_path_superproject_absolute(struct repository *repo, struct strbuf *buf) + { + struct strbuf superproject = STRBUF_INIT; + + if (!get_superproject_working_tree(&superproject)) { + strbuf_release(&superproject); + strbuf_addstr(buf, ""); + return 0; + } + - format_path(buf, superproject.buf, startup_info->prefix, PATH_FORMAT_CANONICAL); ++ format_path(buf, superproject.buf, repo->prefix, PATH_FORMAT_CANONICAL); + strbuf_release(&superproject); + return 0; + } + -static int get_path_superproject_relative(struct repository *repo UNUSED, struct strbuf *buf) ++static int get_path_superproject_relative(struct repository *repo, struct strbuf *buf) + { + struct strbuf superproject = STRBUF_INIT; + + if (!get_superproject_working_tree(&superproject)) { + strbuf_release(&superproject); + strbuf_addstr(buf, ""); + return 0; + } + - format_path(buf, superproject.buf, startup_info->prefix, PATH_FORMAT_RELATIVE); ++ 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); + + if (!work_tree) { + strbuf_addstr(buf, ""); + return 0; + } + - format_path(buf, work_tree, startup_info->prefix, PATH_FORMAT_CANONICAL); ++ format_path(buf, work_tree, repo->prefix, 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) { + strbuf_addstr(buf, ""); + return 0; + } + - format_path(buf, work_tree, startup_info->prefix, PATH_FORMAT_RELATIVE); ++ 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,