summaryrefslogtreecommitdiff
path: root/refs
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2017-04-16 08:41:26 +0200
committerJunio C Hamano <gitster@pobox.com>2017-04-16 21:32:45 -0700
commitb05855b5bcaf07fe8a636e621bd9d12d51963b5a (patch)
tree01832b86c7e5bf8defc66694362bddd561c8bdab /refs
parente121b9cb5f358c9779e02a2bf96fc545a896ab13 (diff)
downloadgit-b05855b5bcaf07fe8a636e621bd9d12d51963b5a.tar.gz
refs_verify_refname_available(): implement once for all backends
It turns out that we can now implement `refs_verify_refname_available()` based on the other virtual functions, so there is no need for it to be defined at the backend level. Instead, define it once in `refs.c` and remove the `files_backend` definition. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs')
-rw-r--r--refs/files-backend.c39
-rw-r--r--refs/refs-internal.h7
2 files changed, 8 insertions, 38 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 2a0538dea7..4185025efa 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -1724,10 +1724,9 @@ retry:
goto error_return;
} else if (remove_dir_recursively(&ref_file,
REMOVE_DIR_EMPTY_ONLY)) {
- if (verify_refname_available_dir(
- refname, extras, skip,
- get_loose_refs(refs),
- err)) {
+ if (refs_verify_refname_available(
+ &refs->base, refname,
+ extras, skip, err)) {
/*
* The error message set by
* verify_refname_available() is OK.
@@ -2094,9 +2093,9 @@ static struct ref_lock *lock_ref_sha1_basic(struct files_ref_store *refs,
*/
if (remove_empty_directories(&ref_file)) {
last_errno = errno;
- if (!verify_refname_available_dir(
- refname, extras, skip,
- get_loose_refs(refs), err))
+ if (!refs_verify_refname_available(
+ &refs->base,
+ refname, extras, skip, err))
strbuf_addf(err, "there are still refs under '%s'",
refname);
goto error_return;
@@ -2108,9 +2107,8 @@ static struct ref_lock *lock_ref_sha1_basic(struct files_ref_store *refs,
if (!resolved) {
last_errno = errno;
if (last_errno != ENOTDIR ||
- !verify_refname_available_dir(
- refname, extras, skip,
- get_loose_refs(refs), err))
+ !refs_verify_refname_available(&refs->base, refname,
+ extras, skip, err))
strbuf_addf(err, "unable to resolve reference '%s': %s",
refname, strerror(last_errno));
@@ -2606,26 +2604,6 @@ static int rename_tmp_log(struct files_ref_store *refs, const char *newrefname)
return ret;
}
-static int files_verify_refname_available(struct ref_store *ref_store,
- const char *newname,
- const struct string_list *extras,
- const struct string_list *skip,
- struct strbuf *err)
-{
- struct files_ref_store *refs =
- files_downcast(ref_store, REF_STORE_READ, "verify_refname_available");
- struct ref_dir *packed_refs = get_packed_refs(refs);
- struct ref_dir *loose_refs = get_loose_refs(refs);
-
- if (verify_refname_available_dir(newname, extras, skip,
- packed_refs, err) ||
- verify_refname_available_dir(newname, extras, skip,
- loose_refs, err))
- return -1;
-
- return 0;
-}
-
static int write_ref_to_lockfile(struct ref_lock *lock,
const unsigned char *sha1, struct strbuf *err);
static int commit_ref_update(struct files_ref_store *refs,
@@ -4288,7 +4266,6 @@ struct ref_storage_be refs_be_files = {
files_ref_iterator_begin,
files_read_raw_ref,
- files_verify_refname_available,
files_reflog_iterator_begin,
files_for_each_reflog_ent,
diff --git a/refs/refs-internal.h b/refs/refs-internal.h
index 545989ae7f..3d46131efb 100644
--- a/refs/refs-internal.h
+++ b/refs/refs-internal.h
@@ -590,12 +590,6 @@ typedef int read_raw_ref_fn(struct ref_store *ref_store,
const char *refname, unsigned char *sha1,
struct strbuf *referent, unsigned int *type);
-typedef int verify_refname_available_fn(struct ref_store *ref_store,
- const char *newname,
- const struct string_list *extras,
- const struct string_list *skip,
- struct strbuf *err);
-
struct ref_storage_be {
struct ref_storage_be *next;
const char *name;
@@ -612,7 +606,6 @@ struct ref_storage_be {
ref_iterator_begin_fn *iterator_begin;
read_raw_ref_fn *read_raw_ref;
- verify_refname_available_fn *verify_refname_available;
reflog_iterator_begin_fn *reflog_iterator_begin;
for_each_reflog_ent_fn *for_each_reflog_ent;