path.c: update validate_headref to handle db ref backends

Update validate_headref to take an extra path argument to specify
which directory to read the git data from. If NULL then as before
this means we try to use the cwd.

Change the two callers to pass the optional path as argument.

In validate_headref, try to read the db configuration from "config"
and if this is possible, check if core.db_repo_name is set or not.
If we can not read the "config" file, then fail.
This changes behaviour of this function and makes the "is this a valid
.git directory" check a little bit stronger since the previous code would only
check if the file "HEAD" exist.

IF core.db-repo-name is set then we treat this as sufficient proof that
the directory is valid and implicitely that HEAD exists in the database.

If core.db-repo-name does NOT exist we fall back to the original check
to try to open the "HEAD" file and check that it looks sane-ish.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refsd-tdb: example refs database daemon

refsd-tdb.c is a simple reference implementation of a refs daemon.
This will eventually be hosted in a separate project but can live in this
branch for now.

Compile with :
gcc refsd-tdb.c -o refsd-tdb -l tdb

Run with:
./refsd-tdb /tmp/refsd.socket /tmp /tmp/refsd.log

Once the refs daemon is running you can start using it with newly
created git repositories by specifying the --db-socket and --db-repo-name
arguments to git clone/init-db :

git clone --db-repo-name=ROCKy --db-socket=/tmp/refsd.socket <some repo> .

This refs daemon is an example. It should be relatively straightforward
to modify it to attach to any other kind of data store.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>