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.180.12 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== 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== 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 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 ; Mon, 30 Nov 2026 13:45:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A2783606A327 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=JIlz2b4U ARC-Seal: i=1; a=rsa-sha256; t=1796046314; cv=none; d=zohomail.com; s=zohoarc; b=Bv7A7KuHZLG0ig97KdZndHvuOhYCjhzrBE/UimeJFP5ZCa9PXWTf91ZTWRkya881z3DE57WJ4lC7Bz1UefLvA5Ct1OfH3ZGp+7YdCNSYtThvERBGjlYkKmviDiOjnm3cboRyMrTXB83d+Cl0oar80H7cl+pt8wcR1UYPcAApz9Q= 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= 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=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; Received: by smtp.zohomail.com with SMTPS id 179604631313136.79002489285392; Mon, 30 Nov 2026 05:45:13 -0800 (PST) From: Adrian Ratiu To: git@vger.kernel.org Cc: Adrian Ratiu , Junio C Hamano , Patrick Steinhardt , "Eric W . Biederman" , "brian m . carlson" Subject: [PATCH v3 0/4] compatObjectFormat: fix a BUG(), wrong ID and unknown headers Date: Mon, 30 Nov 2026 15:43:21 +0200 Message-ID: X-Mailer: git-send-email 2.56.1 In-Reply-To: References: 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-Transfer-Encoding: 8bit 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 -: ---------- > 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 ## 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