Re: [PATCH 02/10] repository.c: replace hold_locked_index() with repo_hold_locked_index()
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Jan 7, 2019, 12:55 UTC
- Message-ID
- <CACsJy8DLFOyh3pvPPhkAVMFMT=wnfOBWuDN9dUr6sUNaNe=3TA@mail.gmail.com>
- In-Reply-To
- <CAN0heSoRSgZVZ=NE6eof4dusEhfdz-eSiht06rGKb=GELvm86Q@mail.gmail.com>
On Sat, Jan 5, 2019 at 9:34 PM Martin Ågren <martin.agren@gmail.com> wrote:
Show 21 quoted lines
> > On Sat, 5 Jan 2019 at 07:07, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote: > > > > hold_locked_index() assumes the index path at $GIT_DIR/index. This is > > not good for places that take an arbitrary index_state instead of > > the_index, which is basically everywhere except builtin/. > > > > Replace it with repo_hold_locked_index(). hold_locked_index() remains > > as a wrapper around repo_hold_locked_index() to reduce changes in builtin/ > > > diff --git a/builtin/clone.c b/builtin/clone.c > > index 7c7f98c72c..ddb3230d21 100644 > > --- a/builtin/clone.c > > +++ b/builtin/clone.c > > @@ -8,6 +8,7 @@ > > * Clone a repository into a different directory that does not yet exist. > > */ > > > > +#define USE_THE_INDEX_COMPATIBILITY_MACROS > > I think this should be in patch 10/10.
Eck. There has been a lot of fixups in this series. I guess I fixed up the wrong commit.
Show 15 quoted lines
> > -int hold_locked_index(struct lock_file *lk, int lock_flags)
> > -{
> > - return hold_lock_file_for_update(lk, get_index_file(), lock_flags);
> > -}
>
> > +int repo_hold_locked_index(struct repository *repo,
> > + struct lock_file *lf,
> > + int flags)
> > +{
> > + return hold_lock_file_for_update(lf, repo->index_file, flags);
> > +}
>
> `get_index_file()` BUGs if `the_repository->index_file` is NULL, but
> other than that, this looks like a faithful conversion. Do we want to
> keep that check here?Better than segfault :)
-- Duy