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

Re: [PATCH 07/24] ls-files: correct index argument to get_convert_attr_ascii()

From
Stefan Beller <sbeller@google.com>
Date
Aug 15, 2018, 18:56 UTC
Message-ID
<CAGZ79kZTqcCzRLVTWVzjttU7dd98H2vm3WA9AceXypE-XwM4LA@mail.gmail.com>
In-Reply-To
<20180813161441.16824-8-pclouds@gmail.com>
On Mon, Aug 13, 2018 at 9:15 AM Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
Show 19 quoted lines
>
> write_eolinfo() does take an istate as function argument and it should
> be used instead of the_index.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  builtin/ls-files.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/builtin/ls-files.c b/builtin/ls-files.c
> index 7233b92794..7f9919a362 100644
> --- a/builtin/ls-files.c
> +++ b/builtin/ls-files.c
> @@ -63,7 +63,7 @@ static void write_eolinfo(const struct index_state *istate,
>                 struct stat st;
>                 const char *i_txt = "";
>                 const char *w_txt = "";
> -               const char *a_txt = get_convert_attr_ascii(&the_index, path);
> +               const char *a_txt = get_convert_attr_ascii(istate, path);
Going by the commit message this patch should end here?
> -static void show_dir_entry(const char *tag, struct dir_entry *ent)
> +static void show_dir_entry(const struct index_state *istate,
> +                          const char *tag, struct dir_entry *ent)
[...]
> -       if (!dir_path_match(&the_index, ent, &pathspec, len, ps_matched))
> +       if (!dir_path_match(istate, ent, &pathspec, len, ps_matched))
[...]
> -       write_eolinfo(NULL, NULL, ent->name);
> +       write_eolinfo(istate, NULL, ent->name);

but here we need to pass through the istate, which is why we adjust the dir_path_match while we're here

> -               show_dir_entry(tag_other, ent);
> +               show_dir_entry(istate, tag_other, ent);
[...]
> -                       show_dir_entry(tag_killed, dir->entries[i]);
> +                       show_dir_entry(istate, tag_killed, dir->entries[i]);
and having to adjust more callers here
> @@ -228,7 +229,7 @@ static void show_ce(struct repository *repo, struct dir_struct *dir,
> -       } else if (match_pathspec(&the_index, &pathspec, fullname, strlen(fullname),
> +       } else if (match_pathspec(repo->index, &pathspec, fullname, strlen(fullname),
> @@ -264,7 +265,7 @@ static void show_ru_info(const struct index_state *istate)
> -               if (!match_pathspec(&the_index, &pathspec, path, len,
> +               if (!match_pathspec(istate, &pathspec, path, len,

These seem more or less unrelated to the commit message or the code changes above. Maybe mention these as a "while at it" or separate them out in their own commit?

thanks, Stefan

Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 14 of 38 in “Kill the_index part3”
  1. 00/24 Kill the_index part3Nguyễn Thái Ngọc Duy, Aug 13, 2018
  2. 01/24 diff.c: move read_index() code back to the callerNguyễn Thái Ngọc Duy, Aug 13, 2018
  3. 02/24 cache-tree: wrap the_index based wrappers with #ifdefNguyễn Thái Ngọc Duy, Aug 13, 2018
  4. Junio C HamanoAug 13, 2018
  5. 03/24 attr: remove an implicit dependency on the_indexNguyễn Thái Ngọc Duy, Aug 13, 2018
  6. Brandon WilliamsAug 13, 2018
  7. 04/24 convert.c: remove an implicit dependency on the_indexNguyễn Thái Ngọc Duy, Aug 13, 2018
  8. Junio C HamanoAug 13, 2018
  9. 06/24 preload-index.c: use the right index instead of the_indexNguyễn Thái Ngọc Duy, Aug 13, 2018
  10. 05/24 dir.c: remove an implicit dependency on the_index in pathspec codeNguyễn Thái Ngọc Duy, Aug 13, 2018
  11. Brandon WilliamsAug 13, 2018
  12. Duy NguyenAug 13, 2018
  13. 07/24 ls-files: correct index argument to get_convert_attr_ascii()Nguyễn Thái Ngọc Duy, Aug 13, 2018
  14. Stefan BellerAug 15, 2018
  15. 08/24 unpack-trees: remove 'extern' on function declarationNguyễn Thái Ngọc Duy, Aug 13, 2018
  16. Stefan BellerAug 15, 2018
  17. Duy NguyenAug 15, 2018
  18. Stefan BellerAug 15, 2018
  19. 09/24 unpack-trees: add a note about path invalidationNguyễn Thái Ngọc Duy, Aug 13, 2018
  20. 10/24 unpack-trees: don't shadow global var the_indexNguyễn Thái Ngọc Duy, Aug 13, 2018
  21. 11/24 unpack-trees: convert clear_ce_flags* to avoid the_indexNguyễn Thái Ngọc Duy, Aug 13, 2018
  22. 13/24 pathspec.c: use the right index instead of the_indexNguyễn Thái Ngọc Duy, Aug 13, 2018
  23. 12/24 unpack-trees: avoid the_index in verify_absent()Nguyễn Thái Ngọc Duy, Aug 13, 2018
  24. 14/24 submodule.c: use the right index instead of the_indexNguyễn Thái Ngọc Duy, Aug 13, 2018
  25. 16/24 attr: remove index from git_attr_set_direction()Nguyễn Thái Ngọc Duy, Aug 13, 2018
  26. Brandon WilliamsAug 13, 2018
  27. 15/24 entry.c: use the right index instead of the_indexNguyễn Thái Ngọc Duy, Aug 13, 2018
  28. 17/24 grep: use the right index instead of the_indexNguyễn Thái Ngọc Duy, Aug 13, 2018
  29. 19/24 archive-*.c: use the right repositoryNguyễn Thái Ngọc Duy, Aug 13, 2018
  30. 20/24 resolve-undo.c: use the right index instead of the_indexNguyễn Thái Ngọc Duy, Aug 13, 2018
  31. 21/24 apply.c: pass struct apply_state to more functionsNguyễn Thái Ngọc Duy, Aug 13, 2018
  32. 22/24 apply.c: make init_apply_state() take a struct repositoryNguyễn Thái Ngọc Duy, Aug 13, 2018
  33. 18/24 archive.c: avoid access to the_indexNguyễn Thái Ngọc Duy, Aug 13, 2018
  34. 23/24 apply.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy, Aug 13, 2018
  35. 24/24 blame.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy, Aug 13, 2018
  36. Brandon WilliamsAug 13, 2018
  37. Junio C HamanoAug 13, 2018
  38. Stefan BellerAug 15, 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.