Re: [PATCH v6 4/6] object-name: show date for ambiguous tag objects
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 30, 2021, 21:43 UTC
- Message-ID
- <xmqqv8z5py42.fsf@gitster.g>
- In-Reply-To
- <patch-v6-4.6-b5aa6e266f6-20211228T143223Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 31 quoted lines
> diff --git a/object-name.c b/object-name.c
> index dcf3ab99990..990f384129e 100644
> --- a/object-name.c
> +++ b/object-name.c
> @@ -403,21 +403,26 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)
> } else if (type == OBJ_TAG) {
> struct tag *tag = lookup_tag(ds->repo, oid);
> const char *tag_tag = "";
> + timestamp_t tag_date = 0;
>
> - if (!parse_tag(tag) && tag->tag)
> + if (!parse_tag(tag) && tag->tag) {
> tag_tag = tag->tag;
> + tag_date = tag->date;
> + }
>
> /*
> * TRANSLATORS: This is a line of
> * ambiguous tag object output. E.g.:
> *
> - * "deadbeef tag Some Tag Message"
> + * "deadbeef tag 2021-01-01 - Some Tag Message"
> *
> * The second argument is the "tag" string from
> * object.c, it should (hopefully) already be
> * translated.
> */
> - strbuf_addf(&desc, _("%s tag %s"), hash, tag_tag);
> + strbuf_addf(&desc, _("%s tag %s - %s"), hash,
> + show_date(tag_date, 0, DATE_MODE(SHORT)),
> + tag_tag);So, when parse_tag() errors out, we show "" and epoch? We should be able to do a better error reporting than that; tag_tag and tag_date are both local and they do not have to be used to store sentinel values like that. Instead perhaps remember that we failed to parse_tag(), and _omit_ unavailable piece of information from the output? I dunno.
> } else if (type == OBJ_TREE) {
> /*
> * TRANSLATORS: This is a line of ambiguous <type>