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

Re: [PATCH v8] ls-files: introduce "--format" option

From
ZheNing Hu <adlternative@gmail.com>
Date
Jul 25, 2022, 11:00 UTC
Message-ID
<CAOLTT8SKW1RCB1Md0DOxKikwq3mgsKWp4stR62YyMyGxjn56aA@mail.gmail.com>
In-Reply-To
<xmqq7d4280m8.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> 于2022年7月25日周一 09:03写道:
Show 49 quoted lines
>
> ZheNing Hu <adlternative@gmail.com> writes:
>
> >> That was not the point.  By extracting only "%(objectmode)" without
> >> having any other clues (like "%(path)") on the same line, the test
> >> is assuming that ls-files will always sort its output in the same
> >> order regardless of the output format, whether it is "--stage" or
> >> "--format=<spec>", and that was what the "is this testing the right
> >> thing?" question was about.
> >>
> >
> > Ah, so that we should sort the ls-files output first, and then compare them.
>
> Imagine that there are three paths in the index and "ls-files -s"
> gives
>
>     100644 1234... 0 path1
>     100644 2345... 0 path2
>     100755 3456... 0 path3
>
> but a bug causes "ls-files --format=<spec>" to show entries in a
> wrong order, e.g. first for path2 and then for path1 and then for
> path3.  If the test used enough fields (like the one that mimics the
> full output of "ls-files -s"), then the output may be
>
>     100644 2345... 0 path2
>     100644 1234... 0 path1
>     100755 3456... 0 path3
>
> and you would notice that it is different from "ls-files -s".
>
> But if the test only used %(objectmode), then the faulty output from
> "ls-files --format=%(objectmode)" would be
>
>     100644
>     100644
>     100755
>
> that matches the "ls-files -s | cut -d' ' -f1"
>
> If you sort, then such a breakage will become even harder to
> notice.  If the faulty output showed path3 first and then path2 and
> then path1, the raw output from "ls-files --format=%(objectmode)" may
> be 100755/100644/100644, but if you sort it, no matter what the
> broken order is, you will always get 100644/100644/100755.
>
> So, no, we shouldn't sort.  If ls-files were allowed to show output
> in any random order, then sorting the output before comparing is a
> good strategy, but that does not apply here.

I get what you mean. So test 'git ls-files --format imitate --stage' can help for checking it, because every line content is different (maybe different <path>, or the same <path> with different <stage>,<objectmode>...), we can find the --format "disorder bug" with ease.

ZheNing Hu
Previous: Junio C HamanoNext: ZheNing Hu via GitGitGadget
Message 58 of 61 in “ls-files: introduce "--format" and "--object-only" options”
  1. 0/2 ls-files: introduce "--format" and "--object-only" optionsZheNing Hu via GitGitGadget, Jun 15, 2022
  2. 1/2 ls-files: introduce "--format" optionZheNing Hu via GitGitGadget, Jun 15, 2022
  3. Ævar Arnfjörð BjarmasonJun 15, 2022
  4. ZheNing HuJun 18, 2022
  5. 2/2 ls-files: introduce "--object-only" optionZheNing Hu via GitGitGadget, Jun 15, 2022
  6. Ævar Arnfjörð BjarmasonJun 15, 2022
  7. ZheNing HuJun 18, 2022
  8. ls-files: introduce "--format" optionZheNing Hu via GitGitGadget, Jun 19, 2022
  9. Phillip WoodJun 19, 2022
  10. ZheNing HuJun 20, 2022
  11. ls-files: introduce "--format" optionZheNing Hu via GitGitGadget, Jun 21, 2022
  12. Phillip WoodJun 23, 2022
  13. Junio C HamanoJun 23, 2022
  14. Phillip WoodJun 24, 2022
  15. ZheNing HuJun 26, 2022
  16. Ævar Arnfjörð BjarmasonJun 24, 2022
  17. Junio C HamanoJun 24, 2022
  18. ZheNing HuJun 26, 2022
  19. Ævar Arnfjörð BjarmasonJun 24, 2022
  20. Junio C HamanoJun 24, 2022
  21. ZheNing HuJun 26, 2022
  22. Junio C HamanoJun 27, 2022
  23. ZheNing HuJun 27, 2022
  24. Junio C HamanoJun 27, 2022
  25. ZheNing HuJul 1, 2022
  26. ZheNing HuJun 26, 2022
  27. ls-files: introduce "--format" optionZheNing Hu via GitGitGadget, Jun 26, 2022
  28. Junio C HamanoJun 27, 2022
  29. ZheNing HuJun 27, 2022
  30. Ævar Arnfjörð BjarmasonJun 27, 2022
  31. ZheNing HuJul 1, 2022
  32. Phillip WoodJun 28, 2022
  33. ZheNing HuJul 1, 2022
  34. ls-files: introduce "--format" optionZheNing Hu via GitGitGadget, Jul 5, 2022
  35. Ævar Arnfjörð BjarmasonJul 5, 2022
  36. ZheNing HuJul 11, 2022
  37. Torsten BögershausenJul 5, 2022
  38. ZheNing HuJul 11, 2022
  39. ls-files: introduce "--format" optionZheNing Hu via GitGitGadget, Jul 11, 2022
  40. Junio C HamanoJul 11, 2022
  41. ZheNing HuJul 12, 2022
  42. Junio C HamanoJul 12, 2022
  43. ls-files: introduce "--format" optionZheNing Hu via GitGitGadget, Jul 13, 2022
  44. Ævar Arnfjörð BjarmasonJul 18, 2022
  45. ZheNing HuJul 19, 2022
  46. Junio C HamanoJul 19, 2022
  47. ZheNing HuJul 19, 2022
  48. ls-files: introduce "--format" optionZheNing Hu via GitGitGadget, Jul 20, 2022
  49. Junio C HamanoJul 20, 2022
  50. Ævar Arnfjörð BjarmasonJul 21, 2022
  51. Eric SunshineJul 21, 2022
  52. Junio C HamanoJul 21, 2022
  53. ZheNing HuJul 22, 2022
  54. Junio C HamanoJul 23, 2022
  55. Junio C HamanoJul 23, 2022
  56. ZheNing HuJul 24, 2022
  57. Junio C HamanoJul 25, 2022
  58. ZheNing HuJul 25, 2022
  59. ls-files: introduce "--format" optionZheNing Hu via GitGitGadget, Jul 23, 2022
  60. Jiang XinSep 8, 2022
  61. ZheNing HuSep 11, 2022

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.