refs.c: add reflog backend methods

Add methods for the reflog functions.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: add methods for misc ref operations

Add ref backend methods for:
resolve_ref_unsafe, is_refname_available, pack_refs, peel_ref,
create_symref, resolve_gitlink_ref.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: add methods for head_ref*

Add methods for the head_ref* functions.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: add methods for the ref iterators

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs-be-files.c: rename refs.c to refs-be-files.c

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: add a database backend for the refs

Add a new type of refs backend that offloads the refs storage to a separate
refs daemon using a domain socket.
Communications with this new daemon goes through a socket and uses
7 simple rpc functions:

fetch, store, delete, traverse, start_transaction, cancel_transaction and
commit_transaction.

An example refs daemon will be released as a separate project. This
reference daemon will use a simple key-value store to store all the refs
and will serve as an example to use and modify for other databases.

The patch introduces a new file refs-be-db.c which implements a new
refs backend and the required methods. This file implements a simple schema to
store refs and reflogs in a key value store and then passes simple RPCs
across to the refs daemon for the actual integration with the database.

Two new configuration variables are added:
core.db-repo-name:
  Which is an arbitrary ascii string that names the repo.
  The repo-name is part of the refs daemon protocol thus allowing
  using one single database/database daemon to store the refs for
  many/all git repositories on the host.
core.db-socket:
  Path to the unix domain socket to use for communication with the daemon.

clone.c and init-db.c has two new arguments :
--db-repo-name=<>
--db-socket=<>
both of which must be specified if you want to use an external database
daemon instead of storing the refs as files under .git

Handle submodule support by requiring that a submodule, and any gitlink,
points to a repository that has compatible backend configuration.
For the database backend this means that the submodule/gitlink target
is also using the database backend and that it is using the same database
daemon.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
git-submodule.sh: create submodules using same backend as main repo

When creating a submodule create a submodule with the same type of
database backend as the amin repo. Automatically generate a repo name
based on the main repo name and the submodule name as :
<main-repo-name>_submodule_<submodule-name>

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
setup.c: do not check for a HEAD file in is_git_directory

Don't check for a HEAD file in the .git direcotry when determining if the
directory is a git directory or not. Only the files backend will have a
HEADs file, not the others.

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>