]> git.ipfire.org Git - thirdparty/git.git/commit - builtin/prune.c
prune: factor out loose-object directory traversal
authorJeff King <peff@peff.net>
Wed, 15 Oct 2014 22:38:55 +0000 (18:38 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 16 Oct 2014 17:10:39 +0000 (10:10 -0700)
commit27e1e22d5ee3005f228b67ea94b5af29547b54fe
treeb6852aec3312ebdffffb968023864782cd0a01e2
parent718ccc9731c4e98b123436c22c1cccf2beed5e29
prune: factor out loose-object directory traversal

Prune has to walk $GIT_DIR/objects/?? in order to find the
set of loose objects to prune. Other parts of the code
(e.g., count-objects) want to do the same. Let's factor it
out into a reusable for_each-style function.

Note that this is not quite a straight code movement. The
original code had strange behavior when it found a file of
the form "[0-9a-f]{2}/.{38}" that did _not_ contain all hex
digits. It executed a "break" from the loop, meaning that we
stopped pruning in that directory (but still pruned other
directories!). This was probably a bug; we do not want to
process the file as an object, but we should keep going
otherwise (and that is how the new code handles it).

We are also a little more careful with loose object
directories which fail to open. The original code silently
ignored any failures, but the new code will complain about
any problems besides ENOENT.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/prune.c
cache.h
sha1_file.c