From: Junio C Hamano <gitster@pobox.com>
To: Adrian Ratiu <adrian.ratiu@collabora.com>
Cc: git@vger.kernel.org, Patrick Steinhardt <ps@pks.im>,
"Eric W . Biederman" <ebiederm@xmission.com>,
"brian m . carlson" <sandals@crustytoothpaste.net>
Subject: Re: [PATCH v3 3/4] object-file-convert: match tree, parent and mergetag headers by key
Date: Sun, 06 Dec 2026 10:45:45 +0900 [thread overview]
Message-ID: <xmqqo6aztc52.fsf@gitster.g> (raw)
In-Reply-To: <ed6dcdd93dde4294ad940e501b52f44b43d41be9.1795455594.git.adrian.ratiu@collabora.com> (Adrian Ratiu's message of "Mon, 30 Nov 2026 15:43:24 +0200")
Adrian Ratiu <adrian.ratiu@collabora.com> writes:
> convert_commit_object() only enters the "tree ", "parent " and
> "mergetag " cases when something follows the space.
>
> A line like "parent \n" falls through to the final "else", which
> rejects any line it does not know.
>
> The next commit makes that "else" copy unknown lines unchanged. Then
> "parent \n" would be copied into the compat object instead of being
> rejected. Worse, a "mergetag " line whose tag starts on the next line
> would be copied together with the unconverted object ID in that tag.
>
> Use "<=" instead of "<", so that these lines enter their own case and
> are rejected there.
>
> An empty "tree " or "parent " fails the length check before
> parse_oid_hex_algop() is reached. An empty "mergetag " leaves a tag
> that doesn't start with "object ", which convert_tag_object() rejects.
>
> This doesn't change behaviour: these lines are rejected as before,
> only now with an error saying why, e.g. "bad parent in commit".
>
> Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
> ---
> object-file-convert.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
Splitting this into its own preparatory commit makes the motivation
completely clear.
>
> diff --git a/object-file-convert.c b/object-file-convert.c
> index 63ee18630b..af14cf8300 100644
> --- a/object-file-convert.c
> +++ b/object-file-convert.c
> @@ -167,7 +167,7 @@ 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))
Using <= still keeps the memcmp() reads within [bufptr, eol), since at
equality the trailing space sits right before the newline at 'eol'.
Empty "tree " and "parent " lines then fail the 'tree_entry_len' and
'parent_entry_len' checks immediately, and an empty "mergetag " seeds
'tag' with "\n" so convert_tag_object() rejects it as not starting with
"object " even if continuation lines follow.
Nicely done.
next prev parent reply other threads:[~2026-12-06 1:45 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 19:57 [PATCH 0/3] compatObjectFormat: fix a BUG(), wrong id and unknown headers Adrian Ratiu
2026-11-12 19:57 ` [PATCH 1/3] setup: reject compatObjectFormat == objectFormat Adrian Ratiu
2026-11-16 7:36 ` Patrick Steinhardt
2026-11-17 10:42 ` Adrian Ratiu
2026-11-12 19:57 ` [PATCH 2/3] rev-parse: die when --output-object-format cannot map an object Adrian Ratiu
2026-11-16 7:37 ` Patrick Steinhardt
2026-11-17 11:55 ` Adrian Ratiu
2026-11-12 19:57 ` [PATCH 3/3] object-file-convert: copy unknown commit headers unchanged Adrian Ratiu
2026-11-16 7:37 ` Patrick Steinhardt
2026-11-17 15:27 ` Adrian Ratiu
2026-11-19 14:18 ` [PATCH v2 0/3] compatObjectFormat: fix a BUG(), wrong ID and unknown headers Adrian Ratiu
2026-11-19 14:18 ` [PATCH v2 1/3] setup: reject compatObjectFormat == objectFormat Adrian Ratiu
2026-11-20 22:21 ` Junio C Hamano
2026-11-19 14:18 ` [PATCH v2 2/3] rev-parse: die when --output-object-format cannot map an object Adrian Ratiu
2026-11-20 22:29 ` Junio C Hamano
2026-11-23 16:12 ` Adrian Ratiu
2026-11-19 14:18 ` [PATCH v2 3/3] object-file-convert: copy unknown commit headers unchanged Adrian Ratiu
2026-11-20 22:41 ` Junio C Hamano
2026-11-23 16:41 ` Adrian Ratiu
2026-11-21 0:30 ` Junio C Hamano
2026-11-21 19:08 ` Junio C Hamano
2026-11-23 16:16 ` Adrian Ratiu
2026-11-21 2:59 ` [PATCH v2 0/3] compatObjectFormat: fix a BUG(), wrong ID and unknown headers Junio C Hamano
2026-11-30 13:43 ` [PATCH v3 0/4] " Adrian Ratiu
2026-11-30 13:43 ` [PATCH v3 1/4] setup: reject compatObjectFormat == objectFormat Adrian Ratiu
2026-12-06 0:38 ` Junio C Hamano
2026-11-30 13:43 ` [PATCH v3 2/4] rev-parse: die when --output-object-format cannot map an object Adrian Ratiu
2026-12-06 1:08 ` Junio C Hamano
2026-11-30 13:43 ` [PATCH v3 3/4] object-file-convert: match tree, parent and mergetag headers by key Adrian Ratiu
2026-12-01 8:15 ` Patrick Steinhardt
2026-12-01 11:29 ` Adrian Ratiu
2026-12-06 1:45 ` Junio C Hamano [this message]
2026-11-30 13:43 ` [PATCH v3 4/4] object-file-convert: copy unknown commit headers unchanged Adrian Ratiu
2026-12-04 17:47 ` Eric W. Biederman
2026-12-04 21:25 ` Adrian Ratiu
2026-12-06 0:38 ` [PATCH v3 0/4] compatObjectFormat: fix a BUG(), wrong ID and unknown headers Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqo6aztc52.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=adrian.ratiu@collabora.com \
--cc=ebiederm@xmission.com \
--cc=git@vger.kernel.org \
--cc=ps@pks.im \
--cc=sandals@crustytoothpaste.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox