git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Martin ÅgrenNext: Nguyễn Thái Ngọc Duy
Message 5 of 25 in “Remove the_index, the final part”
  1. 00/10 Remove the_index, the final partNguyễn Thái Ngọc Duy, Jan 5, 2019
  2. 01/10 notes-utils.c: remove the_repository referencesNguyễn Thái Ngọc Duy, Jan 5, 2019
  3. 02/10 repository.c: replace hold_locked_index() with repo_hold_locked_index()Nguyễn Thái Ngọc Duy, Jan 5, 2019
  4. Martin ÅgrenJan 5, 2019
  5. Duy NguyenJan 7, 2019
  6. 03/10 checkout: avoid the_index when possibleNguyễn Thái Ngọc Duy, Jan 5, 2019
  7. 04/10 read-cache.c: kill read_index()Nguyễn Thái Ngọc Duy, Jan 5, 2019
  8. 05/10 read-cache.c: replace update_index_if_able with repo_&Nguyễn Thái Ngọc Duy, Jan 5, 2019
  9. 06/10 sha1-name.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy, Jan 5, 2019
  10. 07/10 merge-recursive.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy, Jan 5, 2019
  11. 08/10 merge-recursive.c: remove implicit dependency on the_repositoryNguyễn Thái Ngọc Duy, Jan 5, 2019
  12. 09/10 read-cache.c: remove the_* from index_has_changes()Nguyễn Thái Ngọc Duy, Jan 5, 2019
  13. 10/10 cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switchNguyễn Thái Ngọc Duy, Jan 5, 2019
  14. 00/11 Remove the_index, the final partNguyễn Thái Ngọc Duy, Jan 12, 2019
  15. 01/11 grep: use grep_opt->repo instead of explict repo argumentNguyễn Thái Ngọc Duy, Jan 12, 2019
  16. 02/11 notes-utils.c: remove the_repository referencesNguyễn Thái Ngọc Duy, Jan 12, 2019
  17. 03/11 repository.c: replace hold_locked_index() with repo_hold_locked_index()Nguyễn Thái Ngọc Duy, Jan 12, 2019
  18. 04/11 checkout: avoid the_index when possibleNguyễn Thái Ngọc Duy, Jan 12, 2019
  19. 05/11 read-cache.c: kill read_index()Nguyễn Thái Ngọc Duy, Jan 12, 2019
  20. 06/11 read-cache.c: replace update_index_if_able with repo_&Nguyễn Thái Ngọc Duy, Jan 12, 2019
  21. 07/11 sha1-name.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy, Jan 12, 2019
  22. 08/11 merge-recursive.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy, Jan 12, 2019
  23. 09/11 merge-recursive.c: remove implicit dependency on the_repositoryNguyễn Thái Ngọc Duy, Jan 12, 2019
  24. 10/11 read-cache.c: remove the_* from index_has_changes()Nguyễn Thái Ngọc Duy, Jan 12, 2019
  25. 11/11 cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switchNguyễn Thái Ngọc Duy, Jan 12, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.