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 v3 2/4] rev-parse: die when --output-object-format cannot map an object
Date: Sun, 06 Dec 2026 10:08:02 +0900	[thread overview]
Message-ID: <xmqqjylnb4i5.fsf@gitster.g> (raw)
In-Reply-To: <5d5527aa404ecf02017dcc132c0a2879f8718c39.1795455594.git.adrian.ratiu@collabora.com> (Adrian Ratiu's message of "Mon, 30 Nov 2026 15:43:23 +0200")

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

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

The rewording is much clearer for positional revision arguments (both
"rev" and "^rev").  Note that --default and ref-enumeration options like
--all, --branches, or --disambiguate also call show_rev() directly and
ignore output_algo, though leaving those alongside ranges and parent
shorthands for a follow-up makes sense.

> diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
> index d2154eac8d..f4b5a31aff 100644
> --- a/builtin/rev-parse.c
> +++ b/builtin/rev-parse.c
> @@ -1171,9 +1171,11 @@ int cmd_rev_parse(int argc,
>  		}
>  		if (!repo_get_oid_with_flags(the_repository, name, &oid,
>  					     flags)) {
> -			if (output_algo)
> -				repo_oid_to_algop(the_repository, &oid,
> -						  output_algo, &oid);
> +			if (output_algo &&
> +			    repo_oid_to_algop(the_repository, &oid,
> +					      output_algo, &oid) < 0)
> +				die(_("cannot map object %s to %s"),
> +				    oid_to_hex(&oid), output_algo->name);

Even though &oid is passed as both source and destination to
repo_oid_to_algop(), repo_loose_object_map_oid() leaves 'dest' untouched
when no mapping exists, so oid_to_hex(&oid) still formats the original
resolved OID for the error message.

Using the same message as pack-objects is nice for consistency.

Looking good.

  reply	other threads:[~2026-12-06  1:08 UTC|newest]

Thread overview: 35+ 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 [this message]
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-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=xmqqjylnb4i5.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