refs: make pack_refs() virtual
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
Sep 4, 2016 at 18:08 UTC
8231527e1510127a5611a2e2f9660e6aef1c981e
3 files changed
+15
-2
refs.c
+7
@@ -1421,6 +1421,13 @@ void assert_main_repository(struct ref_store *refs, const char *caller)
1421
}
1422
1423
/* backend functions */
1424
+int pack_refs(unsigned int flags)
1425
+{
1426
+ struct ref_store *refs = get_ref_store(NULL);
1427
+
1428
+ return refs->be->pack_refs(refs, flags);
1429
+}
1430
+
1431
int ref_transaction_commit(struct ref_transaction *transaction,
1432
struct strbuf *err)
1433
{
refs/files-backend.c
+4
-2
@@ -2354,10 +2354,10 @@ static void prune_refs(struct ref_to_prune *r)
2354
}
2355
}
2356
2357
-int pack_refs(unsigned int flags)
2357
+static int files_pack_refs(struct ref_store *ref_store, unsigned int flags)
2358
{
2359
struct files_ref_store *refs =
2360
- get_files_ref_store(NULL, "pack_refs");
2360
+ files_downcast(ref_store, 0, "pack_refs");
2361
struct pack_refs_cb_data cbdata;
2362
2363
memset(&cbdata, 0, sizeof(cbdata));
@@ -4022,6 +4022,8 @@ struct ref_storage_be refs_be_files = {
4022
files_ref_store_create,
4023
files_transaction_commit,
4024
4025
+ files_pack_refs,
4026
+
4027
files_read_raw_ref,
4028
files_verify_refname_available
4029
};
refs/refs-internal.h
+4
@@ -500,6 +500,8 @@ typedef int ref_transaction_commit_fn(struct ref_store *refs,
500
struct ref_transaction *transaction,
501
struct strbuf *err);
502
503
+typedef int pack_refs_fn(struct ref_store *ref_store, unsigned int flags);
504
+
505
/*
506
* Read a reference from the specified reference store, non-recursively.
507
* Set type to describe the reference, and:
@@ -554,6 +556,8 @@ struct ref_storage_be {
556
ref_store_init_fn *init;
557
ref_transaction_commit_fn *transaction_commit;
558
559
+ pack_refs_fn *pack_refs;
560
+
561
read_raw_ref_fn *read_raw_ref;
562
verify_refname_available_fn *verify_refname_available;
563
};