🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #3069

[PATCH 1/4] object-name: do not read a peel suffix as a reflog selector

#3069
From: Caspar Duregger
Date: Fri, 13 Nov 2026 14:28
58 lines
12782 bytes
To find a "@{...}" reflog selector, get_oid_basic() checks that the
name ends in '}' and then takes the last "@{" in it.

For "HEAD@{1}^{blob}" the final '}' closes "^{blob}", nevertheless we
take "1}^{blob" as the selector. That is not a number, so it goes to
approxidate_careful(), which accepts it without complaint as "now".
The name then resolves to the current value of HEAD.

We only parse the whole string like this after peel_onion() has
failed, so a peel that should fail succeeds with the wrong object:

    $ git rev-parse --verify 'HEAD@{1}^{/no-such-subject}'
    <object name of HEAD>

Only accept a selector whose "@{" is closed by the final '}'. Reflog
selectors never contain a '}', so no valid selector is rejected.

Signed-off-by: Caspar Duregger <caspar.duregger@gmail.com>
---
 object-name.c              | 6 ++++++
 t/t1508-at-combinations.sh | 4 ++++
 2 files changed, 10 insertions(+)

diff --git a/object-name.c b/object-name.c
index 6546685760..13e4dc0f21 100644
--- a/object-name.c
+++ b/object-name.c
@@ -712,6 +712,12 @@ static int get_oid_basic(struct repository *r, const char *str, int len,
 					nth_prior = 1;
 					continue;
 				}
