Commit graph

15 commits

Author SHA1 Message Date
Linus Torvalds 1b555932cd Fix seriously broken "git pack-refs"
Do *NOT* try this on a repository you care about:

	git pack-refs --all --prune
	git pack-refs

because while the first "pack-refs" does the right thing, the second
pack-refs will totally screw you over.

This is because the second one tries to pack only tags; we should
also pack what are already packed -- otherwise we would lose them.

[jc: with an additional test]

Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-25 19:16:07 -08:00
Junio C Hamano 0f018baba6 --prune is now default for 'pack-refs'
There is no reason not to, really.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-08 14:46:00 -08:00
Junio C Hamano f4204ab9f6 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 "^<sha-1>".

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 <junkio@cox.net>
2006-11-21 23:37:35 -08:00
Junio C Hamano cf0adba788 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>
2006-11-19 18:45:44 -08:00
Alexandre Julliard ca8e2d86c4 pack-refs: Store the full name of the ref even when packing only tags.
Using for_each_tag_ref() to enumerate tags is wrong since it removes
the refs/tags/ prefix, we need to always use for_each_ref() and filter
out non-tag references in the callback.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-11-02 18:04:40 -08:00
Junio C Hamano b3d4204fc4 git-pack-refs --all
This changes 'git-pack-refs' to pack only tags by default.
Branches are meant to be updated, either by committing onto it
yourself or tracking remote branches, and packed entries can
become stale easily, but tags are usually "create once and live
forever" and benefit more from packing.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-10-08 01:36:08 -07:00
Junio C Hamano 422b4a0e03 pack-refs: call fflush before fsync.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-10-04 21:37:15 -07:00
Junio C Hamano 03a182107f pack-refs: use lockfile as everybody else does.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-10-03 02:15:18 -07:00
Junio C Hamano 4431fcc4b1 Clean-up lock-ref implementation
This drops "mustexist" parameter lock_ref_sha1() and lock_any_ref_forupdate()
functions take.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-27 01:42:44 -07:00
Junio C Hamano 6d15987c1e pack-refs: fix git_path() usage.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-22 21:31:40 -07:00
Junio C Hamano 9688460152 git-pack-refs --prune
"git pack-refs --prune", after successfully packing the existing
refs, removes the loose ref files.  It tries to protect against
race by doing the usual lock_ref_sha1() which makes sure the
contents of the ref has not changed since we last looked at.

Also we do not bother trying to prune what was already packed, and
we do not try pruning symbolic refs.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-21 00:06:54 -07:00
Junio C Hamano 13e4aa90ac pack-refs: do not pack symbolic refs.
Now we can tell which one is symbolic and which one is not, it
is easy to do so.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-21 00:06:50 -07:00
Junio C Hamano 8da1977554 Tell between packed, unpacked and symbolic refs.
This adds a "int *flag" parameter to resolve_ref() and makes
for_each_ref() family to call callback function with an extra
"int flag" parameter.  They are used to give two bits of
information (REF_ISSYMREF and REF_ISPACKED) about the ref.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-20 22:02:01 -07:00
Junio C Hamano cb5d709ff8 Add callback data to for_each_ref() family.
This is a long overdue fix to the API for for_each_ref() family
of functions.  It allows the callers to specify a callback data
pointer, so that the caller does not have to use static
variables to communicate with the callback funciton.

The updated for_each_ref() family takes a function of type

	int (*fn)(const char *, const unsigned char *, void *)

and a void pointer as parameters, and calls the function with
the name of the ref and its SHA-1 with the caller-supplied void
pointer as parameters.

The commit updates two callers, builtin-name-rev.c and
builtin-pack-refs.c as an example.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-20 21:47:42 -07:00
Linus Torvalds e1e22e37f4 Start handling references internally as a sorted in-memory list
This also adds some very rudimentary support for the notion of packed
refs.  HOWEVER! At this point it isn't used to actually look up a ref
yet, only for listing them (ie "for_each_ref()" and friends see the
packed refs, but none of the other single-ref lookup routines).

Note how we keep two separate lists: one for the loose refs, and one for
the packed refs we read. That's so that we can easily keep the two apart,
and read only one set or the other (and still always make sure that the
loose refs take precedence).

[ From this, it's not actually obvious why we'd keep the two separate
  lists, but it's important to have the packed refs on their own list
  later on, when I add support for looking up a single loose one.

  For that case, we will want to read _just_ the packed refs in case the
  single-ref lookup fails, yet we may end up needing the other list at
  some point in the future, so keeping them separated is important ]

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-17 19:09:11 -07:00