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
MÅMartin Ågren <martin.agren@gmail.com>
Date
Jan 5, 2019, 14:33 UTC
Message-ID
<CAN0heSoRSgZVZ=NE6eof4dusEhfdz-eSiht06rGKb=GELvm86Q@mail.gmail.com>
In-Reply-To
<20190105055153.3256-3-pclouds@gmail.com>
On Sat, 5 Jan 2019 at 07:07, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
Show 7 quoted lines
>
> 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/
Show 9 quoted lines
> 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.
Show 17 quoted lines
> diff --git a/cache.h b/cache.h
> index ca36b44ee0..634c9ce325 100644
> --- a/cache.h
> +++ b/cache.h
> @@ -433,6 +433,7 @@ void validate_cache_entries(const struct index_state *istate);
>  #define unmerge_cache_entry_at(at) unmerge_index_entry_at(&the_index, at)
>  #define unmerge_cache(pathspec) unmerge_index(&the_index, pathspec)
>  #define read_blob_data_from_cache(path, sz) read_blob_data_from_index(&the_index, (path), (sz))
> +#define hold_locked_index(lock_file, flags) repo_hold_locked_index(the_repository, (lock_file), (flags))
>  #endif
>
>  #define TYPE_BITS 3
> @@ -833,7 +834,6 @@ extern struct cache_entry *refresh_cache_entry(struct index_state *, struct cach
>   */
>  extern void update_index_if_able(struct index_state *, struct lock_file *);
>
> -extern int hold_locked_index(struct lock_file *, int);

The reason this moves is it gets protected with "#ifndef NO_THE_INDEX_COMPATIBILITY_MACROS". Ok.

> -int hold_locked_index(struct lock_file *lk, int lock_flags)
> -{
> -       return hold_lock_file_for_update(lk, get_index_file(), lock_flags);
> -}
Show 6 quoted lines
> +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?

Martin
Previous: Nguyễn Thái Ngọc DuyNext: Duy Nguyen
Message 4 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.