refs-be-files.c: rename refs to refs-be-files

Rename refs.c to refs-be-files.c to indicate that this file now
holds the implementation for the files based refs backend.
A smaller portion of the code in this file is backend agnostic and will
be moved to a a new refs.c file that will hold all the common refs code
that is shared across all backends.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: add a new refs.c file to hold all common refs code

Create a new erfs.c file that will be used to hold all the refs
code that is backend agnostic and will be shared across all backends.

The reason we renamed everything to refs-be-files.c in the previous patch
and now start moving the common code back to the new refs.c file
instead of the other way around is the etive volumes of code.

With the ref_cache, packed refs and loose ref handling that are all
part of the files based implementation the backend specific part
of the old refs.c file is several times larger than the backend agnostic
part. Therefore it makes more sense to first rename everything to be
part of the files based backend and then move the parts that can be used
as common code back to refs.c.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: move update_ref to refs.c

This change moves update_ref() to the refs.c file since this function
does not contain any backend specific code.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: move delete_ref to the common code

This change moves delete_ref() to the refs.c file since this function
does not contain any backend specific code.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: move rename_ref to the common code

This change moves rename_ref() to the refs.c file since this function
does not contain any backend specific code.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: move read_ref_at to the common refs file

This change moves read_ref_at() to the refs.c file since this function
does not contain any backend specific code.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: move the hidden refs functions to the common code

This change moves the hidden refs functions to the refs.c file since
these functions do not contain any backend specific code.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: move dwim and friend functions to the common refs code

These functions do not contain any backend specific code so we can move
them to the common code and share across all backends.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: move warn_if_dangling_symref* to the common code

These functions do not use any backend specific code so we can move
them to the common code.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: move read_ref, read_ref_full and ref_exists to the common code

These functions do not depend on the backend implementation so we
can move them to the common code.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: move resolve_refdup to common

This function can be shared across all refs backends so move it
to the common code.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: move check_refname_component to the common code

This function does not contain any backend specific code so we
can move it to the common code.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: move is_branch to the common code

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: move names_conflict to the common code

Move names_conflict to the common code and make it public.
We want to use the same name conflict checks across all backends
so we guarantee compatibility across backends.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: move prettify_refname to the common code

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: move ref iterators to the common code

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: move head_ref_namespaced to the common code

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs-be-files.c: add a backend method structure with transaction functions

Add a ref structure for backend methods. Start by adding method pointers
for the transaction functions.

Rename the existing transaction functions to files_* and make them static.
Add new transaction functions that just pass through to the appropriate
methods for the backend.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs-be-files.c: add reflog backend methods

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs-be-files.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>