From: Michael Haggerty Date: Fri, 03 Mar 2017 16:03:13 GMT Subject: Re: [PATCH v5 20/24] files-backend: avoid ref api targetting main ref store Message-ID: <07b603ad-386d-56a8-8f0b-9721006313c7@alum.mit.edu> In-Reply-To: <20170222140450.30886-21-pclouds@gmail.com> 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 > --- > 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