From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.182.109 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== 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== 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 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 ; Fri, 4 Dec 2026 21:25:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7E080606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=zohomail header.b=Mng4XL/x ARC-Seal: i=1; a=rsa-sha256; t=1796419532; cv=none; d=zohomail.com; s=zohoarc; b=Vbax9elqxKt+mCObAb9FIm/LsP26A53b6jgeF5fEJSOEal7N2yM/HA2L7Pm5kWKP4aFMvaOsUM9kgeVRPivGOj7r1UQsm4ZVLVd51KE4g55J4368xEc9WOxIZfuAlu3gX8YBe4tJw13EfJV1vqpjpoxPYM3hgTWIj5XD0kxURTg= 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= 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= 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; Received: by smtp.zohomail.com with SMTPS id 1796419530589385.9268919448273; Fri, 4 Dec 2026 13:25:30 -0800 (PST) From: Adrian Ratiu To: "Eric W. Biederman" Cc: git@vger.kernel.org, Junio C Hamano , Patrick Steinhardt , "brian m . carlson" Subject: Re: [PATCH v3 4/4] object-file-convert: copy unknown commit headers unchanged In-Reply-To: <8733sddjk9.fsf@email.froward.int.ebiederm.org> References: <366b8c310dcf1f03046cae422e7ac5c0eb618c9d.1795455594.git.adrian.ratiu@collabora.com> <8733sddjk9.fsf@email.froward.int.ebiederm.org> Date: Fri, 04 Dec 2026 23:25:25 +0200 Message-ID: <874icsg2m2.fsf@collabora.com> X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain Hi Eric, Really appreciate your review, thanks! On Fri, 04 Dec 2026, "Eric W. Biederman" 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 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 " 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 " [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