Article View: linux.kernel.git
Article #4112[PATCH v3 0/4] compatObjectFormat: fix a BUG(), wrong ID and unknown headers
From: Adrian Ratiu
Date: Mon, 30 Nov 2026 13:43
Date: Mon, 30 Nov 2026 13:43
135 lines
15962 bytes
15962 bytes
Hello all,
This is v3 of the compatObjectFormat fixes found while testing sha1-sha256
interop between Git, Gitoxide and Jujutsu.
Because patch 4 drops a check that 08a45903cb (object-file-convert: convert
commits that embed signed tags, 2023-10-01) added on purpose, I'd still welcome
a look from Eric or Brian.
Changes in v3:
* Split the "<" to "<=" change for the "tree ", "parent " and "mergetag "
headers into its own patch (3/4). (Junio)
* Reword the note in patch 2 on which rev-parse arguments are covered. (Junio)
* Simplify building the commit in the "empty mergetag line" test. (Junio)
v2: https://lore.kernel.org/git/cover.1794932695.git.adrian.ratiu@collabora.com/
v1: https://lore.kernel.org/git/20261112195740.2834341-1-adrian.ratiu@collabora.com/
Many thanks,
Adrian
Adrian Ratiu (4):
setup: reject compatObjectFormat == objectFormat
rev-parse: die when --output-object-format cannot map an object
object-file-convert: match tree, parent and mergetag headers by key
object-file-convert: copy unknown commit headers unchanged
builtin/rev-parse.c | 8 +++++---
object-file-convert.c | 35 ++++++++++++++++++++++-------------
setup.c | 7 +++++++
t/t1016-compatObjectFormat.sh | 33 +++++++++++++++++++++++++++++++++
t/t1302-repo-version.sh | 14 ++++++++++++++
t/t1500-rev-parse.sh | 14 ++++++++++++++
6 files changed, 95 insertions(+), 16 deletions(-)
Range-diff against v2:
1: f74a0fd67a = 1: f74a0fd67a setup: reject compatObjectFormat == objectFormat
2: 5b91372748 ! 2: 5d5527aa40 rev-parse: die when --output-object-format cannot map an object
@@ Commit message
Fix it to die with the same message as pack-objects. The other callers
of repo_oid_to_algop() already check its result.
- Note that this only covers the case where the user asks for a single
- revision, as it is the only case where rev-parse passes the desired
- output hash explicitly. All the other cases, like for example when the
- user passes a range, do not use the desired output hash at all. Fixing
- that would be a bigger change though, so it is left for a future patch
- series.
+ Note that this covers every argument that names a single object,
+ e.g. "git rev-parse --output-object-format=sha1 main next".
+ Arguments that rev-parse expands into several objects, like the
+ "A..B" and "A...B" ranges or the "rev^!", "rev^@" and "rev^-"
+ shorthands, are printed by code that ignores the output format, so
+ they still print storage IDs. Fixing that would be a bigger change,
+ so it is left for a future series.
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
-: ---------- > 3: ed6dcdd93d object-file-convert: match tree, parent and mergetag headers by key
3: 26080a7a38 ! 4: 366b8c310d object-file-convert: copy unknown commit headers unchanged
@@ Commit message
The author, committer, encoding and gpgsig headers were already copied
the same, so their separate cases are no longer needed.
- The "tree ", "parent " and "mergetag " cases only matched a line with
- something after the space. That didn't matter while all other lines
- were rejected, but they would now be copied. For a "mergetag " line
- whose tag starts on the next line, the object ID in the tag would be
- copied unconverted, even though Git reads that header as a mergetag and
- convert_commit_extra_headers() refuses to convert it.
-
- Match these headers by their key alone instead, the way
- read_commit_extra_header_lines() does. Such a line with an empty or bad
- value is then rejected, as before. A "tree", "parent" or "mergetag"
- line without a space is not one of these headers to Git, so it is
- copied like any other unknown header, which is also what
- convert_commit_extra_headers() does.
+ The "tree ", "parent " and "mergetag " cases match these headers by
+ their key alone since the previous commit, so a line with an empty or
+ bad value is still rejected instead of being copied. A "tree",
+ "parent" or "mergetag" line without a space is not one of these
+ headers to Git, so it is copied like any other unknown header, which
+ is also what convert_commit_extra_headers() does.
Alternatives considered:
@@ Commit message
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
## object-file-convert.c ##
-@@ object-file-convert.c: static int convert_commit_object(struct repository *repo,
- if (!eol)
- return error(_("bad %s in commit"), "line");
-
-- if (((bufptr + 5) < eol) && !memcmp(bufptr, "tree ", 5))
-+ if (((bufptr + 5) <= eol) && !memcmp(bufptr, "tree ", 5))
- {
- if (((bufptr + tree_entry_len) != eol) ||
- parse_oid_hex_algop(bufptr + 5, &oid, &p, from) ||
-@@ object-file-convert.c: static int convert_commit_object(struct repository *repo,
- "tree", oid_to_hex(&oid));
- strbuf_addf(out, "tree %s\n", oid_to_hex(&mapped_oid));
- }
-- else if (((bufptr + 7) < eol) && !memcmp(bufptr, "parent ", 7))
-+ else if (((bufptr + 7) <= eol) && !memcmp(bufptr, "parent ", 7))
- {
- if (((bufptr + parent_entry_len) != eol) ||
- parse_oid_hex_algop(bufptr + 7, &oid, &p, from) ||
-@@ object-file-convert.c: static int convert_commit_object(struct repository *repo,
-
- strbuf_addf(out, "parent %s\n", oid_to_hex(&mapped_oid));
- }
-- else if (((bufptr + 9) < eol) && !memcmp(bufptr, "mergetag ", 9))
-+ else if (((bufptr + 9) <= eol) && !memcmp(bufptr, "mergetag ", 9))
- {
- struct strbuf tag = STRBUF_INIT, new_tag = STRBUF_INIT;
-
@@ object-file-convert.c: static int convert_commit_object(struct repository *repo,
strbuf_release(&tag);
strbuf_release(&new_tag);
@@ t/t1016-compatObjectFormat.sh: do
+ test_expect_success "reject a $hash commit with an empty mergetag line" '
+ git cat-file tag committag >../${hash}_committag &&
+ {
-+ sed -n "/^committer /q;p" ../${hash}_commit2 &&
-+ grep "^committer " ../${hash}_commit2 &&
++ sed -e "/^committer /q" ../${hash}_commit2 &&
+ echo "mergetag " &&
+ sed "s/^/ /" ../${hash}_committag &&
+ echo &&
base-commit: 1891de46f79dc444a47db1c87bd0c8c76b5463f2
--
2.56.1
Technical Details
Message-ID:
<cover.1795455594.git.adrian.ratiu@collabora.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76669-linux-kernel-git=dewy.ruReferences:
<cover.1794932695.git.adrian.ratiu@collabora.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76669-linux-kernel-git=dewy.ru From: adrian.ratiu@collabora.com (Adrian Ratiu) Newsgroups: linux.kernel.git Subject: [PATCH v3 0/4] compatObjectFormat: fix a BUG(), wrong ID and unknown headers Date: Mon, 30 Nov 2026 15:43:21 +0200 Organization: Usenet Network Message-ID: <cover.1795455594.git.adrian.ratiu@collabora.com> References: <cover.1794932695.git.adrian.ratiu@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1437269"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:6SpjXwd+XAmgKf3IyIw2Y5Qe/Fo= sha256:U5GhECiGzpRP7yCcaX0cHrN7WtEvsi0nD1ULbtSNJgs= sha1:IDakk/WDNQXXuwm8rKp94pfQS98= sha256:Br/pQkha3byF6pCzlSP29hvIeDboEw6n+QQWxBfunn8= 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 BE7D7125FED; Mon, 30 Nov 2026 16:46:02 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.751 X-Spam-Status: No, score=-2.751 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, 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] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=collabora.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 yPo15PvU7MdE; Mon, 30 Nov 2026 16:45:57 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-76669-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=collabora.com X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 4E4DE125FF3; Mon, 30 Nov 2026 16:45:48 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 24A8A2E1E2; Mon, 30 Nov 2026 13:45:37 +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=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796046336; b=ZejjD2q8V7qeM+S4kf0M67jQlf/uu/6PGLUp9BxS9AVge1r9Y9ltHC/HjjD6TTFkAZhg iqBEt/aZnAyclG0No5XTCvlMwNxicDGSRo3EuEMIbmjze85ifEXwKEWAIC2XMSl7+jAVc Y4PmDbFytNz+XjY6mMvAR37yDTpexKsIDC4BuRtV49SvfkJYXEhkrakX/PeJEsVpUQWvV I5365w1hqGha/SCkgNOYszffc0to8GUk6u+GaxMfYrbCstzFMBXKg6GKFl7AfenX7ULR3 mEEUlOI4cFHgMWWuw3jah24juLbArcfU0rab55kT6PscUx6d9M+9FMGxYtClPMgZMBw== X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796046336; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature: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=VwFYfUoNYn1Ck+FZD4x7iTTXteZX4tPkUIXn89B/gnw=; b=tWoI5Xdtc5lu310WRoQ7KfbENu5J73pQ6JGN5vWfIxN2RRYr/gp7d8aEGTk64+h2z+4+ b6i3xHJHWJCpx4g2gi/yyGHKPY0sYBaTsjB3j9sqVI9Xp+id/j/KdLTPYjiNJFIQAc/h6 dLSd0WFedJ4t9Ni78PZZuxkYdDpfV4wj1cjh7OtkPVu9XAi1A3fzlRKB5q9gKdvjcGhQH N+xwuf4CmjeRKU3VTOKdAsq1CtuTUN4E4rwBaN50IJAre8sgpunF/YJapjVIN4KXxOxzS RDBOTWzb3GqUzNo69wPJbwrKKLgrQJALcdQpmTAnekDye24NIu6E8s3SvObDM8pXtBQ== X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=zohomail header.b=JIlz2b4U; dmarc=pass header.from=collabora.com; spf=pass smtp.mailfrom=collabora.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 D7A7D606A33B; Mon, 30 Nov 2026 13:45:36 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=zohomail header.b=JIlz2b4U X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.180.12 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796046336; b=ZBojGfnc/0lun40bp7YiZWey0tSmp/snM72s0XBnfhoDWTMgSPnWE4PzM8Pptanw9cXf KOjaq4pWuVSax6hB4lpUEuSVGRgWTQ4JhWlJhU3XhUI2CdmLnxcK/H8ymu0qHE+0e8AyI swbLg7qh5GgpNFtxlShdMhG1ZexY1ifI6G1DLG2/rvL95xZ9cF7eQ0MtBC3a/cRGeoN59 OjfyfmxlasBK913jtbGxdI7QFQ5c4o3c26KRASp9j5bhgKjL3iGSXm5DUwqEhsH5IWa5H Gpn46y7yigx/WaukPE+Thf3jN5KY3LFYwZitlnLWhMNeLjkVylGNOdY9+/YR62SqlhQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796046336; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=VwFYfUoNYn1Ck+FZD4x7iTTXteZX4tPkUIXn89B/gnw=; b=KLV4iU6gx8v/9oA3r0G+6zw99qD/l3VGmpGtp4fyc9gYnis0/Cq//EU+cr5QI8RITkHZ gOG+PZU/YkDKUBVyXIoLplBxE24X0xiVMhoRqvRTXOZqVwxZu6ZBRgQvUxMd/7lLj+Je4 wH5MTZRGV/5RCg3A2+MBkXwDRQKGQNIHtonVJZiwELdaxlj4KgBaKmHKELjWZkty90T1x KuXyCkE40ZUNGV0duNRZ5FG1yh2l4SZwqaCXvNJRFFTkTvtJakmYiTpVIRvUmn1P67WOr GAr65p/HDjMEex/5Xg9mshnGPLvkPOVRmjqWlaeTz3q7PHbn9jTBxjmgtBBAa32m3jw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=zohomail header.b=JIlz2b4U; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.180.12 X-Received: from sender6-op-o12.zoho.com (sender6-op-o12.zoho.com [165.173.180.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2783606A327 for <git@vger.kernel.org>; Mon, 30 Nov 2026 13:45:35 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A2783606A327 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com X-ARC-Seal: i=1; a=rsa-sha256; t=1796046314; cv=none; d=zohomail.com; s=zohoarc; b=Bv7A7KuHZLG0ig97KdZndHvuOhYCjhzrBE/UimeJFP5ZCa9PXWTf91ZTWRkya881z3DE57WJ4lC7Bz1UefLvA5Ct1OfH3ZGp+7YdCNSYtThvERBGjlYkKmviDiOjnm3cboRyMrTXB83d+Cl0oar80H7cl+pt8wcR1UYPcAApz9Q= X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1796046314; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=VwFYfUoNYn1Ck+FZD4x7iTTXteZX4tPkUIXn89B/gnw=; b=fSb2O/dkD9Eb6pA2xF0SOnBzFNzsaXFeLopiubzNG7iflhMpGR/XUtYLzVdY6mzftaCwtBTT+Lr1rczuY7amocsd8ElkqBg5c0S7C/O8eDgIdFzB6lS+l8z65//UM8g8W0dZtBskbm38QABO14JgfZWHE1u9ygycI/15g2E1dk0= X-ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=adrian.ratiu@collabora.com; dmarc=pass header.from=<adrian.ratiu@collabora.com> X-DKIM-Signature: a=rsa-sha256; b=JIlz2b4UO7Ezu2TfDsnK2XHegLZbPeMprY5yb4DFUC3M/hZirtUzfTv0o9Z7cQJDdv3C9KrZbCJKNs9lZ2Sfs9k5vT8YU2YS6tznM62HtAbp2PG93LFKxojSXr+oqaRDm/qdL7YeNwlpLHaRN9oSnzfSPqV9ZfdZJjBV5cLXFmA=; c=relaxed/relaxed; s=zohomail; d=collabora.com; v=1; bh=VwFYfUoNYn1Ck+FZD4x7iTTXteZX4tPkUIXn89B/gnw=; h=Content-Description:Content-ID:Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Resent-Sender:Resent-Cc:Resent-Date:Resent-To:Reply-To:Resent-Message-ID:Resent-From:Sender:Subject:To:Date:From:Message-Id:Reply-To:Subject:To:Cc; X-Received: by smtp.zohomail.com with SMTPS id 179604631313136.79002489285392; Mon, 30 Nov 2026 05:45:13 -0800 (PST) X-Cc: Adrian Ratiu <adrian.ratiu@collabora.com>, Junio C Hamano <gitster@pobox.com>, Patrick Steinhardt <ps@pks.im>, "Eric W . Biederman" <ebiederm@xmission.com>, "brian m . carlson" <sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.56.1 X-In-Reply-To: <cover.1794932695.git.adrian.ratiu@collabora.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