Skip to content

Commit 284689b

Browse files
mhaggergitster
authored andcommitted
refs: make create_symref() virtual
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 8231527 commit 284689b

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

refs.c

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

1431+
int create_symref(const char *ref_target, const char *refs_heads_master,
1432+
const char *logmsg)
1433+
{
1434+
struct ref_store *refs = get_ref_store(NULL);
1435+
1436+
return refs->be->create_symref(refs, ref_target, refs_heads_master,
1437+
logmsg);
1438+
}
1439+
14311440
int ref_transaction_commit(struct ref_transaction *transaction,
14321441
struct strbuf *err)
14331442
{

refs/files-backend.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3011,12 +3011,16 @@ static int create_symref_locked(struct ref_lock *lock, const char *refname,
30113011
return 0;
30123012
}
30133013

3014-
int create_symref(const char *refname, const char *target, const char *logmsg)
3014+
static int files_create_symref(struct ref_store *ref_store,
3015+
const char *refname, const char *target,
3016+
const char *logmsg)
30153017
{
30163018
struct strbuf err = STRBUF_INIT;
30173019
struct ref_lock *lock;
30183020
int ret;
30193021

3022+
files_downcast(ref_store, 0, "create_symref");
3023+
30203024
lock = lock_ref_sha1_basic(refname, NULL, NULL, NULL, REF_NODEREF, NULL,
30213025
&err);
30223026
if (!lock) {
@@ -4023,6 +4027,7 @@ struct ref_storage_be refs_be_files = {
40234027
files_transaction_commit,
40244028

40254029
files_pack_refs,
4030+
files_create_symref,
40264031

40274032
files_read_raw_ref,
40284033
files_verify_refname_available

refs/refs-internal.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,10 @@ 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 create_symref_fn(struct ref_store *ref_store,
505+
const char *ref_target,
506+
const char *refs_heads_master,
507+
const char *logmsg);
504508

505509
/*
506510
* Read a reference from the specified reference store, non-recursively.
@@ -557,6 +561,7 @@ struct ref_storage_be {
557561
ref_transaction_commit_fn *transaction_commit;
558562

559563
pack_refs_fn *pack_refs;
564+
create_symref_fn *create_symref;
560565

561566
read_raw_ref_fn *read_raw_ref;
562567
verify_refname_available_fn *verify_refname_available;

0 commit comments

Comments
 (0)