Article View: linux.kernel.git
Article #2189Re: [GSoC Patch v7 4/8] repo: add path.hooks with absolute and relative suffixes
From: Justin Tobler
Date: Mon, 02 Nov 2026 22:32
Date: Mon, 02 Nov 2026 22:32
118 lines
15770 bytes
15770 bytes
On 26/09/27 05:14PM, K Jayatheerth wrote:
> 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 | 9 +++++++++
> builtin/repo.c | 22 ++++++++++++++++++++++
> t/t1900-repo-info.sh | 28 ++++++++++++++++++++++++++--
> 3 files changed, 57 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
> index e524a07f53..20836cf8f6 100644
> --- a/Documentation/git-repo.adoc
> +++ b/Documentation/git-repo.adoc
> @@ -119,6 +119,15 @@ 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.
So if a repository has `core.hooksPath` set to "/dev/null", the relative
path output here would be something like "../../../../dev/null". I
recognize that this matches the current behavior:
$ git -c core.hooksPath=/dev/null rev-parse --path-format=relative --git-path hooks
../../../../dev/null
...but I'm still not really convinced that is is a behavior we would
want to carry over as it makes it harder to users to figure out when
hooks are disabled.
I would suggest we print the "/dev/null" here even when the relative
path is requested and document the behavior.
[snip]
> diff --git a/t/t1900-repo-info.sh b/t/t1900-repo-info.sh
> index eec576a1d9..1da5db4942 100755
> --- a/t/t1900-repo-info.sh
> +++ b/t/t1900-repo-info.sh
> @@ -174,7 +174,11 @@ 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
> )
> @@ -188,7 +192,11 @@ 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
> )
From what I can gather, the code changes to this test helper is really
only required for the "/dev/null" test case. IMO, this helper function
has now become quite unwieldy and rather difficult to parse.
I think we would be better off writing the "/dev/null" test case by hand.
> @@ -213,6 +221,22 @@ 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"'
> +
> +# /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
I'm not quite sure I follow here. Are we saying that the git-repo-info
command won't work on windows if the hooks are set to "/dev/null"? Or is
it just some issue with how the test is written? If its the latter,
maybe this is something we can work around if the test is written
without the use of the `test_repo_info_path` helper?
-Justin
Technical Details
Message-ID:
<aukHlEd5udC1gLYZ@denethor>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74232-linux-kernel-git=dewy.ruReferences:
<20260716012138.6714-1-jayatheerthkulkarni2005@gmail.com> <20260927114420.59724-1-jayatheerthkulkarni2005@gmail.com> <20260927114420.59724-5-jayatheerthkulkarni2005@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74232-linux-kernel-git=dewy.ru
From: jltobler@gmail.com (Justin Tobler)
Newsgroups: linux.kernel.git
Subject: Re: [GSoC Patch v7 4/8] repo: add path.hooks with absolute and
relative suffixes
Date: Mon, 2 Nov 2026 16:32:02 -0600
Organization: Usenet Network
Message-ID: <aukHlEd5udC1gLYZ@denethor>
References: <20260716012138.6714-1-jayatheerthkulkarni2005@gmail.com>
<20260927114420.59724-1-jayatheerthkulkarni2005@gmail.com>
<20260927114420.59724-5-jayatheerthkulkarni2005@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
logging-data="3046121"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:sJhqxsfA1JZLBlX28drvb89BvFs= sha256:bUkyyFh+OI1bBWGXQNxs5A7aAaUpZIjUi7U8nzh1xUo=
sha1:Ec1e9jWV2Vcc8w7SM9AJsuw/b5s= sha256:YC1ppw7l4UaQF9/NKEnNx224MLX+2uE0qapE3hPJfBA=
Content-Disposition: inline
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 6AC891126B8; Tue, 3 Nov 2026 01:32:46 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id eHf7QbPTc594;
Tue, 3 Nov 2026 01:32:43 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=git+bounces-74232-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id 89C6C1126B3; Tue, 3 Nov 2026 01:32:35 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by tor.lore.kernel.org (Postfix) with ESMTP id C13C225BFC; Mon, 2 Nov 2026 22:32:26 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1793658745;
b=Jlq97deIN+D+ihO5FqamkaVCXCfokOcjwxhjnd93du+SutXZocXflsCSb1WJykuKYBzE
DHB5G+ql3JpTSxlwr7bWJMLEeYDu8AIFw7ggGHt2Vo5GB2h9Cyd1x9XokI4D0aecO+tDk
SEvqa6YYef2VZDI8tO8/PIbscX5zWC81qd5R41koECMOXnWiE8lYixjgWnJ9fDH2yosFt
SxhIaxc5Y7cpKb08PuVmCRTfA6n1IZuncxUHTx7ey4N8MYptRdfTy1dSlnvlQ2SbYOec8
df+4tXZMx3shjgI/3c4pFtPsrFASoT8XkqLdcUNVCMEjPGHIBcECaqOwJUxB8/JHMRQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793658745;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:Date:From:To:Cc:Subject:Message-ID:References:X-Mailing-List:
List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
List-Owner:Precedence:MIME-Version:Content-Type:Content-Disposition:
In-Reply-To;
bh=qQS5/cXNdBgcAPgXcoDIsdMuZRkpfbfkunYbHgb7iwY=;
b=gvnQpi9c9of4JJNQtbn0c5z3xa2TWAnap+077Uz3f78Glnx3Jf/rpmVTrqGUNEtifyyH
rpL1VBuPvh2cROdlM0By66QKWElIy8ag+SckhKl2vJCCJeUbaxlzrhjO3qpcf0Oxxt+LO
bqpQYoRAW15BxI6V6PlaM1Am2yZxDrUipKJhF39QuUiLtibp3rHWjjzT95aaFkbWy+xdI
mtPC1QbZeGRbX9ePEPBt93OqeiFX8Bz6TYUWiV3P3ifjzu8uddrcQk8XF2rh0OvNu77vs
sjhWQ4pCagLS5uSrU7glPSlNftk5FvrykFMW4odz0VPMgYa9aU5V4VAAOTpPwOS9KTg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Bk67Xjhd;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C931606A32F;
Mon, 2 Nov 2026 22:32:25 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Bk67Xjhd
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.176
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1793658744;
b=wnCNmRbIHiv9nodcfxNKl1oWwxugU6Tw6GNOdrRMLsMGJR644utMXh/Y/PFgv4NQOAfs
zRdX3utGXSJzmCrD+XXLJfBLEOUTpJbI5bwmnaQCWnnTr9iU71/9Q0SYbXZ5Vi4Ea8N4L
prI5D5iM8FO3SGU0cEQkTMJ5LH8jnY1MBlFJpQFe++Ui4Vo2c0hAA2TKBNfacCUqvq3Wm
3PJXEWlFOmhq67qZhSo2VFD4oH5aq3k3QiISv1kK8DnthVI4Bbfov2Qf2C6LdBqBeZoHK
RPn+w6qmkk+LWkvMBvjTaCRqh4LpFzWdFw7fcgbEK0vRdlei2DZfw127JnkV85/zXgg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793658744;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Date:From:To:Cc:
Subject:Message-ID:References:MIME-Version:Content-Type:
Content-Disposition:In-Reply-To;
bh=qQS5/cXNdBgcAPgXcoDIsdMuZRkpfbfkunYbHgb7iwY=;
b=ev8x4UT0xDoa1mPNiDe6ujDWzWImXiUQYzgtscrykxTnnnaFpDiEnTtaCUOS3tNI8m8n
HVQqvIL7SmcIcxwti/OPDsL0CvJQWbVa68ylHEQuHL3+Q++ip+o7oJElTBE8UjG5O7mll
7fMgbCQgnnTvqmg7dajtJNpo+2rSpX6CqJCMIry8L2DeCLQ7txdGMsRJ/zIgyx/7cLZco
bKvvxr6aE0NmddHlewueaRiX2eBBryrGWvyO8pbsxZVhcYTlOnCnFy9So5O20kf3sjPpH
qxSxdo8zDZnT6mgNv1FJtQz9JLc512rG9e1eV3/uiR4mdoJRhxxvCLYyzfUsbszbMnA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Bk67Xjhd;
arc=none smtp.remote-ip=209.85.167.176
X-Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7AC2606A324
for <git@vger.kernel.org>; Mon, 2 Nov 2026 22:32:23 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D7AC2606A324
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-oi1-f176.google.com with SMTP id 5614622812f47-4e4a4d77e5bso76283b6e.0
for <git@vger.kernel.org>; Mon, 02 Nov 2026 14:32:23 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1793658743; x=1794263543; darn=vger.kernel.org;
h=in-reply-to:content-disposition:content-type:mime-version
:references:message-id:subject:cc:to:from:date:from:to:cc:subject
:date:message-id:reply-to:content-type;
bh=qQS5/cXNdBgcAPgXcoDIsdMuZRkpfbfkunYbHgb7iwY=;
b=Bk67XjhdFTa5VEDGVU+0VhgI1yIEhm8wz72u/ZQIJ74NEGsNaDWkkbOKCUGUPMRZLt
E7Jcm4EaLfaCtv0eHgxq9E0iZpGuPpHce7br2Oo/VKWuYMBgOua7Xv7bZftFM/lGGqfY
WXaJ7damzgEy9CCtw61IE2NHEPuBbCADGNoBiSIkqGPnSPt18nZ74/6mCloJHraZtHd1
1nLRiRXT8HTyjom25lkdCAcnA4V3RWG5Be7XhBZ71mS5r+qiDD5Sa1VaE1gss27nDpG4
tfXLxIaEPxrEAzgM7EEuswGW+PCEC7BBlonThfhKjvTRCjkLvdHm03M3grTE9jw8BCfJ
oL3w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1793658743; x=1794263543;
h=in-reply-to:content-disposition:content-type:mime-version
:references:message-id:subject:cc:to:from:date:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=qQS5/cXNdBgcAPgXcoDIsdMuZRkpfbfkunYbHgb7iwY=;
b=pTHeRXUDbIXexUFEvLRSKg+VNLAaSJve/cBjddJwNbdlhe+SVpdNW7WMCTh+G9ef1w
FhqQOfjnxDzX8aZzYauf7rv8mK5mf4YjFQTxckV3a3PZVDW5vgt/0Lzbus5X7dfyWwRO
z8gUvtkb1rjO+ZqIqQra1lfzPC8cppeCmDbZ7xyzQNPz6XmuPmVQdZ+Wto0qAlOMevSC
fBJXcyyyVWovwlatY/hAooJ4wtPgpojriz3F0ZkhaysXwRD8XFrvJmtvx5OCOjxIe9fh
ZBL81QifhfW7qmX8rsRagB0Z4oELq1QTY1PWhEp23Zfx20FP94nueDpMUj7lGbU5tEqM
FJ6g==
X-Gm-Message-State: AFq9FYKnmsPKdgKE/1QW+roXL5YWW9ck/KLLhQBhqVNvuFvbWHTimXnJ
huqZ4c/KJez9ngsnXNMedG0XnzqAkz7zFAGvjSs4FOkvLZkl1CD08SYHW2phfA==
X-Gm-Gg: AYBFou0Q8mA/ccoRZ+28V1RAdHOAcwUAJnUVhoSxMgRhqBTmrD+4oIP/2fLB1oRxnUX
6EpdZ6Olr/IEZR0M0HGPQO8x97zcdiIQ6cz81Zkaryk/txXUI0qsAhqcbJjxJ4lR0V+dwggpU1v
7e4RdM7PQ77osRf0YmBkw2m65Ou8RnhnRAVgsOZtL2ipxABNC9TEBzW/UjlnLJs1atQpGsy1LFx
U6UaiQe12zIHgTpjonDwMcn33FZGmimhs05wtPqht89nRzIhYp1nhCNkyFpNSNF1u1xyFlT6nTj
nesNYwYo+SUq4GU0gP4JNIKgbdEeSkYAA6LwaEfjuKICfanbGML5RsO5+bGm1ctw5Aqrqd7opER
RmTMzEFujSUfPGqkHE347V4rPAzihaSSrOtiFMIpAj7bpOAp3rmsbHb0vAS3DhLgeGyhg0+Btsh
rjxSwoadNlCEto0fYK0UmBfiMtEKy8qlvubBZHRmeZGZKCX5d0tHSi66PuPXimF90hed4BsHjlj
1TvGsUY2JfiJIqf+NfKrCjbfAB+BufrhDRlqi81IuUGvtAJsPBFcoNUzX0BXH4fCJl/APgIuXXJ
UQYg0OxFACLoPgmg6pObEKSR/B6FOuQVJvNWnbyjhtqqg1rcopd7uz7J3TdUuuvffeLGz7KTGg=
=
X-Received: by 2002:a05:6809:297:10b0:564:3e9e:b4b1 with SMTP id 5614622812f47-5643e9ebc20mr1805647b6e.18.1793658742569;
Mon, 02 Nov 2026 14:32:22 -0800 (PST)
X-Received: from localhost ([136.51.44.64])
by smtp.gmail.com with ESMTPSA id 5614622812f47-5640fc49923sm8786598b6e.1.2026.11.02.14.32.09
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Mon, 02 Nov 2026 14:32:10 -0800 (PST)
X-Cc: git@vger.kernel.org, lucasseikioshiro@gmail.com, gitster@pobox.com
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20260927114420.59724-5-jayatheerthkulkarni2005@gmail.com>