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

Re: [PATCH 12/12] update-index: remove ce_match_stat(), all macros

From
Elijah Newren <newren@gmail.com>
Date
Jan 1, 2021, 21:12 UTC
Message-ID
<CABPp-BEPDpagENsmx=8gJ9SqUFrD+mh87WbLnV1mpgtFz56qVg@mail.gmail.com>
In-Reply-To
<8fb307c3bee9a33ad408bba6c422e992fb1e2656.1609506428.git.gitgitgadget@gmail.com>

On Fri, Jan 1, 2021 at 5:12 AM Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com> wrote:

Show 5 quoted lines
>
> From: Derrick Stolee <dstolee@microsoft.com>
>
> The final index compatibility macro to remove from the update-index
> builtin is ce_match_state(). Further, this is the last use of that macro
I think you mean ce_match_stat(); no trailing 'e'.
Show 22 quoted lines
> anywhere, so it should be removed.
>
> There are some remaining references in the racy-git.txt technical
> document that are updated to ie_match_stat().
>
> Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
> ---
>  Documentation/technical/racy-git.txt | 6 +++---
>  builtin/update-index.c               | 3 +--
>  cache.h                              | 1 -
>  3 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/Documentation/technical/racy-git.txt b/Documentation/technical/racy-git.txt
> index ceda4bbfda4..65188e04559 100644
> --- a/Documentation/technical/racy-git.txt
> +++ b/Documentation/technical/racy-git.txt
> @@ -26,7 +26,7 @@ information obtained from the filesystem via `lstat(2)` system
>  call when they were last updated.  When checking if they differ,
>  Git first runs `lstat(2)` on the files and compares the result
>  with this information (this is what was originally done by the
> -`ce_match_stat()` function, but the current code does it in
> +`ie_match_stat()` function, but the current code does it in
Even updating the documentation... :-)

Arguably, this change should have been done years ago when ce_match_stat was turned into a macro, but certainly becomes more important with your patch that removes the macro.

