From 851b3d7671778b74e40bf155c49f6b045f5eb4df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Thu, 27 Jan 2022 06:26:47 +0100 Subject: object-name: show date for ambiguous tag objects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- object-name.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'object-name.c') diff --git a/object-name.c b/object-name.c index f31b50bc31..cbf459f566 100644 --- a/object-name.c +++ b/object-name.c @@ -408,19 +408,24 @@ static int show_ambiguous_object(const struct object_id *oid, void *data) * TRANSLATORS: This is a line of ambiguous * tag object output. E.g.: * - * "deadbeef tag Some Tag Message" + * "deadbeef tag 2022-01-01 - Some Tag Message" * - * The second argument is the "tag" string + * The second argument is the YYYY-MM-DD found + * in the tag. + * + * The third 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); } else { /* * TRANSLATORS: This is a line of ambiguous * tag object output where we couldn't parse * the tag itself. E.g.: * - * "deadbeef tag [bad tag, could not parse it]" + * "deadbeef [bad tag, could not parse it]" */ strbuf_addf(&desc, _("%s [bad tag, could not parse it]"), hash); -- cgit v1.2.3