Re: [PATCH v7 4/6] object-name: show date for ambiguous tag objects
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 13, 2022, 22:46 UTC
- Message-ID
- <xmqq1r1bgso2.fsf@gitster.g>
- In-Reply-To
- <patch-v7-4.6-2e5511c9fa5-20220111T130811Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> } else if (type == OBJ_TAG) {
> struct tag *tag = lookup_tag(ds->repo, oid);
> const char *tag_tag = "";
> + timestamp_t tag_date = 0;How about leaving these two uninitialized and introduce one extra bool, int tag_info_valid = 0;
and then
Show 5 quoted lines
>
> - if (!parse_tag(tag) && tag->tag)
> + if (!parse_tag(tag) && tag->tag) {
> tag_tag = tag->tag;
> + tag_date = tag->date;tag_info_valid = 1;
Show 16 quoted lines
> + }
>
> /*
> * 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.
> */
> - 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);Then this part can use tag_info_valid to conditionally use tag_date and tag_tag:
if (tag_info_valid)
strbuf_addf(&desc, ... <hash,date,tag>);
else
strbuf_addf(&desc, _("%s tag [bad]"), hash);without throwing a misleading "In 1970 this happened".
> } else if (type == OBJ_TREE) {
> /*
> * TRANSLATORS: This is a line of ambiguous <type>