Article View: linux.kernel.git
Article #3899[PATCH v5 2/3] remote: name the original URL when relative_url() fails
From: Aniket Gupta
Date: Thu, 26 Nov 2026 11:58
Date: Thu, 26 Nov 2026 11:58
53 lines
12676 bytes
12676 bytes
When relative_url() cannot resolve a URL, its error message does not
name the URL it was given but what is left of it after some "../"
components have already been stripped off. With a base URL of "./a/b"
and too many "../", it says:
cannot strip one component off url '.'
which does not help a user to tell what is wrong with the URL.
Name the URL that was passed in instead.
Signed-off-by: Aniket Gupta <aniketgupta3001@gmail.com>
---
remote.c | 2 +-
t/t0060-path-utils.sh | 9 +++++++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/remote.c b/remote.c
index 3bca10364e..25e607abf2 100644
--- a/remote.c
+++ b/remote.c
@@ -3183,7 +3183,7 @@ char *relative_url_gently(const char *remote_url, const char *url,
if (chopped < 0) {
strbuf_addf(err,
_("cannot strip one component off url '%s'"),
- remoteurl);
+ remote_url);
free(remoteurl);
strbuf_release(&sb);
return NULL;
diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
index 56faf5fe73..0d16b2c884 100755
--- a/t/t0060-path-utils.sh
+++ b/t/t0060-path-utils.sh
@@ -394,6 +394,15 @@ test_submodule_relative_url "../" "$(pwd)/addtest" "../repo" "$(pwd)/repo"
test_submodule_relative_url "../" "foo/bar" "../submodule" "../foo/submodule"
test_submodule_relative_url "../" "foo" "../submodule" "../submodule"
+test_expect_success 'relative_url() names the URL it was given when it fails' '
+ cat >expect <<-\EOF &&
+ fatal: cannot strip one component off url '\''https://host.example/a'\''
+ EOF
+ test_must_fail test-tool submodule resolve-relative-url "" \
+ "https://host.example/a" ../../../../../../x 2>actual &&
+ test_cmp expect actual
+'
+
test_submodule_relative_url "(null)" "../foo/bar" "../sub/a/b/c" "../foo/sub/a/b/c"
test_submodule_relative_url "(null)" "../foo/bar" "../sub/a/b/c/" "../foo/sub/a/b/c"
test_submodule_relative_url "(null)" "../foo/bar/" "../sub/a/b/c" "../foo/sub/a/b/c"
--
2.54.0 (Apple Git-157)
Technical Details
Message-ID:
<20261126115803.30015-3-aniketgupta3001@gmail.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76437-linux-kernel-git=dewy.ruReferences:
<20261105152842.566318-1-aniketgupta3001@gmail.com> <20261126115803.30015-1-aniketgupta3001@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76437-linux-kernel-git=dewy.ru
From: aniketgupta3001@gmail.com (Aniket Gupta)
Newsgroups: linux.kernel.git
Subject: [PATCH v5 2/3] remote: name the original URL when relative_url() fails
Date: Thu, 26 Nov 2026 17:28:02 +0530
Organization: Usenet Network
Message-ID: <20261126115803.30015-3-aniketgupta3001@gmail.com>
References: <20261105152842.566318-1-aniketgupta3001@gmail.com>
<20261126115803.30015-1-aniketgupta3001@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="457027"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:GI4dhBQhepmAzPut1R9NBuYLCbA= sha256:wtUATleoMS4dGafMdq2kIJ2S+VyOfXrxeyx8J8uBmBU=
sha1:YWauL4ATA0C+waxU+u6R/17imug= sha256:pTugxx8ymtifBgRNH26oGm+XUOMxjdcKo1l3SxCDgk4=
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 5F50B125ED2; Thu, 26 Nov 2026 14:58:34 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.148
X-Spam-Status: No, score=-3.148 tagged_above=-9999 required=6.31
tests=[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 BR5fon_KkruU;
Thu, 26 Nov 2026 14:58:30 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=git+bounces-76437-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
by mail.dewy.ru (Postfix) with ESMTPS id B71FF125ED3; Thu, 26 Nov 2026 14:58:20 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sto.lore.kernel.org (Postfix) with ESMTP id 858F9608DE0; Thu, 26 Nov 2026 11:58:19 +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=1795694296;
b=j9wgLDRpeSN+iBHemKVYYAq5GeI+7wEq7gRR75tq1hHigm5huieQ41lRPlcOL+VX3fHG
P87/J+Qpk8dv+5djGBTWJViUmReolCACQDwyvPA8cX2nz6nKsYV0yjWcHBfJyRAAicf8X
PsEEfN6bj4stTPw4eF86wId2ZRDlBLr0YyopFqRsTqbPf4XGL+5y5W72H8sINvy4QMMPV
RzH4EdLzRJjI4SqLGidGR6pavYH8TGYUkndM2msWWJJa97pdPUvTkr19ofTH2EWA63aGu
SZFHM81ymm1ueGyupyud6rPF2C9bmUV3SRbJIq8z5MST1OYK0MNimNuMnkITFcAWIKg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795694296;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=uL3hkZoND+sXWMMe1nbA2pvpSGU/ObvvjhiBJdMJoXs=;
b=jOEat+TFbvclpC2GaOWC6Oku8bA59Pz6JpDmYvvnLgl0TrsCq3sUL9+GXwuldhrUwh2X
bUx2Xkog3gwOh5gd3qXwguyugyOKyWt6CLTv9A3LM8P51x0ysjL8CfZ2xJIHVRPx9N+Ab
MUUKkhMeyyDi0tJkfCQIT5T3IDBjgL4Ys4Bx0AXvEekDAoh+mBYSeezartYrNFH3zQ2CL
AO1zfArP/svEcnku1iGGyD6+6RrUwfcCGZhGuu8X8eNa1W7oOfCKV0Rs5rKHm8VkHsUPe
kicGsyEI/hbSYVcAWXeJ15ZISbt6vmceT5McgS07f9/1uUq2TDPw4/Bi1ZmfR1FioIw==
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=VkNU2hCj;
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 A47F3606A32E;
Thu, 26 Nov 2026 11:58:16 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=VkNU2hCj
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.169
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1795694295;
b=EgdZH/3Hfe9DXqfuQXrojfdbafRCYypXhT035myrLGlgN+WsLQjn1/oG6+ItLI8TWuuV
dKpRQPt/w4xNIfYNHohtorsoWZf9J7yPW6jq+ZZOveQUYePyp4aMl1ucH3S7dJLN0LCbt
aRT0FcKzeMfJ4gK69oonBSpxYNxuJqnwzDv4VKcE0tfIJPQZYV8+XLQnApIMoBwwkeF15
zL/iIPQO1npg7Q9y7uHgEChz9Gk9b1H25NVaU3f4n2gDOVBsvLqt/DCJWqUVyc+/3zTce
Bsfv7OgxTtrhvSGIMdX4BL61yt1Ex35+fmISlrgCRmVTOOrYTh/DteGFDP42Vg75x7Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795694295;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
Content-Transfer-Encoding;
bh=uL3hkZoND+sXWMMe1nbA2pvpSGU/ObvvjhiBJdMJoXs=;
b=APxq46cjVXfZ8sXmv6hciXazofVqhOWFcJubQcNf6uGVXXB9URFbCvwZIaZNarovCyVQ
oVbV7ZYZjq8ur4vpfg1QRkF8Sx70Pzvw3goAfUnLBktax1IPgXvljhFJjW4VU0evbZQ2q
2uZ2IHPw0WhcGsHjs+qbEb1ltTedl2NspkHxNVDv+2gnW2X1YE0ovkLvM+kl/dLunDJHd
Th3iZ0E2vHygo0/gKoEg6HyQasvgr4k+prF//QYfsbaLCKLUf3dFn+XNC/9YAp85CNtlq
Jl+OAdWU76g6NCkiJ+xTlpL2R6MdnXIfqnLJ69nUf/8RnpfTgCELUybJfWAqlyV87Vw==
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=VkNU2hCj;
arc=none smtp.remote-ip=74.125.82.169
X-Received: from mail-dy1-f169.google.com (mail-dy1-f169.google.com [74.125.82.169])
(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 785E1606A32A
for <git@vger.kernel.org>; Thu, 26 Nov 2026 11:58:15 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 785E1606A32A
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-dy1-f169.google.com with SMTP id 5a478bee46e88-38190551625so13476177eec.1
for <git@vger.kernel.org>; Thu, 26 Nov 2026 03:58:15 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1795694295; x=1796299095; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=uL3hkZoND+sXWMMe1nbA2pvpSGU/ObvvjhiBJdMJoXs=;
b=VkNU2hCjlIFuSGlovmKqZrognugxLDIbD/cjckFIBY9O3piKa+6OYpQUjA/MspRuyS
2Qu+T2tH6D1V5h+9XEe2RDzPM1HNP1uh7ttSwym646XDnv4l5UvOa9D1v5Xxh/EeY13n
xvwdsoZ7NR6V63JoMJ7UlMA0cqjzX5+JExeC6csgydsMEuySGdQlLN2outujtOCO56hG
KO3jP3eqvbiVa5EyYE1+5pgi4e4arvqHInjDzb56udv6XUpXzNv50UiP78/zlv86/MHz
IvOGaCCMfN2mOkGfOzefBpIBNuujMmQ7taYyOwQDcrpEAyrz72jy9MoZCm7P2tSnFLo0
qzkQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1795694295; x=1796299095;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
:to:cc:subject:date:message-id:reply-to:content-type;
bh=uL3hkZoND+sXWMMe1nbA2pvpSGU/ObvvjhiBJdMJoXs=;
b=uSKPtctfxZSDfj53aXjEGiBTkcgJQuT8qgD4PKblEgAJa6nrWBYaigVe1Qeq8ZNwbb
YgpS1qvRp+YncOAI4uYLkECq3Bx8IbsSgtKdn8AfQ05J/8YcQ+dgwXHOxMj1eWMZwiCK
ry4lZc30bo7Rlm2UQTvn5cir5mrKHA8c/jyFi/8GhbS6lh2jIETSH5buy/eTPPFb59y4
fGfCtSVcP0R0GjUfhgjDMzWbusZyZW6l2xQ4DGGoJjQNbxrDPRt2Aq1oq4e2y0Z15S4H
W8uIbVKfkKy4sM4labNW6VKc6Hs6boXxIprZ4ZElrieyeo3ILW1g95CipYErrZ4uNSZ3
NdSw==
X-Gm-Message-State: APuU4Z87WSrwn1jqCRL9Qkt17UiOt3QU3RcaGYnb6RpMs3HjWx4Kgtue
gAgAW0PVwpNVrdfw8ddgpsDj3nD06G5Qclauz0sL9yC9Rk/SNmKOcBW3/UCatEF4
X-Gm-Gg: AZFdTZchFZzhS1DJxg11PcAOvH2FFry04RNA+wrIEu/kOlaGFOrPi/ljzn81or77kia
7Vmzk60NxVBK0mYlUBTECjCFN5VdRwfp5WJdJy4fQ7EQPtVgfnei5tQPHYGYlKBl/rMn6sVjcqg
auGdG/S6xHT9yN541IIgq95SwDxy5g9I9HXqMuljdoYway0WeA6CYDGgm9fKG93RM5QdvlA691A
E9K4RiP0My1P4FEj+7CE0cCyT2n8NbfeZa+l639HipoPP4nSlOtFQeL4df8MW5SFowCdlifGKp8
sLbKjZTbXs9Hd62PTAbuJ5n6Ti8UxhmfikdNkFqUf/djaenq56E0d8JJJPf7cp/TxKqz3PGzhw7
wTROpMQINRJ66duIRp3OIomFNTu5mzmK+Yd2ClhafV0XEyFvxVdF00lM7Q03ZI4B1iUMSQS72Is
BEqvRGM5+pPujvkFcYpBPfKY5VS1le8HWXbQ8pjHjwULMrDA+tG2HbuXly9AuN45LFoLQGtOHDW
u5E1vbtB87EVIe3Tj2J9HmS3YYLBYkQY5uQMKB+p0vKkpdXJhtaNZSI5I8KSpbUfOB7wwY18yYm
GjOUZWtoQJ0UzFe2N+Tk945NqOmJy/Xb6YaLSgWPK8+3pRlyA+ELxHfPIXyZt2hzM6vXkXw5qGm
q7nZtkponId9HAskRo3BJDVYWE1+MKP9RFlNR2JgroG0=
X-Received: by 2002:a05:7301:6192:10b0:386:a7f2:88e2 with SMTP id 5a478bee46e88-386a7f28967mr14149056eec.23.1795694294482;
Thu, 26 Nov 2026 03:58:14 -0800 (PST)
X-Received: from localhost.localdomain ([103.25.231.125])
by smtp.gmail.com with ESMTPSA id 5a478bee46e88-386aa203267sm33614470eec.0.2026.11.26.03.58.12
(version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
Thu, 26 Nov 2026 03:58:14 -0800 (PST)
X-Cc: Junio C Hamano <gitster@pobox.com>,
Derrick Stolee <stolee@gmail.com>,
Patrick Steinhardt <ps@pks.im>
X-Mailer: git-send-email 2.54.0
X-In-Reply-To: <20261126115803.30015-1-aniketgupta3001@gmail.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