]> git.ipfire.org Git - thirdparty/git.git/commit - builtin/describe.c
Improve git-describe performance by reducing revision listing.
authorShawn O. Pearce <spearce@spearce.org>
Sat, 13 Jan 2007 22:30:53 +0000 (17:30 -0500)
committerJunio C Hamano <junkio@cox.net>
Mon, 15 Jan 2007 05:17:27 +0000 (21:17 -0800)
commit8713ab307940c37906631efb8ef96be37963f81c
tree39e13ca8204ec99a5b7a59c2510e0a4d4a36f329
parent910c0d7b5ea09d55f769062abd9b9fe3af904a23
Improve git-describe performance by reducing revision listing.

My prior version of git-describe ran very slowly on even reasonably
sized projects like git.git and linux.git as it tended to identify
a large number of possible tags and then needed to generate the
revision list for each of those tags to sort them and select the
best tag to describe the input commit.

All we really need is the number of commits in the input revision
which are not in the tag.  We can generate these counts during
the revision walking and tag matching loop by assigning a color to
each tag and coloring the commits as we walk them.  This limits us
to identifying no more than 26 possible tags, as there is limited
space available within the flags field of struct commit.

The limitation of 26 possible tags is hopefully not going to be a
problem in real usage, as most projects won't create 26 maintenance
releases and merge them back into a development trunk after the
development trunk was tagged with a release candidate tag.  If that
does occur git-describe will start to revert to its old behavior of
using the newer maintenance release tag to describe the development
trunk, rather than the development trunk's own tag.  The suggested
workaround would be to retag the development trunk's tip.

However since even 26 possible tags can take a while to generate a
description for on some projects I'm defaulting the limit to 10 but
offering the user --candidates to increase the number of possible
matches if they need a more accurate result.  I specifically chose
10 for the default as it seems unlikely projects will have more
than 10 maintenance releases merged into a development trunk before
retagging the development trunk, and it seems to perform about the
same on linux.git as v1.4.4.4 git-describe.

A large amount of debugging information was also added during
the development of this change, so I've left it in to be toggled
on with --debug.  It may be useful to the end user to help them
understand why git-describe took one particular tag over another.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Documentation/git-describe.txt
builtin-describe.c