summaryrefslogtreecommitdiff
path: root/builtin-pack-refs.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-11-19 21:22:44 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-11-20 02:45:44 (GMT)
commitcf0adba7885342e1bbcf0689fece9d13e39784b4 (patch)
treec6559d40439c8e28fb0634292738e00693deb88e /builtin-pack-refs.c
parentef06b91804ff5a626e265c6d9080bbc0e7924e88 (diff)
downloadgit-cf0adba7885342e1bbcf0689fece9d13e39784b4.zip
git-cf0adba7885342e1bbcf0689fece9d13e39784b4.tar.gz
git-cf0adba7885342e1bbcf0689fece9d13e39784b4.tar.bz2
Store peeled refs in packed-refs file.
This would speed up "show-ref -d" in a repository with mostly packed tags. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-pack-refs.c')
-rw-r--r--builtin-pack-refs.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/builtin-pack-refs.c b/builtin-pack-refs.c
index 042d271..ee5a556 100644
--- a/builtin-pack-refs.c
+++ b/builtin-pack-refs.c
@@ -1,5 +1,7 @@
#include "cache.h"
#include "refs.h"
+#include "object.h"
+#include "tag.h"
static const char builtin_pack_refs_usage[] =
"git-pack-refs [--all] [--prune]";
@@ -29,12 +31,26 @@ static int handle_one_ref(const char *path, const unsigned char *sha1,
int flags, void *cb_data)
{
struct pack_refs_cb_data *cb = cb_data;
+ int is_tag_ref;
- if (!cb->all && strncmp(path, "refs/tags/", 10))
- return 0;
/* Do not pack the symbolic refs */
- if (!(flags & REF_ISSYMREF))
- fprintf(cb->refs_file, "%s %s\n", sha1_to_hex(sha1), path);
+ if ((flags & REF_ISSYMREF))
+ return 0;
+ is_tag_ref = !strncmp(path, "refs/tags/", 10);
+ if (!cb->all && !is_tag_ref)
+ return 0;
+
+ fprintf(cb->refs_file, "%s %s\n", sha1_to_hex(sha1), path);
+ if (is_tag_ref) {
+ struct object *o = parse_object(sha1);
+ if (o->type == OBJ_TAG) {
+ o = deref_tag(o, path, 0);
+ if (o)
+ fprintf(cb->refs_file, "%s %s^{}\n",
+ sha1_to_hex(o->sha1), path);
+ }
+ }
+
if (cb->prune && !do_not_prune(flags)) {
int namelen = strlen(path) + 1;
struct ref_to_prune *n = xcalloc(1, sizeof(*n) + namelen);