Skip to content

Commit bd427cf

Browse files
mhaggergitster
authored andcommitted
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>
1 parent 284689b commit bd427cf

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

refs.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,13 @@ int pack_refs(unsigned int flags)
14281428
return refs->be->pack_refs(refs, flags);
14291429
}
14301430

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+
14311438
int create_symref(const char *ref_target, const char *refs_heads_master,
14321439
const char *logmsg)
14331440
{

refs/files-backend.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,9 +1759,10 @@ static enum peel_status peel_entry(struct ref_entry *entry, int repeel)
17591759
return status;
17601760
}
17611761

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)
17631764
{
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");
17651766
int flag;
17661767
unsigned char base[20];
17671768

@@ -4027,6 +4028,7 @@ struct ref_storage_be refs_be_files = {
40274028
files_transaction_commit,
40284029

40294030
files_pack_refs,
4031+
files_peel_ref,
40304032
files_create_symref,
40314033

40324034
files_read_raw_ref,

refs/refs-internal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,8 @@ typedef int ref_transaction_commit_fn(struct ref_store *refs,
501501
struct strbuf *err);
502502

503503
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);
504506
typedef int create_symref_fn(struct ref_store *ref_store,
505507
const char *ref_target,
506508
const char *refs_heads_master,
@@ -561,6 +563,7 @@ struct ref_storage_be {
561563
ref_transaction_commit_fn *transaction_commit;
562564

563565
pack_refs_fn *pack_refs;
566+
peel_ref_fn *peel_ref;
564567
create_symref_fn *create_symref;
565568

566569
read_raw_ref_fn *read_raw_ref;

0 commit comments

Comments
 (0)