+				/*
+				 * The final '}' must close this "@{", not a
+				 * later suffix as in "ref@{1}^{tree}".
+				 */
+				if (memchr(str + at + 2, '}', len - at - 3))
+					break;
 				if (!upstream_mark(str + at, len - at) &&
 				    !push_mark(str + at, len - at)) {
 					reflog_len = (len-1) - (at+2);
diff --git a/t/t1508-at-combinations.sh b/t/t1508-at-combinations.sh
index 87a4286414..10a8c3ad9d 100755
--- a/t/t1508-at-combinations.sh
+++ b/t/t1508-at-combinations.sh
@@ -84,6 +84,10 @@ nonsense "@{-1}@{-1}"
 check "HEAD@{3}" commit old-two
 nonsense "@{3}"
 
+# a failed peel must not be retried as a reflog date
+nonsense "HEAD@{1}^{blob}"
+nonsense "@{1}^{/no-such-subject}"
+
 test_expect_success 'switch to old-branch' '
 	git checkout old-branch
 '
-- 
2.56.1.windows.1
Technical Details
Message-ID: <20261113142804.7465-2-caspar.duregger@gmail.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-75383-linux-kernel-git=dewy.ru
References: <20260212040708.GA1894049@coredump.intra.peff.net>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-75383-linux-kernel-git=dewy.ru
From: caspar.duregger@gmail.com (Caspar Duregger)
Newsgroups: linux.kernel.git
Subject: [PATCH 1/4] object-name: do not read a peel suffix as a reflog selector
Date: Fri, 13 Nov 2026 15:28:01 +0100
Organization: Usenet Network
Message-ID: <20261113142804.7465-2-caspar.duregger@gmail.com>
References: <20260212040708.GA1894049@coredump.intra.peff.net>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1372568"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:RJM3eeem77hYeIBiHHJYsj6+ScE= sha256:RDzuaJ4uJJ5iKwh++IiulBB4NdpJpMlIMKRbRJnGgA8=
	sha1:kPA0wKaRXblGpzm3Vz99Wb/qFLs= sha256:bFjW5Qlo4uQFlOi/icSbN09Lxfn7f+IGC6DbBxrqtf8=
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 7EF43114588; Fri, 13 Nov 2026 18:26:58 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -1.948
X-Spam-Status: No, score=-1.948 tagged_above=-9999 required=6.31
	tests=[DCC_CHECK=1.1, 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 S8Mq0N0Pq6CN;
	Fri, 13 Nov 2026 18:26:54 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=git+bounces-75383-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 776FE11452D; Fri, 13 Nov 2026 18:26:44 +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 10E2E1C811C; Fri, 13 Nov 2026 14:28:56 +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=1794580130;
	b=qXNOVwGVYQuL6HvbIkj5fG7PMeCn/kB98FeolQJIVnePtKIdyUaNpP7gu8rpq/jv6uzQ
	 rCuRyIaiQ6Qg1v7lVccD6jED7O6duAeWNIlSh7dZ0ins3RHrCe12+yNbkV8NC9bz68gfC
	 y5xjuDUEOeCiZVsegMqY7OX0FyLWREF5UKXiDnFi54M3cdiGjrio0ZlRs2dzfuYvZhe//
	 2HXMqXZ1ChG9kwny5EORzW9c5i4j1ZbHEwLy2qNSPvr8I6o5Yv80FKMDRjEthDQzPfNwe
	 s3s05uVybPqUhXobjnv/PPcBLgp3l/9cQQ2KF1vltYprPEO2Xfxew2/O5x3mXM7EiZg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794580130;
	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=TF7HE61UWN3qwbvSbDt1QTXd3Thn2U/deOOhW78yQYg=;
	b=1BABj7E2SbdgM2bR3xaSZkDbL4OBVYsPBdnZEP17PJScpRYjTFnUuaTJueQqUsD4eWcO
	 YXTyGkmaQCUouib2WJhA0fxZVCIVAQJF4RL8lJA3W1n4tm5mghkCKMHtBdZx3vdaGGFzp
	 ncVzH6YTP1T3hkhVKDH/ICNGb+UO/AA7hGV1eS4XuHg34MTMMc8UpI595BPd3p8bzuRDK
	 odhSUFApeODQCljBkyiOpHTlo+q3bB/qNjE/I6pmjYzohtcqqj8iPVat6T8q7FIXWmXqD
	 Y1sUvY1SuxaSEokuH+7bHsFFWEYbZQr25dmTciqB381jH204IslCM4bLQ1e8D4QIt0Q==
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=QDEz2DKb;
	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 39BC2606A332;
	Fri, 13 Nov 2026 14:28:50 +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=QDEz2DKb
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.44
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794580129;
	b=Ra83/NbAs4fgoIdtO3TaMyZvLCkOm0q5kzsVxZLRkg6Og5M4j0efuXkEhS/yQ/1jLh/P
	 OZ6eT0DIHQ2RnSdtDBkYcvP0E/xSGMy1qtwAoi4A6bsnxVp8AdRdPXd4CWV5FwJb7Ac6m
	 aMP2t11MSbhqZSXVlZRA3ZI1091u7n2YsMnzvZueGCWATi92YRurJ5w3mXg4d8arIc7wC
	 vGpOGl7Y1YpebL2YHAsw2ooLK7pEuIugjS6Jxqp8OzffawWI3KLue4MBk+UgaEfXQWx6E
	 bCZOV3prQOXsJpttIpSzkyjBll3+hqVq8cBkANnlIY0UDei6IHLmcl0I23pi2vkuKvQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794580129;
	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=TF7HE61UWN3qwbvSbDt1QTXd3Thn2U/deOOhW78yQYg=;
	b=HvZ/h3GdSJbvoRCLTdaLAaE8Yf3gULlY1UBg1ILdUy6HZ/6e0CIp17wiC8/IM+oRErk8
	 1Tic8VCGj9XhTLX8BA7SjEfYB57Cwc99wBClNkQA9zuBeCv5yyLrO+Bms2gcfxr9P0TYh
	 1MhhrQysqBnCdaClY5VXB/59MpMt5jMlxiMU8Cd8dlFWYKokijDqnMikqhKJxFA7mnFCl
	 PagkzDtpNmKTcYiMEJl/hVHwOFLlhoeiuHquNea0APkBhYPI3F7/kSsZU4flDILE/3kdi
	 aBrMFpUlsqVWQYatCZbVQSr9vI/c4+635Rjd/McZTyyeYhQyCWKMGrgxQBAD1XJiJQA==
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=QDEz2DKb;
	arc=none smtp.remote-ip=209.85.128.44
X-Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44])
	(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 11194606A880
	for <git@vger.kernel.org>; Fri, 13 Nov 2026 14:28:48 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 11194606A880
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-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4bb55cda775so4648365e9.0
        for <git@vger.kernel.org>; Fri, 13 Nov 2026 06:28:48 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1794580127; x=1795184927; 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=TF7HE61UWN3qwbvSbDt1QTXd3Thn2U/deOOhW78yQYg=;
        b=QDEz2DKbjPHUnfuX35Pj9+bcCbSIfjKQbnaD43uGvpHN1d/jBn/395nHWEC1lNWafb
         i1N43hVWkqfw38FkpbI8AHUQC1/wJ9U0cT7XYWjbonz4pwp9scdI4kxRAtK3h2xQgmQW
         nr85/FYuhonLFCOSmN4XK5Xz6riERlA12Jt1H3fNx2frAvMlorl7wzGPcv3zeYhOovza
         cDHsEauMWLjX06tEJFecxieeeIyhlHKhogmYI5hDqnyz4BY4E2srNlKSMexiFnNr8i8b
         TzbWGM13w4g2vkSTmSTP3wWgfPUW3ez28SEIj2R36dF/ZxlSlBt9Tn1EDXKZsxvsZS8D
         LtKQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1794580127; x=1795184927;
        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=TF7HE61UWN3qwbvSbDt1QTXd3Thn2U/deOOhW78yQYg=;
        b=keJEHKPzIj0zheizGx5WtGuvinW//FfaZe6NLCXsn6vT+CviXWNu30Qh3x8ctwFAIj
         e9TKy8ngnpNL8WhLxNJajt2YLV3Uu41fNkMDFCXhHP+2RJk4j2Sx88/DHL44yGHtEd/K
         8Y2uJPw1Q8KpjsIwLtXyuyKaRw1PSb2nkdYfWxBOh5vWRwGFMDmgDqAEbVLfoLme09/j
         nCVY87HjmTfbhYVe2NMbzfvSQVdKT44GktYz7FROqAW3ouyNyIhqPt4d94PU8b1J1fOc
         A+/uYqfikqP9hlpQW5tqZxTeJHPZnWYoIFEsOBkGt2u2UWtngs3en8gsIUAyOFwxkeFw
         EC9w==
X-Gm-Message-State: APuU4Z+vYSYXKpa+rOnsTcjPi7NyFxId9lNukmzjhv1nkaYYBYl4efM6
	BcqnSE/+ljqkcETjqkMpGQ7jE3R36UmZ4SqC4VDFGijgNB1hOsysyk0eCABiVPa5
X-Gm-Gg: AYBFou0HyNH3V9JSuRgAZC7GsfKkSzfSF+A4uOhpu+aBPbj2yAbaG+agIZfD7guYlBc
	ZYC15XuesHCEQoXoh7HqPWSQJaWw+oGzv0pZ0LF5Tiql47cGnH4wI3AJWavlTuYOcisVqi4g1eq
	BLWdLuZoiqRUHKuQMyxdAmFI4xfRo3IPteXxKVktOyJ6GSKkChYGuLzoJUdhz1rZenSU8yx7hXV
	xZyBbiq96tSHAeDPX4tTLEgBDSLt4PMM/83RBtQ8chI+tAEeOnHg/3L4YF7pt6kWN7CmstyNMZz
	Qvf1hY9WJaa+kCDSZT5EsrW9+Z2BBQhoaH2uXEcn58m0FWFXhObev9xKqFL/YlQpJK1KvjnDGkI
	QTADbw5Qp2oa0IiYRY5VNFBEUwA+fQdX03R8FfqFkC9dZ2cdaHV5jA+gAzpylnB1ksHDZL+rEfW
	qWg03axHh3zQ+ezPhGcUefHNMUa/fIkfbs17eH77CVIaYwuWF4qDC1qNeZyDz5So0OJpEKv5cg8
	mP6I0kcpc1MEp/d5YwVFOjf3YXyWi/87AJNKcp2wjgsvCSu72bbkmECxppQBERv0uj2XZpoef09
	KyRXVtZbDvAfpf/utvcVbNLA5XaIjDPRuB/kXkapZwYkDSsHDmuWJDyTTEVWNtjnA9GAo9zpkUD
	z7MC2DnN24P7XbghhT6vnpCEkIvAeVQ==
X-Received: by 2002:a05:600c:4691:b0:4bb:5e8c:13bc with SMTP id 5b1f17b1804b1-4bb5e8c13e4mr9747645e9.7.1794580127193;
        Fri, 13 Nov 2026 06:28:47 -0800 (PST)
X-Received: from KURSA (ipservice-092-208-105-158.092.208.pools.vodafone-ip.de. [92.208.105.158])
        by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb55ac1159sm60033285e9.4.2026.11.13.06.28.46
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Fri, 13 Nov 2026 06:28:46 -0800 (PST)
X-Cc: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>,
	Junio C Hamano <gitster@pobox.com>,
	Jeff King <peff@peff.net>,
	"brian m . carlson" <sandals@crustytoothpaste.net>,
	Caspar Duregger <caspar.duregger@gmail.com>
X-Mailer: git-send-email 2.56.1.windows.1
X-In-Reply-To: <20260212040708.GA1894049@coredump.intra.peff.net>
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