On 02/22/2017 03:04 PM, Nguyễn Thái Ngọc Duy wrote: > A small step towards making files-backend works as a non-main ref store > using the newly added store-aware API. > > For the record, `join` and `nm` on refs.o and files-backend.o tell me > that files-backend no longer uses functions that defaults to > get_main_ref_store(). Nice! > I'm not yet comfortable at the idea of removing > files_assert_main_repository() (or converting REF_STORE_MAIN to > REF_STORE_WRITE). More staring and testing is required before that can > happen. Well, except peel_ref(). I'm pretty sure that function is safe. > > Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> > --- > refs/files-backend.c | 85 ++++++++++++++++++++++++++++++---------------------- > 1 file changed, 49 insertions(+), 36 deletions(-) > > diff --git a/refs/files-backend.c b/refs/files-backend.c > index dafddefd3..09c280fd3 100644 > --- a/refs/files-backend.c > +++ b/refs/files-backend.c > [...] > @@ -3873,8 +3883,10 @@ static int files_transaction_commit(struct ref_store *ref_store, > * head_ref within the transaction, then split_head_update() > * arranges for the reflog of HEAD to be updated, too. > */ > - head_ref = resolve_refdup("HEAD", RESOLVE_REF_NO_RECURSE, > - head_oid.hash, &head_type); > + head_ref = (char *)refs_resolve_ref_unsafe(ref_store, "HEAD", > + RESOLVE_REF_NO_RECURSE, > + head_oid.hash, &head_type); > + head_ref = xstrdup_or_null(head_ref); If you combine the last two statements, you can avoid the ugly cast. > [...] Michael