refs: make delete_refs() virtual
In the file-based backend, delete_refs has some special optimization to deal with packed refs. In other backends, we might be able to make ref deletion faster by putting all deletions into a single transaction. So we need a special backend function for this. Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
fc6814637d
commit
a27dcf89b6
7
refs.c
7
refs.c
@ -1532,3 +1532,10 @@ int initial_ref_transaction_commit(struct ref_transaction *transaction,
|
|||||||
|
|
||||||
return refs->be->initial_transaction_commit(refs, transaction, err);
|
return refs->be->initial_transaction_commit(refs, transaction, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int delete_refs(struct string_list *refnames, unsigned int flags)
|
||||||
|
{
|
||||||
|
struct ref_store *refs = get_ref_store(NULL);
|
||||||
|
|
||||||
|
return refs->be->delete_refs(refs, refnames, flags);
|
||||||
|
}
|
||||||
|
@ -2451,10 +2451,11 @@ static int delete_ref_loose(struct ref_lock *lock, int flag, struct strbuf *err)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int delete_refs(struct string_list *refnames, unsigned int flags)
|
static int files_delete_refs(struct ref_store *ref_store,
|
||||||
|
struct string_list *refnames, unsigned int flags)
|
||||||
{
|
{
|
||||||
struct files_ref_store *refs =
|
struct files_ref_store *refs =
|
||||||
get_files_ref_store(NULL, "delete_refs");
|
files_downcast(ref_store, 0, "delete_refs");
|
||||||
struct strbuf err = STRBUF_INIT;
|
struct strbuf err = STRBUF_INIT;
|
||||||
int i, result = 0;
|
int i, result = 0;
|
||||||
|
|
||||||
@ -4067,6 +4068,7 @@ struct ref_storage_be refs_be_files = {
|
|||||||
files_pack_refs,
|
files_pack_refs,
|
||||||
files_peel_ref,
|
files_peel_ref,
|
||||||
files_create_symref,
|
files_create_symref,
|
||||||
|
files_delete_refs,
|
||||||
|
|
||||||
files_ref_iterator_begin,
|
files_ref_iterator_begin,
|
||||||
files_read_raw_ref,
|
files_read_raw_ref,
|
||||||
|
@ -490,6 +490,8 @@ typedef int create_symref_fn(struct ref_store *ref_store,
|
|||||||
const char *ref_target,
|
const char *ref_target,
|
||||||
const char *refs_heads_master,
|
const char *refs_heads_master,
|
||||||
const char *logmsg);
|
const char *logmsg);
|
||||||
|
typedef int delete_refs_fn(struct ref_store *ref_store,
|
||||||
|
struct string_list *refnames, unsigned int flags);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Iterate over the references in the specified ref_store that are
|
* Iterate over the references in the specified ref_store that are
|
||||||
@ -587,6 +589,7 @@ struct ref_storage_be {
|
|||||||
pack_refs_fn *pack_refs;
|
pack_refs_fn *pack_refs;
|
||||||
peel_ref_fn *peel_ref;
|
peel_ref_fn *peel_ref;
|
||||||
create_symref_fn *create_symref;
|
create_symref_fn *create_symref;
|
||||||
|
delete_refs_fn *delete_refs;
|
||||||
|
|
||||||
ref_iterator_begin_fn *iterator_begin;
|
ref_iterator_begin_fn *iterator_begin;
|
||||||
read_raw_ref_fn *read_raw_ref;
|
read_raw_ref_fn *read_raw_ref;
|
||||||
|
Loading…
Reference in New Issue
Block a user