Article View: linux.kernel.git
Article #4344Re: [PATCH v3 4/4] object-file-convert: copy unknown commit headers unchanged
From: Adrian Ratiu
Date: Fri, 04 Dec 2026 21:25
Date: Fri, 04 Dec 2026 21:25
178 lines
17051 bytes
17051 bytes
Hi Eric,
Really appreciate your review, thanks!
On Fri, 04 Dec 2026, "Eric W. Biederman" <ebiederm@xmission.com> wrote:
> I don't understand what the problem is with the behavior that was
> deliberately added in commit 08a45903cb32 ("object-file-convert: convert
> commits that embed signed tags").
Taking a step back, I'll try to keep this as short & sweet as I can. :)
Jujutsu can use a Git repo as its backend and starting with jj v0.30, it
records its own change ID in every commit it writes by default, as an
extra header after "committer":
change-id <32 characters from jj's k-z alphabet>
(jj's change ID is not an object ID and doesn't refer to anything in the
object store, it's just a random 16-byte value written in reverse hex,
that stays the same when jj rewrites a commit.)
While testing sha1-sha256 interop between Git, Gitoxide and jj, I found
that none of these commits can be converted in a repository with
extensions.compatObjectFormat enabled:
1. git fetch of a jj commit fails: "Failed to convert object from sha256
to sha1" and "unpack-objects failed". So does git hash-object -w.
2. git commit --amend on such a commit succeeds: commit_tree_extended()
converts the extra headers with convert_commit_extra_headers(),
which copies unknown headers. It records a compat ID for the new
commit, but reading that compat ID back fails with the same error.
Basically one path rejects the header and the other accepts it. :)
The repo ends up with compat IDs that Git itself can't read.
Here is an example reproducer with jj v0.47.1 and git 2.56.1:
# A SHA-256 repo with SHA-1 compat IDs
git init -q --object-format=sha256 compat
git -C compat config extensions.compatObjectFormat sha1
git -C compat commit -q --allow-empty -m base
# A jj commit on top of it, in a clone without compat
git clone -q compat plain
(cd plain && jj git init --colocate && jj commit -m 'made by jj')
git -C plain cat-file commit HEAD | grep change-id
# change-id xlzosozsspsklvyrmyztsvykqvkpuyky
# 1. Pulling it fails
git -C compat pull -q ../plain HEAD
# fatal: Failed to convert object from sha256 to sha1
# fatal: unpack-objects failed
# 2. index-pack converts nothing, so this pull works. The amend
# then records a compat ID that can't be read back.
git -C compat -c fetch.unpackLimit=1 pull -q ../plain HEAD
git -C compat commit -q --amend --allow-empty -m amended
c=$(git -C compat rev-parse --output-object-format=sha1 HEAD)
git -C compat cat-file -p $c
# fatal: Failed to convert object from sha256 to sha1
With this series the above works without errors.
> Fundamentally if a header holds a object id the code needs to know about
> the header or the commit can not be converted. Ignoring that
> possibility will result in inconsistent and improper conversions that
> affect the structure of the git tree.
I agree and jj also has such a header: for a commit with unresolved
conflicts (yes, committing conflicts is a jj feature :)), it records the
IDs of the conflicting trees:
jj:trees <tree ID> <tree ID> <tree ID>
Copied unconverted, these IDs are wrong in the compat commit.
Git's own graph isn't affected, though. In either format, Git only
reads object IDs from the tree, parent and mergetag headers. What breaks
is the meaning the other tool gave to the header.
> When git isn't converting commits it doesn't matter so I also don't
> see a problem with the two code paths being different, as the difference
> is in their fundamental responsibilities.
In a compat repo, creating a commit also converts it: git commit writes
the sha256 commit, builds its sha1 version and records that ID. It
builds the sha1 headers with convert_commit_extra_headers() which copies
unknown headers.
So both code paths do the same job: produce the sha1 version of a
commit. When they disagree, git commit records a compat ID that
convert_commit_object() then refuses to produce.
I tried a commit with an "x-related <sha256 commit ID>" header:
1. git hash-object -w refuses it.
2. git commit --amend accepts it, copies the ID unconverted, and
records a compat ID that then can't be read back.
So git commit already produces the commit you're worried about. If we
fail on such headers, both paths have to fail, see my proposal below.
> My sense is that deliberately failing is better than generating a
> garbage commit. I think that should definitely be the default.
I agree that failing is better than writing garbage, but today Git does
both: git commit records a compat ID for such a commit, and
convert_commit_object() then refuses to produce the commit behind it.
You're right, though, that this patch lets more commands accept such a
commit silently (fetch, hash-object, reading by compat ID), where today
they fail loudly.
> Fundamentally the code must be updated whenever someone adds a new
> header that adds additional object ids.
>
> For me the question is how does the code reasonably detect new headers
> with object ids and fail those while allowing the other non-problematic
> cases to work.
>
> The paths I see are whitelisting all headers. Or having something that
> scans the unknown like and causes the conversion to fail if it includes
> anything that looks like an object id.
A whitelist would make Git decide which tools may add headers, which
Patrick argued against in v1 [1]. He was also skeptical of recognizing
IDs automatically, but that was about converting them, here we'd only
refuse them.
I don't have a strong opinion on this and am willing to follow any
guidance/consensus. A scan would be a good solution for me personally,
since in jj the change IDs use letters k-z and never look like hex
object IDs, while commits with conflicts would continue to be refused.
So in v4 I could keep failing on unknown headers, but only on those that
look like they hold an object ID, and copy the rest. Both
convert_commit_object() and convert_commit_extra_headers() would use the
same check, so the two paths can't disagree again.
Would that work for you? I'm open to other suggestions.
> It might make sense to add a warning in the ordinary commit case about
> headers that we don't know how to commit.
With the check above, the ordinary commit case would fail on headers
that look like they hold an object ID, instead of warning.
Warning about all other unknown headers would fire on every jj commit
that git rewrites (e.g. git commit --amend), so I'd rather copy those
silently.
If you'd prefer only a warning for the first kind, the read path would
have to accept the same commits too or we're back to compat IDs that
can't be read.
> How do we prevent creating a corrupt git archive? If there are such
> headers the converted archive will be corrupt when the non-converted
> archive is fine.
For the headers Git knows, the converted graph is complete and fsck is
happy. Unknown headers that hold full object IDs would be refused by the
check above instead of being copied. Abbreviated or otherwise encoded
IDs would still get through so the check can't prevent every case.
To fully prevent it, Git needs to know which headers hold object
IDs. Patrick suggested a well-known header prefix for them,
e.g. "x-obj-foo <oid>" [1], which would also let Git convert them.
I think that's the correct long-term fix, but it's outside the scope for
this series.
[1] https://lore.kernel.org/git/avqypRLPLZZFNqRs@pks.im/
Thanks again,
Adrian
Technical Details
Message-ID:
<874icsg2m2.fsf@collabora.com>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-77034-linux-kernel-git=dewy.ruReferences:
<cover.1794932695.git.adrian.ratiu@collabora.com> <cover.1795455594.git.adrian.ratiu@collabora.com> <366b8c310dcf1f03046cae422e7ac5c0eb618c9d.1795455594.git.adrian.ratiu@collabora.com> <8733sddjk9.fsf@email.froward.int.ebiederm.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-77034-linux-kernel-git=dewy.ru From: adrian.ratiu@collabora.com (Adrian Ratiu) Newsgroups: linux.kernel.git Subject: Re: [PATCH v3 4/4] object-file-convert: copy unknown commit headers unchanged Date: Fri, 04 Dec 2026 23:25:25 +0200 Organization: Usenet Network Message-ID: <874icsg2m2.fsf@collabora.com> References: <cover.1794932695.git.adrian.ratiu@collabora.com> <cover.1795455594.git.adrian.ratiu@collabora.com> <366b8c310dcf1f03046cae422e7ac5c0eb618c9d.1795455594.git.adrian.ratiu@collabora.com> <8733sddjk9.fsf@email.froward.int.ebiederm.org> MIME-Version: 1.0 Content-Type: text/plain Injection-Info: usenet.network; logging-data="2872485"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:DFxeCjIpajPbg7QgOrvLVryhK5g= sha256:qdmrMRwVo1ljWrsUN2rNsP17XO2jN58hDOFt8rUi5nk= sha1:T/7fHomY8gpJB5WTEmvJR/s10Ew= sha256:uN6aHrCXijgKPTyT1zRJ1Sn8I5m9luYh8eWWRwB9Kg4= 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 D17B4117CE7; Sat, 5 Dec 2026 00:26:07 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -1.898 X-Spam-Status: No, score=-1.898 tagged_above=-9999 required=6.31 tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, 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=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 mmuXTEbUVc7C; Sat, 5 Dec 2026 00:26:04 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=git+bounces-77034-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id D2A1D117CDC; Sat, 5 Dec 2026 00:25:54 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 928A82A2F8; Fri, 4 Dec 2026 21:25:52 +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=1796419548; b=pV0NGGHpWBr+Qar5053OpcHFHxKdW0Hnq9mAb+VqwJND87b4oIoRWespiQxw8iXLYvYr 6BxmXvJ/wm6K26VQHKbNGVgHg/tFhN6lZJDsHne7ldx63Vm5Fo3gdmGHMJw4k+M69xI5R 1FaTkjohrEOWd7HTobf3p1IlrWBxtbuQ2KlCsSUeGwXi0LPO7mmHqgnQkpBXkG1drOn7B TLqBWX+y7E8eKIfwcVl4KcBLlU5n0oZIDhjty6yx6fNq+2lWFHoX+4G8saUOAoRV9DZsX 0UvXWX4JPzWjvQmOQBRVGiEZ1G/MAjn/9B0ByrK5c8ziCl29PJQQAd3Z5Eh29bB288Q== X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796419548; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To: Cc:Subject:In-Reply-To:References:Date:Message-ID:X-Mailing-List: List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe: List-Owner:Precedence:MIME-Version:Content-Type; bh=1B5DlsGQJBiBtjRlDw6A8+EiW0cSARAJhF54Kd04h9o=; b=B9C874UMme7RbybUnb1wTtg3U1V6p7EdOBNqdPBwBzWzed5h/ZVg5YC0FH9eMRILQzA4 5RdKYIrqQfI2BCkhDOcuuv9EM/mn/l37yAoNpog4Du/M87hug1bT2FHQDDztUU4GiltUC VrsN37MRURUBkEHKUJ8+SEPFr/+S2+dFagTEpLt3ef/4zCypNGdlfyPznxMTgx8dN4OYn ZjgM8Hkxs37+TzSALeOT0BP4bE6OGVNMjsriEqfrnI7VxIpx7i72XcjNTzflN9LV2EAqW JvW8UtQkFCV2CCzjjNqcHBRt1FgdbmU19JiKO4palAND8uvrAQjOrR7JeNNScLQVzkQ== 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="Mng4XL/x"; 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 B68E4606A33F; Fri, 4 Dec 2026 21:25:48 +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=Mng4XL/x X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.182.109 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796419547; b=CFINFP1S1Za8eUZ7oGPfarh+MP2jXnUHlZ6wKprWwHXwPg0NvlTxZJajiqDAZFj9a7FH fTtIGXL/N9S185IqdgrIDxfYhqYcSLM27W2pXocHe1sm/ufVHqlgorFHi5R6MbRK+7yie BFkuhlL68lebezF08w94SkOdN64KnTlHfQVCf7d+dILKCa/6T6HOUDxhqxrNLMOKqqrUF eIHetM0LvsF/O0nRSYw4zlqnKnStuJpzM1NcU85LYk/0pKVvOpExPk1YG0yGNCWr4EGbo MyZWI0gG0CxKTRq1o/Du+vS0tD649pcgc9tk9aWXYRk4MzpVjj/u1uOs8lpOr3b987A== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796419547; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:In-Reply-To: References:Date:Message-ID:MIME-Version:Content-Type; bh=1B5DlsGQJBiBtjRlDw6A8+EiW0cSARAJhF54Kd04h9o=; b=EPdeKZeLCGyN7uPHNgAqLsZDm7wO4H4vxURUmULkfIpNScu+8kuYIKIBvcnHOL2mdz+b 0uvRroMKM5jU2seWkzzX1jJQpH2y+TLx2IvBzdbVCsHChBz/ekwtTWIK8WMwduuRiUxM8 lNkBlox75K0OtPxlZ3IGxvgvFgB/YCKhSRB0ST4vMsuztesgO/VUsAoLuZN+JgH/+BCUx 84RLoWORKnAkc9Rfr8X51ur+lzWQIH5DAs+l/RJED2LeHGOFgttr1tWLOLua4j0elgPte qrTtJYg2ojNekBiHYVIVCFr7xTPUAozemXukqhQqlD4jYiiZIy7Y7fsQuDifWl2sieg== 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="Mng4XL/x"; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.182.109 X-Received: from sender5-pp-e109.zoho.com (sender5-pp-e109.zoho.com [165.173.182.109]) (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 7E080606A322 for <git@vger.kernel.org>; Fri, 4 Dec 2026 21:25:47 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7E080606A322 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=1796419532; cv=none; d=zohomail.com; s=zohoarc; b=Vbax9elqxKt+mCObAb9FIm/LsP26A53b6jgeF5fEJSOEal7N2yM/HA2L7Pm5kWKP4aFMvaOsUM9kgeVRPivGOj7r1UQsm4ZVLVd51KE4g55J4368xEc9WOxIZfuAlu3gX8YBe4tJw13EfJV1vqpjpoxPYM3hgTWIj5XD0kxURTg= X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1796419532; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=1B5DlsGQJBiBtjRlDw6A8+EiW0cSARAJhF54Kd04h9o=; b=QB8XVbRbVjCuLzpjRa7wkbtufxKwSJSqeG2eRMGwh05lvyCX9TmfHyNwpIz6zUOOv03F9lq6XJk1VAzShyzKL7NMrIAIOnXmT9vtmcHbpu98z8kYB+0AJMeGYDpnC5n03d0PmYTWfhPAICuOYPdeO7KJk2I13X/WbDG62WvLC+M= 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=Mng4XL/xgNrLw3AEolwBPyznvE7eOSfwINhKjKg4IA8H09o1m3qCf8Tu+TRcFWA/9PbnMd6VRyj6WYocStVNlhZMHWdV+1Z9Q3EIyGgk56n+0de9AEgYTMd68LWcOFLU/uhPqOYEJIWeYt9vs+JFYkyZw/GB98g3Fim/aMqN5C0=; c=relaxed/relaxed; s=zohomail; d=collabora.com; v=1; bh=1B5DlsGQJBiBtjRlDw6A8+EiW0cSARAJhF54Kd04h9o=; 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 1796419530589385.9268919448273; Fri, 4 Dec 2026 13:25:30 -0800 (PST) X-Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>, Patrick Steinhardt <ps@pks.im>, "brian m . carlson" <sandals@crustytoothpaste.net> X-In-Reply-To: <8733sddjk9.fsf@email.froward.int.ebiederm.org> 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