From f4204ab9f6a192cdb9a68150e031d7183688bfeb Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 21 Nov 2006 23:36:35 -0800 Subject: Store peeled refs in packed-refs (take 2). This fixes the previous implementation which failed to optimize repositories with tons of lightweight tags. The updated packed-refs format begins with "# packed-refs with:" line that lists the kind of extended data the file records. Currently, there is only one such extension defined, "peeled". This stores the "peeled tag" on a line that immediately follows a line for a tag object itself in the format "^". The header line itself and any extended data are ignored by older implementation, so packed-refs file generated with this version can still be used by older git. packed-refs made by older git can of course be used with this version. Signed-off-by: Junio C Hamano --- builtin-pack-refs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'builtin-pack-refs.c') diff --git a/builtin-pack-refs.c b/builtin-pack-refs.c index ee5a5565af..8dc5b9efff 100644 --- a/builtin-pack-refs.c +++ b/builtin-pack-refs.c @@ -46,8 +46,8 @@ static int handle_one_ref(const char *path, const unsigned char *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); + fprintf(cb->refs_file, "^%s\n", + sha1_to_hex(o->sha1)); } } @@ -111,6 +111,10 @@ int cmd_pack_refs(int argc, const char **argv, const char *prefix) if (!cbdata.refs_file) die("unable to create ref-pack file structure (%s)", strerror(errno)); + + /* perhaps other traits later as well */ + fprintf(cbdata.refs_file, "# pack-refs with: peeled \n"); + for_each_ref(handle_one_ref, &cbdata); fflush(cbdata.refs_file); fsync(fd); -- cgit v1.2.3