refs: make peel_ref() virtual
For now it only supports the main reference store. 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
bd427cf27f561174fa8fa14e2c8c321d2df82c47
3 files changed
+14
-2
refs.c
+7
@@ -1428,6 +1428,13 @@ int pack_refs(unsigned int flags)
1428
return refs->be->pack_refs(refs, flags);
1429
}
1430
1431
+int peel_ref(const char *refname, unsigned char *sha1)
1432
+{
1433
+ struct ref_store *refs = get_ref_store(NULL);
1434
+
1435
+ return refs->be->peel_ref(refs, refname, sha1);
1436
+}
1437
+
1438
int create_symref(const char *ref_target, const char *refs_heads_master,
1439
const char *logmsg)
1440
{
refs/files-backend.c
+4
-2
@@ -1759,9 +1759,10 @@ static enum peel_status peel_entry(struct ref_entry *entry, int repeel)
1759
return status;
1760
}
1761
1762
-int peel_ref(const char *refname, unsigned char *sha1)
1762
+static int files_peel_ref(struct ref_store *ref_store,
1763
+ const char *refname, unsigned char *sha1)
1764
{
1764
- struct files_ref_store *refs = get_files_ref_store(NULL, "peel_ref");
1765
+ struct files_ref_store *refs = files_downcast(ref_store, 0, "peel_ref");
1766
int flag;
1767
unsigned char base[20];
1768
@@ -4027,6 +4028,7 @@ struct ref_storage_be refs_be_files = {
4028
files_transaction_commit,
4029
4030
files_pack_refs,
4031
+ files_peel_ref,
4032
files_create_symref,
4033
4034
files_read_raw_ref,
refs/refs-internal.h
+3
@@ -501,6 +501,8 @@ typedef int ref_transaction_commit_fn(struct ref_store *refs,
501
struct strbuf *err);
502
503
typedef int pack_refs_fn(struct ref_store *ref_store, unsigned int flags);
504
+typedef int peel_ref_fn(struct ref_store *ref_store,
505
+ const char *refname, unsigned char *sha1);
506
typedef int create_symref_fn(struct ref_store *ref_store,
507
const char *ref_target,
508
const char *refs_heads_master,
@@ -561,6 +563,7 @@ struct ref_storage_be {
563
ref_transaction_commit_fn *transaction_commit;
564
565
pack_refs_fn *pack_refs;
566
+ peel_ref_fn *peel_ref;
567
create_symref_fn *create_symref;
568
569
read_raw_ref_fn *read_raw_ref;