object-name: show date for ambiguous tag objects

Make the ambiguous tag object output nicer in the case of tag objects such as ebf3c04b262 (Git 2.32, 2021-06-06) by including the date in the "tagger" header. I.e.: $ git rev-parse b7e68 error: short object ID b7e68 is ambiguous hint: The candidates are: hint: b7e68c41d92 tag 2021-06-06 - v2.32.0 hint: b7e68ae18e0 commit 2019-12-23 - bisect: use the standard 'if (!var)' way to check for 0 hint: b7e68f6b413 tree hint: b7e68490b97 blob b7e68 [...] Before this we'd emit a "tag" line without a date, e.g.: hint: b7e68c41d92 tag v2.32.0 Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Jan 27, 2022 at 06:26 UTC 851b3d7671778b74e40bf155c49f6b045f5eb4df
1 file changed +9 -4
object-name.c
+9 -4
@@ -408,19 +408,24 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)
408 * TRANSLATORS: This is a line of ambiguous
409 * tag object output. E.g.:
410 *
411 - * "deadbeef tag Some Tag Message"
411 + * "deadbeef tag 2022-01-01 - Some Tag Message"
412 *
413 - * The second argument is the "tag" string
413 + * The second argument is the YYYY-MM-DD found
414 + * in the tag.
415 + *
416 + * The third argument is the "tag" string
417 * from object.c.
418 */
416 - strbuf_addf(&desc, _("%s tag %s"), hash, tag->tag);
419 + strbuf_addf(&desc, _("%s tag %s - %s"), hash,
420 + show_date(tag->date, 0, DATE_MODE(SHORT)),
421 + tag->tag);
422 } else {
423 /*
424 * TRANSLATORS: This is a line of ambiguous
425 * tag object output where we couldn't parse
426 * the tag itself. E.g.:
427 *
423 - * "deadbeef tag [bad tag, could not parse it]"
428 + * "deadbeef [bad tag, could not parse it]"
429 */
430 strbuf_addf(&desc, _("%s [bad tag, could not parse it]"),
431 hash);