Git development
 help / color / mirror / Atom feed
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 v2 3/3] object-file-convert: copy unknown commit headers unchanged
Date: Fri, 20 Nov 2026 14:41:26 -0800	[thread overview]
Message-ID: <xmqqa4n3nn1l.fsf@gitster.g> (raw)
In-Reply-To: <26080a7a386bdd0ae14725d2e731d1be81774d49.1794932695.git.adrian.ratiu@collabora.com> (Adrian Ratiu's message of "Thu, 19 Nov 2026 16:18:22 +0200")

Adrian Ratiu <adrian.ratiu@collabora.com> writes:

> Make convert_commit_object() copy unknown headers and their
> continuation lines unchanged, just like convert_commit_extra_headers(),
> so both give the same compat object.
>
> The author, committer, encoding and gpgsig headers were already copied
> the same, so their separate cases are no longer needed.

In other words, we note the headers that carry object names on them
and make sure we convert these object names, and pass all the other
headers intact, since we do not have to even know about them.  Which
makes sense.

> diff --git a/object-file-convert.c b/object-file-convert.c
> index 63ee18630b..ae21eedc3d 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))
>  		{
>  			if (((bufptr + tree_entry_len) != eol) ||
>  			    parse_oid_hex_algop(bufptr + 5, &oid, &p, from) ||
> @@ -179,7 +179,7 @@ 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) ||
> @@ -192,7 +192,7 @@ 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;

The explanation in the proposed log message did mention these three
headers, but I do not think it sufficiently explained why comparison
started to include the equality case.  It said:

> The "tree ", "parent " and "mergetag " cases only matched a line with
> something after the space.

I do not recall the details of "mergetag", but I fail to see why it
makes sense to start copying a line that is "parent \n" now.  If it
is not "parent [0-9a-f]{algo->rawsz*2}\n", do we still want to pass
it to parse_oid_hex_algop() in the body of this "else if"?

> @@ -223,17 +223,26 @@ static int convert_commit_object(struct repository *repo,
>  			strbuf_release(&tag);
>  			strbuf_release(&new_tag);
>  		}
> -		else if (((bufptr + 7) < tail) && !memcmp(bufptr, "author ", 7))
> -			strbuf_add(out, bufptr, (eol - bufptr) + 1);
> -		else if (((bufptr + 10) < tail) && !memcmp(bufptr, "committer ", 10))
> -			strbuf_add(out, bufptr, (eol - bufptr) + 1);
> -		else if (((bufptr + 9) < tail) && !memcmp(bufptr, "encoding ", 9))
> -			strbuf_add(out, bufptr, (eol - bufptr) + 1);
> -		else if (((bufptr + 6) < tail) && !memcmp(bufptr, "gpgsig", 6))
> -			strbuf_add(out, bufptr, (eol - bufptr) + 1);

These are "headers we know about, but our knowledge on them do not
matter as we are copying the bits verbatim" cases.


      reply	other threads:[~2026-11-20 22:41 UTC|newest]

Thread overview: 17+ 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-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 [this message]

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=xmqqa4n3nn1l.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