diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2008-02-24 03:07:25 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-02-24 10:01:24 -0800 |
commit | feededd05b551a02a95fe2a736e9d5f688b86119 (patch) | |
tree | d719ce9319e2041d3638fa1dab2149a5807de62b /builtin-describe.c | |
parent | 0ae91be0e1fac3ff31675f0ec2c7ebf2bb5c1be6 (diff) | |
download | git-feededd05b551a02a95fe2a736e9d5f688b86119.tar.gz git-feededd05b551a02a95fe2a736e9d5f688b86119.tar.xz |
Teach git-describe to use peeled ref information when scanning tags
By using the peeled ref information inside of the packed-refs file we
can avoid opening tag objects to obtain the commits they reference.
This speeds up git-describe when there are a large number of tags
in the repository as we have less objects to parse before we can
start commit matching.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-describe.c')
-rw-r--r-- | builtin-describe.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/builtin-describe.c b/builtin-describe.c index 342848313..bfd25e232 100644 --- a/builtin-describe.c +++ b/builtin-describe.c @@ -46,19 +46,30 @@ static void add_to_known_names(const char *path, static int get_name(const char *path, const unsigned char *sha1, int flag, void *cb_data) { - struct commit *commit = lookup_commit_reference_gently(sha1, 1); + struct commit *commit; struct object *object; - int prio; + unsigned char peeled[20]; + int is_tag, prio; + + if (!peel_ref(path, peeled) && !is_null_sha1(peeled)) { + commit = lookup_commit_reference_gently(peeled, 1); + if (!commit) + return 0; + is_tag = !!hashcmp(sha1, commit->object.sha1); + } else { + commit = lookup_commit_reference_gently(sha1, 1); + object = parse_object(sha1); + if (!commit || !object) + return 0; + is_tag = object->type == OBJ_TAG; + } - if (!commit) - return 0; - object = parse_object(sha1); /* If --all, then any refs are used. * If --tags, then any tags are used. * Otherwise only annotated tags are used. */ if (!prefixcmp(path, "refs/tags/")) { - if (object->type == OBJ_TAG) { + if (is_tag) { prio = 2; if (pattern && fnmatch(pattern, path + 10, 0)) prio = 0; |