Show 54 quoted lines
>  `ce_match_stat_basic()` function).  If some of these "cached
>  stat information" fields do not match, Git can tell that the
>  files are modified without even looking at their contents.
> @@ -102,7 +102,7 @@ timestamp as the index file itself.
>
>  The callers that want to check if an index entry matches the
>  corresponding file in the working tree continue to call
> -`ce_match_stat()`, but with this change, `ce_match_stat()` uses
> +`ie_match_stat()`, but with this change, `ie_match_stat()` uses
>  `ce_modified_check_fs()` to see if racily clean ones are
>  actually clean after comparing the cached stat information using
>  `ce_match_stat_basic()`.
> @@ -128,7 +128,7 @@ Runtime penalty
>  ---------------
>
>  The runtime penalty of falling back to `ce_modified_check_fs()`
> -from `ce_match_stat()` can be very expensive when there are many
> +from `ie_match_stat()` can be very expensive when there are many
>  racily clean entries.  An obvious way to artificially create
>  this situation is to give the same timestamp to all the files in
>  the working tree in a large project, run `git update-index` on
> diff --git a/builtin/update-index.c b/builtin/update-index.c
> index 4da0c169dc7..256df43ecbd 100644
> --- a/builtin/update-index.c
> +++ b/builtin/update-index.c
> @@ -3,7 +3,6 @@
>   *
>   * Copyright (C) Linus Torvalds, 2005
>   */
> -#define USE_THE_INDEX_COMPATIBILITY_MACROS
>  #include "cache.h"
>  #include "config.h"
>  #include "lockfile.h"
> @@ -277,7 +276,7 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len
>         struct cache_entry *ce;
>
>         /* Was the old index entry already up-to-date? */
> -       if (old && !ce_stage(old) && !ce_match_stat(old, st, 0))
> +       if (old && !ce_stage(old) && !ie_match_stat(istate, old, st, 0))
>                 return 0;
>
>         ce = make_empty_cache_entry(istate, len);
> diff --git a/cache.h b/cache.h
> index dfcbc4923e2..2925bf050b8 100644
> --- a/cache.h
> +++ b/cache.h
> @@ -416,7 +416,6 @@ extern struct index_state the_index;
>  #define chmod_cache_entry(ce, flip) chmod_index_entry(&the_index, (ce), (flip))
>  #define refresh_cache(flags) refresh_index(&the_index, (flags), NULL, NULL, NULL)
>  #define refresh_and_write_cache(refresh_flags, write_flags, gentle) repo_refresh_and_write_index(the_repository, (refresh_flags), (write_flags), (gentle), NULL, NULL, NULL)
> -#define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options))
>  #define ce_modified(ce, st, options) ie_modified(&the_index, (ce), (st), (options))
>  #define cache_dir_exists(name, namelen) index_dir_exists(&the_index, (name), (namelen))
>  #define cache_name_is_other(name, namelen) index_name_is_other(&the_index, (name), (namelen))
The rest looks good.
Previous: Derrick Stolee via GitGitGadgetNext: Elijah Newren
Message 18 of 65 in “Remove more index compatibility macros”
  1. 00/12 Remove more index compatibility macrosDerrick Stolee via GitGitGadget, Jan 1, 2021
  2. 01/12 merge-index: drop index compatibility macrosDerrick Stolee via GitGitGadget, Jan 1, 2021
  3. Alban GruinJan 3, 2021
  4. Derrick StoleeJan 4, 2021
  5. 02/12 mv: remove index compatibility macrosDerrick Stolee via GitGitGadget, Jan 1, 2021
  6. 03/12 rm: remove compatilibity macrosDerrick Stolee via GitGitGadget, Jan 1, 2021
  7. 04/12 update-index: drop the_index, the_repositoryDerrick Stolee via GitGitGadget, Jan 1, 2021
  8. Elijah NewrenJan 1, 2021
  9. Derrick StoleeJan 4, 2021
  10. 07/12 update-index: use istate->cache_changedDerrick Stolee via GitGitGadget, Jan 1, 2021
  11. 06/12 update-index: use index->cache_nr over active_nrDerrick Stolee via GitGitGadget, Jan 1, 2021
  12. 10/12 update-index: use add_index_entry()Derrick Stolee via GitGitGadget, Jan 1, 2021
  13. 11/12 update-index: replace several compatibility macrosDerrick Stolee via GitGitGadget, Jan 1, 2021
  14. 09/12 update-index: use remove_file_from_index()Derrick Stolee via GitGitGadget, Jan 1, 2021
  15. 08/12 update-index: use index_name_pos() over cache_name_pos()Derrick Stolee via GitGitGadget, Jan 1, 2021
  16. 05/12 update-index: use istate->cache over active_cacheDerrick Stolee via GitGitGadget, Jan 1, 2021
  17. 12/12 update-index: remove ce_match_stat(), all macrosDerrick Stolee via GitGitGadget, Jan 1, 2021
  18. Elijah NewrenJan 1, 2021
  19. Elijah NewrenJan 1, 2021
  20. Eric SunshineJan 2, 2021
  21. Derrick StoleeJan 4, 2021
  22. Eric SunshineJan 4, 2021
  23. Derrick StoleeJan 5, 2021
  24. 00/14 Remove more index compatibility macrosDerrick Stolee via GitGitGadget, Jan 5, 2021
  25. 03/14 update-index: drop the_index, the_repositoryDerrick Stolee via GitGitGadget, Jan 5, 2021
  26. 02/14 rm: remove compatilibity macrosDerrick Stolee via GitGitGadget, Jan 5, 2021
  27. 01/14 mv: remove index compatibility macrosDerrick Stolee via GitGitGadget, Jan 5, 2021
  28. 04/14 update-index: use istate->cache over active_cacheDerrick Stolee via GitGitGadget, Jan 5, 2021
  29. 05/14 update-index: use index->cache_nr over active_nrDerrick Stolee via GitGitGadget, Jan 5, 2021
  30. 07/14 update-index: use index_name_pos() over cache_name_pos()Derrick Stolee via GitGitGadget, Jan 5, 2021
  31. 09/14 update-index: use add_index_entry()Derrick Stolee via GitGitGadget, Jan 5, 2021
  32. 12/14 update-index: reduce static globals, part 1Derrick Stolee via GitGitGadget, Jan 5, 2021
  33. 14/14 update-index: remove static globals from callbacksDerrick Stolee via GitGitGadget, Jan 5, 2021
  34. Eric SunshineJan 7, 2021
  35. Derrick StoleeJan 7, 2021
  36. Eric SunshineJan 7, 2021
  37. Junio C HamanoJan 7, 2021
  38. Derrick StoleeJan 8, 2021
  39. 10/14 update-index: replace several compatibility macrosDerrick Stolee via GitGitGadget, Jan 5, 2021
  40. 08/14 update-index: use remove_file_from_index()Derrick Stolee via GitGitGadget, Jan 5, 2021
  41. 06/14 update-index: use istate->cache_changedDerrick Stolee via GitGitGadget, Jan 5, 2021
  42. 13/14 update-index: reduce static globals, part 2Derrick Stolee via GitGitGadget, Jan 5, 2021
  43. 11/14 update-index: remove ce_match_stat(), all macrosDerrick Stolee via GitGitGadget, Jan 5, 2021
  44. 00/14 Remove more index compatibility macrosDerrick Stolee via GitGitGadget, Jan 8, 2021
  45. 01/14 mv: remove index compatibility macrosDerrick Stolee via GitGitGadget, Jan 8, 2021
  46. 02/14 rm: remove compatilibity macrosDerrick Stolee via GitGitGadget, Jan 8, 2021
  47. 04/14 update-index: use istate->cache over active_cacheDerrick Stolee via GitGitGadget, Jan 8, 2021
  48. 03/14 update-index: drop the_index, the_repositoryDerrick Stolee via GitGitGadget, Jan 8, 2021
  49. 12/14 update-index: reduce static globals, part 1Derrick Stolee via GitGitGadget, Jan 8, 2021
  50. 05/14 update-index: use istate->cache_nr over active_nrDerrick Stolee via GitGitGadget, Jan 8, 2021
  51. 07/14 update-index: use index_name_pos() over cache_name_pos()Derrick Stolee via GitGitGadget, Jan 8, 2021
  52. 09/14 update-index: use add_index_entry()Derrick Stolee via GitGitGadget, Jan 8, 2021
  53. 11/14 update-index: remove ce_match_stat(), all macrosDerrick Stolee via GitGitGadget, Jan 8, 2021
  54. 06/14 update-index: use istate->cache_changedDerrick Stolee via GitGitGadget, Jan 8, 2021
  55. 10/14 update-index: replace several compatibility macrosDerrick Stolee via GitGitGadget, Jan 8, 2021
  56. 08/14 update-index: use remove_file_from_index()Derrick Stolee via GitGitGadget, Jan 8, 2021
  57. 13/14 update-index: reduce static globals, part 2Derrick Stolee via GitGitGadget, Jan 8, 2021
  58. 14/14 update-index: remove static globals from callbacksDerrick Stolee via GitGitGadget, Jan 8, 2021
  59. Junio C HamanoJan 10, 2021
  60. Eric SunshineJan 10, 2021
  61. Derrick StoleeJan 10, 2021
  62. Derrick StoleeJan 25, 2021
  63. Junio C HamanoJan 6, 2021
  64. Derrick StoleeJan 6, 2021
  65. Junio C HamanoJan 6, 2021

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.