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

Re: [PATCH 01/15] contrib: add cocci script to replace index compat macros

From
Derrick Stolee <stolee@gmail.com>
Date
Jun 19, 2018, 11:35 UTC
Message-ID
<a7e0bcd5-5bef-097e-f032-d152d51515aa@gmail.com>
In-Reply-To
<20180616054157.32433-2-pclouds@gmail.com>
On 6/16/2018 1:41 AM, Nguyễn Thái Ngọc Duy wrote:
Show 8 quoted lines
> Index compat macros are going to be removed to expose the_index and
> then reorganized to use the right index instead of simply the_index
> because sometimes we want to use a different index.
>
> This cocci script can help with the first step. It can be used later
> on on even builtin/ when we start to reorganize code in there, but for
> now this is the script that performs all the conversion outside
> builtin/

I pulled your code and ran `make coccicheck` and got quite a large patch as a result.

Perhaps reorder the commits in your large patch with this one at the end? It's helpful to see what your mechanical changes are going to be, but let's save it for when `make coccicheck` is stable.

Show 197 quoted lines
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>   contrib/coccinelle/index-compat.cocci | 184 ++++++++++++++++++++++++++
>   1 file changed, 184 insertions(+)
>   create mode 100644 contrib/coccinelle/index-compat.cocci
>
> diff --git a/contrib/coccinelle/index-compat.cocci b/contrib/coccinelle/index-compat.cocci
> new file mode 100644
> index 0000000000..ca46711eb6
> --- /dev/null
> +++ b/contrib/coccinelle/index-compat.cocci
> @@ -0,0 +1,184 @@
> +@@
> +@@
> +-active_cache
> ++the_index.cache
> +
> +@@
> +@@
> +-active_nr
> ++the_index.cache_nr
> +
> +@@
> +@@
> +-active_alloc
> ++the_index.cache_alloc
> +
> +@@
> +@@
> +-active_cache_changed
> ++the_index.cache_changed
> +
> +@@
> +@@
> +-active_cache_tree
> ++the_index.cache_tree
> +
> +@@
> +@@
> +- read_cache()
> ++ read_index(&the_index)
> +
> +@@
> +expression path;
> +@@
> +- read_cache_from(path)
> ++ read_index_from(&the_index, path, get_git_dir())
> +
> +@@
> +expression pathspec;
> +@@
> +- read_cache_preload(pathspec)
> ++ read_index_preload(&the_index, pathspec)
> +
> +@@
> +@@
> +- is_cache_unborn()
> ++ is_index_unborn(&the_index)
> +
> +@@
> +@@
> +- read_cache_unmerged()
> ++ read_index_unmerged(&the_index)
> +
> +@@
> +@@
> +- discard_cache()
> ++ discard_index(&the_index)
> +
> +@@
> +@@
> +- unmerged_cache()
> ++ unmerged_index(&the_index)
> +
> +@@
> +expression name;
> +expression namelen;
> +@@
> +- cache_name_pos(name, namelen)
> ++ index_name_pos(&the_index, name, namelen)
> +
> +@@
> +expression ce;
> +expression option;
> +@@
> +- add_cache_entry(ce, option)
> ++ add_index_entry(&the_index, ce, option)
> +
> +@@
> +expression pos;
> +expression new_name;
> +@@
> +- rename_cache_entry_at(pos, new_name)
> ++ rename_index_entry_at(&the_index, pos, new_name)
> +
> +@@
> +expression pos;
> +@@
> +- remove_cache_entry_at(pos)
> ++ remove_index_entry_at(&the_index, pos)
> +
> +@@
> +expression path;
> +@@
> +- remove_file_from_cache(path)
> ++ remove_file_from_index(&the_index, path)
> +
> +@@
> +expression path;
> +expression st;
> +expression flags;
> +@@
> +- add_to_cache(path, st, flags)
> ++ add_to_index(&the_index, path, st, flags)
> +
> +@@
> +expression path;
> +expression flags;
> +@@
> +- add_file_to_cache(path, flags)
> ++ add_file_to_index(&the_index, path, flags)
> +
> +@@
> +expression ce;
> +expression flip;
> +@@
> +-chmod_cache_entry(ce, flip)
> ++chmod_index_entry(&the_index, ce, flip)
> +
> +@@
> +expression flags;
> +@@
> +-refresh_cache(flags)
> ++refresh_index(&the_index, flags, NULL, NULL, NULL)
> +
> +@@
> +expression ce;
> +expression st;
> +expression options;
> +@@
> +-ce_match_stat(ce, st, options)
> ++ie_match_stat(&the_index, ce, st, options)
> +
> +@@
> +expression ce;
> +expression st;
> +expression options;
> +@@
> +-ce_modified(ce, st, options)
> ++ie_modified(&the_index, ce, st, options)
> +
> +@@
> +expression name;
> +expression namelen;
> +@@
> +-cache_dir_exists(name, namelen)
> ++index_dir_exists(&the_index, name, namelen)
> +
> +@@
> +expression name;
> +expression namelen;
> +expression igncase;
> +@@
> +-cache_file_exists(name, namelen, igncase)
> ++index_file_exists(&the_index, name, namelen, igncase)
> +
> +@@
> +expression name;
> +expression namelen;
> +@@
> +-cache_name_is_other(name, namelen)
> ++index_name_is_other(&the_index, name, namelen)
> +
> +@@
> +@@
> +-resolve_undo_clear()
> ++resolve_undo_clear_index(&the_index)
> +
> +@@
> +expression at;
> +@@
> +-unmerge_cache_entry_at(at)
> ++unmerge_index_entry_at(&the_index, at)
> +
> +@@
> +expression pathspec;
> +@@
> +-unmerge_cache(pathspec)
> ++unmerge_index(&the_index, pathspec)
> +
> +@@
> +expression path;
> +expression sz;
> +@@
> +-read_blob_data_from_cache(path, sz)
> ++read_blob_data_from_index(&the_index, path, sz)
Previous: Nguyễn Thái Ngọc DuyNext: Derrick Stolee
Message 3 of 32 in “Kill the_index part 1, expose it”
  1. 00/15 Kill the_index part 1, expose itNguyễn Thái Ngọc Duy, Jun 16, 2018
  2. 01/15 contrib: add cocci script to replace index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  3. Derrick StoleeJun 19, 2018
  4. Derrick StoleeJun 19, 2018
  5. Duy NguyenJun 19, 2018
  6. Derrick StoleeJun 19, 2018
  7. SZEDER GáborJul 23, 2018
  8. 05/15 diff-lib.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  9. 11/15 revision.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  10. 04/15 check-racy.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  11. 14/15 wt-status.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  12. 10/15 rerere.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  13. 12/15 sequencer.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  14. 13/15 sha1-name.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  15. 03/15 blame.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  16. 08/15 merge-recursive.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  17. 09/15 merge.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  18. 15/15 cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switchNguyễn Thái Ngọc Duy, Jun 16, 2018
  19. Brandon WilliamsJun 18, 2018
  20. 02/15 apply.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  21. Junio C HamanoJun 25, 2018
  22. Duy NguyenJun 30, 2018
  23. Junio C HamanoJul 3, 2018
  24. Duy NguyenJul 9, 2018
  25. 07/15 entry.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  26. 06/15 diff.c: stop using index compat macrosNguyễn Thái Ngọc Duy, Jun 16, 2018
  27. Elijah NewrenJun 17, 2018
  28. Duy NguyenJun 17, 2018
  29. Brandon WilliamsJun 18, 2018
  30. Ben PeartJun 19, 2018
  31. Derrick StoleeJun 19, 2018
  32. Duy NguyenJun 19, 2018

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.