enable debugging using the GITFS_DEBUG variable

Before, this was triggered using the DEBUG variable, but this is also
set by live-boot when 'debug' is given on the commandline, causing
git-fs to not background and stalling the boot.
allow passing options to fuse

This allows passing options like -f (foreground), -d (debug), -s (single
threaded) and various mount options with -o to fuse. In addition, git-fs
itself now also listens to -d for debugging info, instead of the DEBUG
environment variable.
remove some seamingly meaningless memsets

These clear out buffers passed in by fuse, but I don't think we should
be touching those buffers except for writing actual data. In addition,
it's double work, so let's just not clear them.
make git-fs chroot into the .git directory

This allows using git-fs from a live-boot initrd by making it resistant
to moving the .git directory (or rather, the mount point above it),
around the filesystem.

Also add some extra error checking.
move defines from the Makefile into git-fs.c

This allows the git-fs.c file to be checked by itself, which plays
nicely with the syntastic vim plugin.
let git-fs use a commit instead of the index to get its files

Right now, this is hardcoded to "HEAD", but it will be configurable in
the future.

This change should also improve the performance, since a tree object is
actually stored in a tree datastructure and the lookup at each level
uses a binary search as well (instead of the single linear search
through all the filenames that was done before).

As an extra advantage, a tree contains explicit (subtree) objects for
directories, which removes the need to fiddle with prefix matching.

This commit also removes a lot of duplicate lookups by locating the
right tree entry in the open / opendir call and then using that pointer
in the read call.

Finally, it switches readdir from writing back its results all at once
(like before, which needs fuse to allocate additional memory for storing
those objects) to just filling up one buffer worth of filenames and
letting fuse call a second time.
restructure entry lookup

This simplifies some functions, removes some duplicate code and makes
some lookups occur less often.
make sure all memory gets freed

Before, there were some cases, especially in error paths, that left
memory leaking around.
make sure all error messages have a newline
Process the git repo path using realpath()

When not running on the foreground, fuse does a chdir("/") as part of
the detaching process, which breaks any relative repository path given
(since we don't use it until after fuse_main is done initializing). By
turning the path into an absolute path during argument processing, it
will remain working.
force mounts to be read-only
force fuse to use single-threaded mode

It seems libgit2 isn't completely thread-safe yet and running fuse in
multithreaded mode will make it cause errors (segfaults, bus errors,
deadlocks) when hammered hard enough (i.e. when used as a rootfs).
use git_revparse_single to resolve the rev to checkout

Unlike the previous git_reference_name_to_oid, this supports branch
names, tags, trees, shas, etc. instead of just symbolic refs.

Note that this function requires a libgit2 newer that 0.17 (i.e., this
requires libgit2 from git).
let gitfs_opt_proc return -1 on error

Previously, it would just not set the repo path and assume that the main
function would bail out, but it turns out you can tell fuse to return an
error explicitly, which should be more reliable.
Allow specifying the revision / tree to use with --rev or -o rev
report usage info on errors and -h / --help
move some initialization code to main()

This opens the repo twice, once before fuse_main and the chroot and once
after the chroot. This allows more initialization errors to be reported
to the user, before fuse_main detaches from the terminal.
add -o options to fuse in a different way

This is a bit more extendable for adding more options in the future.
set an fsname for fuse

This causes mount to say "/foo.git on /somewhere" instead of "git-fs on
/somewhere".
fix the permission bits for symlinks