From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E09A2286D5E for ; Mon, 23 Feb 2026 14:21:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771856476; cv=none; b=pfDj1KKYvMONsO5uSAkPt7Ef1IYbbJOIqIOEZdr22dDec/dJZuhf4U8QywxDix+uDayEbGWH35DMws3ftFTGaIJ87EL6nHfRn6/i4y3iKatSVYwHZQfWJB1fmscboOPjcJuvPuNhrAre7TY/ie7fl8hwLQ7nXijXjKdvPdbQ1ZE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771856476; c=relaxed/simple; bh=OjNb9GbMmvoo/AvzqMKMll5S6aCm26qmvy45GbcFE+Y=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=fz+Tq706KHlkEgw4PyvJvnUZfvs/lQ09l7MvIRc4VA2hKx8X1aa1LLmlwqMv157H4ua07eQ763j30bktbyF/TqEmM1U2RE1dS7xN/lGvvORM0ebp+j+9QLLYo5ZqC86iAvb/nqaasPnDHZZS+d936FIkCwEp8zsjQRuW5qQkq0A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LepXwFz6; arc=none smtp.client-ip=209.85.222.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LepXwFz6" Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-8cb3e22435fso437399485a.1 for ; Mon, 23 Feb 2026 06:21:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771856473; x=1772461273; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=SMW1I8meSSb/l+AUNZEA2AyUORzirRK8gxnH32iO8mE=; b=LepXwFz6iObO3/xeaSP5lfQ7qPVtcv33sdsvL5VWp2JZvQlzIrTAXaf+Ai+iHtGL6g NRuESfZQhEXd4G+5eR/hk5AVXcxzVbnyT2o0oHzRdvTbPtJvMUceQjVSEGomQ7Ll52pC 7gUAvjdTd9+j9LQ+nnsianRisLMLwcu4U/A71o8LrgExXMwF1gmfvL38xSYccpR5UzDp 2ayuWi9qhCTbpnmQKIY5JFTR2l1vyD910cQx2IP7WnUTNCMZh3gjouv5sRmDarg+rHCL UkDFtHt0+iv+yXXzm6DPigmiwt11feZoEQTo3LfBZtsRl6zO0KVN/N2QgOXzHRJDfF4m uHtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771856473; x=1772461273; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=SMW1I8meSSb/l+AUNZEA2AyUORzirRK8gxnH32iO8mE=; b=vuc9m2LtqI2xqGfrpFEdZm8Yg9qV+2rehYoen3xJZEx/dGr7lL8mfo27Fyyj3Nd2mL b9mQfzom92UwE8SYCFCrgSkcCz1RAcwykZqy/VITt0UfI9xdW9h6o4muWasBtvTBRo4R as8EbjnKmvm+IkSsTwO8y5T2mc8jsdSYXy4ESZpsMbVenalIdojZa/mJP0lZKccHwDO8 Kc8uPC+HimvKHLXfAkLl88IpH1qommxd8+IqYxQXjZOSIpHQcx8UuerC8mDcG4kCCQiz LUSDkUyTp66CSo/AGBsRJVwGKiPZhq/8Tx0ZZQNHxpPQFlwBNjh3dRCYLPxZiqKS456H dMqA== X-Gm-Message-State: AOJu0YzlfOAqr0Ue5HlU9GzsJIEZnY3SGxbSl3oOribsTnGjIOAMKEw7 /LkRylEDQXvv29nnjwOlFII6shlVDDrb3xNjWbf2ilTiQfxBZZmvUr7WyWMK9A== X-Gm-Gg: AZuq6aJVMKcvr/qFEHfRcekTyxqhIzR1+c9oHs2iwMyxqVdyNWdndDGir6OYoCpbaNU nkvxVHX9Tq2prX455ZlqOkza6aTgcDIs++Oqh+IWTfbGCInvreI36uMQoOPk8TZaHdH5oi09pcd HNvDiZD2746IdxMX4I0CSgsnzT0ZuuZHyS88qKNb4oLPFm1I2rofK8mdbkhD2ejn18QEYjH3zgL pJ2mw8sorZ96Ds02Thf4zmRpe8x2rSpO+bvxosCPVfYTnsmwbvoz+f1edFJRap5nqXfBAtMBtXR hLUkmOXGCivUVjIl9KD1kqa66oWEH9zc8rEC43A83paPvRpj7Y73YyUv2aZtqvbtT9lWlTwaJL3 0wRfgzfKL2Ix0jQRm1C//iE8IiXv5lpw2hNYGckkXEjqWoee1xexf/b7tIB0lgX8QWToGLSbi8t BDv3Mq2iNWjqxPlbKlb4sBcqA= X-Received: by 2002:a05:622a:452:b0:4ff:b32b:cdf9 with SMTP id d75a77b69052e-5070bf6d4ddmr102718521cf.14.1771856473196; Mon, 23 Feb 2026 06:21:13 -0800 (PST) Received: from [127.0.0.1] ([20.55.15.231]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-5070d6a2299sm67526711cf.19.2026.02.23.06.21.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 06:21:12 -0800 (PST) Message-Id: <6d5b9ff07566e1cc28a672cf1f47988e9c8c45da.1771856469.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Eslam reda ragheb via GitGitGadget" Date: Mon, 23 Feb 2026 14:21:02 +0000 Subject: [PATCH v2 2/9] repo: add path keys to repo info Fcc: Sent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Karthik Nayak , Justin Tobler , Ayush Chandekar , Siddharth Asthana , Lucas Seiki Oshiro , eslam reda , Eslam reda ragheb From: Eslam reda ragheb Add a path category to git repo info with key-value pairs that mirror repository paths users commonly retrieve via rev-parse and git-path lookups. This makes scripting against repo metadata more direct and avoids shelling out to multiple commands for related paths. The new keys are introduced as explicit path.* entries in repo_info_fields and are resolved through dedicated helpers. This keeps lookup behavior predictable and makes future path additions straightforward. Signed-off-by: Eslam reda ragheb --- builtin/repo.c | 137 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) diff --git a/builtin/repo.c b/builtin/repo.c index e34914a9a7..35e1eaf7d7 100644 --- a/builtin/repo.c +++ b/builtin/repo.c @@ -1,10 +1,12 @@ #define USE_THE_REPOSITORY_VARIABLE #include "builtin.h" +#include "abspath.h" #include "environment.h" #include "hex.h" #include "odb.h" #include "parse-options.h" +#include "path.h" #include "path-walk.h" #include "progress.h" #include "quote.h" @@ -14,6 +16,7 @@ #include "strbuf.h" #include "string-list.h" #include "shallow.h" +#include "submodule.h" #include "utf8.h" static const char *const repo_usage[] = { @@ -40,6 +43,13 @@ struct field { get_value_fn *get_value; }; +static void repo_info_add_path(struct repo_info *info, + struct strbuf *buf, + const char *path) +{ + strbuf_add_absolute_path(buf, path); +} + static int get_layout_bare(struct repo_info *info UNUSED, struct strbuf *buf) { strbuf_addstr(buf, is_bare_repository() ? "true" : "false"); @@ -61,6 +71,119 @@ static int get_object_format(struct repo_info *info, struct strbuf *buf) return 0; } +static int get_path_common_dir(struct repo_info *info, struct strbuf *buf) +{ + repo_info_add_path(info, buf, repo_get_common_dir(info->repo)); + return 0; +} + +static int get_path_config_file(struct repo_info *info, struct strbuf *buf) +{ + struct strbuf path = STRBUF_INIT; + + repo_info_add_path(info, buf, repo_git_path_replace(info->repo, &path, "config")); + strbuf_release(&path); + return 0; +} + +static int get_path_git_dir(struct repo_info *info, struct strbuf *buf) +{ + repo_info_add_path(info, buf, repo_get_git_dir(info->repo)); + return 0; +} + +static int get_path_git_prefix(struct repo_info *info, struct strbuf *buf) +{ + if (info->prefix) + strbuf_addstr(buf, info->prefix); + return 0; +} + +static int get_path_grafts_file(struct repo_info *info, struct strbuf *buf) +{ + repo_info_add_path(info, buf, repo_get_graft_file(info->repo)); + return 0; +} + +static int get_path_hooks_directory(struct repo_info *info, struct strbuf *buf) +{ + struct strbuf path = STRBUF_INIT; + + repo_info_add_path(info, buf, repo_git_path_replace(info->repo, &path, "hooks")); + strbuf_release(&path); + return 0; +} + +static int get_path_index_file(struct repo_info *info, struct strbuf *buf) +{ + repo_info_add_path(info, buf, repo_get_index_file(info->repo)); + return 0; +} + +static int get_path_logs_directory(struct repo_info *info, struct strbuf *buf) +{ + struct strbuf path = STRBUF_INIT; + + repo_info_add_path(info, buf, repo_git_path_replace(info->repo, &path, "logs")); + strbuf_release(&path); + return 0; +} + +static int get_path_objects_directory(struct repo_info *info, struct strbuf *buf) +{ + repo_info_add_path(info, buf, repo_get_object_directory(info->repo)); + return 0; +} + +static int get_path_packed_refs_file(struct repo_info *info, struct strbuf *buf) +{ + struct strbuf path = STRBUF_INIT; + + repo_info_add_path(info, buf, repo_git_path_replace(info->repo, &path, "packed-refs")); + strbuf_release(&path); + return 0; +} + +static int get_path_refs_directory(struct repo_info *info, struct strbuf *buf) +{ + struct strbuf path = STRBUF_INIT; + + repo_info_add_path(info, buf, repo_git_path_replace(info->repo, &path, "refs")); + strbuf_release(&path); + return 0; +} + +static int get_path_shallow_file(struct repo_info *info, struct strbuf *buf) +{ + struct strbuf path = STRBUF_INIT; + + repo_info_add_path(info, buf, repo_git_path_replace(info->repo, &path, "shallow")); + strbuf_release(&path); + return 0; +} + +static int get_path_superproject_working_tree(struct repo_info *info, + struct strbuf *buf) +{ + struct strbuf superproject = STRBUF_INIT; + + if (get_superproject_working_tree(&superproject)) + repo_info_add_path(info, buf, superproject.buf); + + strbuf_release(&superproject); + return 0; +} + +static int get_path_toplevel(struct repo_info *info, struct strbuf *buf) +{ + const char *work_tree = repo_get_work_tree(info->repo); + + if (work_tree) + repo_info_add_path(info, buf, work_tree); + + return 0; +} + static int get_references_format(struct repo_info *info, struct strbuf *buf) { struct repository *repo = info->repo; @@ -74,6 +197,20 @@ static const struct field repo_info_fields[] = { { "layout.bare", get_layout_bare }, { "layout.shallow", get_layout_shallow }, { "object.format", get_object_format }, + { "path.common-dir", get_path_common_dir }, + { "path.config-file", get_path_config_file }, + { "path.git-dir", get_path_git_dir }, + { "path.git-prefix", get_path_git_prefix }, + { "path.grafts-file", get_path_grafts_file }, + { "path.hooks-directory", get_path_hooks_directory }, + { "path.index-file", get_path_index_file }, + { "path.logs-directory", get_path_logs_directory }, + { "path.objects-directory", get_path_objects_directory }, + { "path.packed-refs-file", get_path_packed_refs_file }, + { "path.refs-directory", get_path_refs_directory }, + { "path.shallow-file", get_path_shallow_file }, + { "path.superproject-working-tree", get_path_superproject_working_tree }, + { "path.toplevel", get_path_toplevel }, { "references.format", get_references_format }, }; -- gitgitgadget