Skip to content

Commit 851b3d7

Browse files
avargitster
authored andcommitted
object-name: show date for ambiguous tag objects
Make the ambiguous tag object output nicer in the case of tag objects such as ebf3c04 (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: b7e68c4 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: b7e68f6 tree hint: b7e6849 blob b7e68 [...] Before this we'd emit a "tag" line without a date, e.g.: hint: b7e68c4 tag v2.32.0 Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ba5e8a0 commit 851b3d7

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

object-name.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,19 +408,24 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)
408408
* TRANSLATORS: This is a line of ambiguous
409409
* tag object output. E.g.:
410410
*
411-
* "deadbeef tag Some Tag Message"
411+
* "deadbeef tag 2022-01-01 - Some Tag Message"
412412
*
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
414417
* from object.c.
415418
*/
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);
417422
} else {
418423
/*
419424
* TRANSLATORS: This is a line of ambiguous
420425
* tag object output where we couldn't parse
421426
* the tag itself. E.g.:
422427
*
423-
* "deadbeef tag [bad tag, could not parse it]"
428+
* "deadbeef [bad tag, could not parse it]"
424429
*/
425430
strbuf_addf(&desc, _("%s [bad tag, could not parse it]"),
426431
hash);

0 commit comments

Comments
 (0)