Skip to content

Commit a27dcf8

Browse files
dturner-twgitster
authored andcommitted
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>
1 parent fc68146 commit a27dcf8

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

refs.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,3 +1532,10 @@ int initial_ref_transaction_commit(struct ref_transaction *transaction,
15321532

15331533
return refs->be->initial_transaction_commit(refs, transaction, err);
15341534
}
1535+
1536+
int delete_refs(struct string_list *refnames, unsigned int flags)
1537+
{
1538+
struct ref_store *refs = get_ref_store(NULL);
1539+
1540+
return refs->be->delete_refs(refs, refnames, flags);
1541+
}

refs/files-backend.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2451,10 +2451,11 @@ static int delete_ref_loose(struct ref_lock *lock, int flag, struct strbuf *err)
24512451
return 0;
24522452
}
24532453

2454-
int delete_refs(struct string_list *refnames, unsigned int flags)
2454+
static int files_delete_refs(struct ref_store *ref_store,
2455+
struct string_list *refnames, unsigned int flags)
24552456
{
24562457
struct files_ref_store *refs =
2457-
get_files_ref_store(NULL, "delete_refs");
2458+
files_downcast(ref_store, 0, "delete_refs");
24582459
struct strbuf err = STRBUF_INIT;
24592460
int i, result = 0;
24602461

@@ -4067,6 +4068,7 @@ struct ref_storage_be refs_be_files = {
40674068
files_pack_refs,
40684069
files_peel_ref,
40694070
files_create_symref,
4071+
files_delete_refs,
40704072

40714073
files_ref_iterator_begin,
40724074
files_read_raw_ref,

refs/refs-internal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,8 @@ typedef int create_symref_fn(struct ref_store *ref_store,
490490
const char *ref_target,
491491
const char *refs_heads_master,
492492
const char *logmsg);
493+
typedef int delete_refs_fn(struct ref_store *ref_store,
494+
struct string_list *refnames, unsigned int flags);
493495

494496
/*
495497
* Iterate over the references in the specified ref_store that are
@@ -587,6 +589,7 @@ struct ref_storage_be {
587589
pack_refs_fn *pack_refs;
588590
peel_ref_fn *peel_ref;
589591
create_symref_fn *create_symref;
592+
delete_refs_fn *delete_refs;
590593

591594
ref_iterator_begin_fn *iterator_begin;
592595
read_raw_ref_fn *read_raw_ref;

0 commit comments

Comments
 (0)