summaryrefslogtreecommitdiff
path: root/compat/basename.c
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2017-01-13 12:58:16 -0500
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-01-15 15:59:03 -0800
commitf6371f9210418f1beabc85b097e2a3470aeeb54d (patch)
treebf422bd41f553c2b60982b08f2e802de3a9e3b97 /compat/basename.c
parentt1450: test fsck of packed objects (diff)
downloadtgif-f6371f9210418f1beabc85b097e2a3470aeeb54d.tar.xz
sha1_file: add read_loose_object() function
It's surprisingly hard to ask the sha1_file code to open a _specific_ incarnation of a loose object. Most of the functions take a sha1, and loop over the various object types (packed versus loose) and locations (local versus alternates) at a low level. However, some tools like fsck need to look at a specific file. This patch gives them a function they can use to open the loose object at a given path. The implementation unfortunately ends up repeating bits of related functions, but there's not a good way around it without some major refactoring of the whole sha1_file stack. We need to mmap the specific file, then partially read the zlib stream to know whether we're streaming or not, and then finally either stream it or copy the data to a buffer. We can do that by assembling some of the more arcane internal sha1_file functions, but we end up having to essentially reimplement unpack_sha1_file(), along with the streaming bits of check_sha1_signature(). Still, most of the ugliness is contained in the new function, and the interface is clean enough that it may be reusable (though it seems unlikely anything but git-fsck would care about opening a specific file). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'compat/basename.c')
0 files changed, 0 insertions, 0 deletions