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

Re: [PATCH v2 2/6] grep.c: take column number as argument to show_line()

From
Taylor Blau <me@ttaylorr.com>
Date
Apr 23, 2018, 01:17 UTC
Message-ID
<20180423011726.GD78148@syl.local>
In-Reply-To
<CAPig+cQ2+wTTXE0mhnGnp2pZug=Po0SCVwCO_2agxUDaOsFRLw@mail.gmail.com>
On Sun, Apr 22, 2018 at 08:16:12PM -0400, Eric Sunshine wrote:
Show 49 quoted lines
> On Sun, Apr 22, 2018 at 4:47 PM, Taylor Blau <me@ttaylorr.com> wrote:
> > show_line() currently receives the line number within the
> > 'grep_opt->buf' in order to determine which line number to display. In
> > order to display information about the matching column number--if
> > requested--we must additionally take in that information.
> >
> > To do so, we extend the signature of show_line() to take in an
> > additional unsigned "cno". "cno" is either:
> >
> >   * A 1-indexed column number of the first match on the given line, or
> >   * 0, if the column number is irrelevant (when displaying a function
> >     name, context lines, etc).
>
> This information about how 'cno' is interpreted seems important enough
> to have as an in-code comment somewhere. Unfortunately, this patch
> never actually uses 'cno', so it's hard to add such a comment to
> non-existent code. In fact, the granularity of this patch feels wrong;
> it seems to exist for some purpose but, at the same time, is a
> do-nothing patch.
>
> This issue illustrates a larger problem with how this patch series is
> structured overall. In his review, Ævar suggested collapsing several
> patches into one, but the problems go deeper than that when you have
> patches which implement some bit of functionality but don't document
> that functionality until some later step which exposes some other bit
> of functionality, and so forth. As a reviewer, I expect a patch series
> to hold my hand and lead me on a straightforward journey from building
> blocks to final product, but this series tends to jump around without
> apparent logic.
>
> One way to achieve a more coherent patch series would be to build the
> machinery first and then expose it to the user in various ways. Also,
> each patch which implements some user-facing functionality should also
> document that functionality. For instance, a more understandable
> series might be structured something like this:
>
>   1. grep: match_line: expose matched column
>   2. grep: extend grep_opt to allow showing matched column
>   3. grep: display column number of first match
>   4. builtin/grep: add --column-number option
>   5. grep: add configuration variables to show matched column
>   6. contrib/git-jump: jump to match column in addition to line
>
> There may be fewer or more patches than shown here (I believe Ævar
> suggested a cleanup patch), but this should give the general idea.
> Patches 4 and 5 might also be swapped if that seems more logical.
>
> (Sorry if any of the above sounds harsh; it's not meant to be, but is
> intended to be constructive.)

I appreciate the suggestion, and did not take it as harsh. I think that the existing structure is OK, but I think that I am biased since I'm the author of the series. I have given your proposed structure a shot and I think that it should improve the readability of this series for others on the list as well.

To avoid sending more email than is necessary, I have pushed a draft of this series to my copy of Git, and would greatly appreciate your feedback on whether the structure of these patches is sensible. If they all seem OK to you, I'll happily push v3.

For your consideration: https://github.com/ttaylorr/git/compare/tb/grep-colno
> > We additionally modify all calls to show_line() in order to pass the new
> > required argument.
>
> Nit: No need to state the obvious; this final sentence could easily be dropped.
Fair; I have removed this from the patch.

Thanks, Taylor

Previous: Eric SunshineNext: Eric Sunshine
Message 8 of 108 in “grep.c: take regmatch_t as argument in match_line()”
  1. 1/6 grep.c: take regmatch_t as argument in match_line()Taylor Blau, Apr 21, 2018
  2. 0/6 Teach '--column-number' to 'git-grep(1)'Taylor Blau, Apr 22, 2018
  3. 1/6 grep.c: take regmatch_t as argument in match_line()Taylor Blau, Apr 22, 2018
  4. Eric SunshineApr 22, 2018
  5. Taylor BlauApr 22, 2018
  6. 2/6 grep.c: take column number as argument to show_line()Taylor Blau, Apr 22, 2018
  7. Eric SunshineApr 23, 2018
  8. Taylor BlauApr 23, 2018
  9. Eric SunshineApr 23, 2018
  10. Ævar Arnfjörð BjarmasonApr 23, 2018
  11. Eric SunshineApr 23, 2018
  12. Taylor BlauApr 24, 2018
  13. Ævar Arnfjörð BjarmasonApr 23, 2018
  14. Taylor BlauApr 24, 2018
  15. Junio C HamanoApr 24, 2018
  16. Taylor BlauApr 24, 2018
  17. 3/6 grep.[ch]: teach columnnum, color_columnno to grep_optTaylor Blau, Apr 22, 2018
  18. Ævar Arnfjörð BjarmasonApr 22, 2018
  19. Taylor BlauApr 22, 2018
  20. Eric SunshineApr 23, 2018
  21. Taylor BlauApr 23, 2018
  22. 4/6 grep.c: display column number of first matchTaylor Blau, Apr 22, 2018
  23. Eric SunshineApr 23, 2018
  24. Taylor BlauApr 23, 2018
  25. 5/6 builtin/grep.c: show column numbers via --column-numberTaylor Blau, Apr 22, 2018
  26. Ævar Arnfjörð BjarmasonApr 22, 2018
  27. Taylor BlauApr 22, 2018
  28. Eric SunshineApr 23, 2018
  29. Taylor BlauApr 23, 2018
  30. 6/6 contrib/git-jump/git-jump: use column number when grep-ingTaylor Blau, Apr 22, 2018
  31. Ævar Arnfjörð BjarmasonApr 22, 2018
  32. Taylor BlauApr 22, 2018
  33. Junio C HamanoApr 22, 2018
  34. Taylor BlauApr 22, 2018
  35. Junio C HamanoApr 23, 2018
  36. 0/7 Teach '--column-number' to 'git-grep(1)'Taylor Blau, Apr 24, 2018
  37. 1/7 Documentation/config.txt: camel-case lineNumber for consistencyTaylor Blau, Apr 24, 2018
  38. 2/7 grep.c: expose matched column in match_line()Taylor Blau, Apr 24, 2018
  39. 4/7 grep.c: display column number of first matchTaylor Blau, Apr 24, 2018
  40. Eric SunshineApr 24, 2018
  41. 6/7 grep.c: add configuration variables to show matched optionTaylor Blau, Apr 24, 2018
  42. 7/7 contrib/git-jump/git-jump: jump to match column in addition to lineTaylor Blau, Apr 24, 2018
  43. Eric SunshineApr 24, 2018
  44. Taylor BlauApr 24, 2018
  45. 5/7 builtin/grep.c: add '--column-number' option to 'git-grep(1)'Taylor Blau, Apr 24, 2018
  46. 3/7 grep.[ch]: extend grep_opt to allow showing matched columnTaylor Blau, Apr 24, 2018
  47. 0/7 Teach '--column' to 'git-grep(1)'Taylor Blau, May 5, 2018
  48. 1/7 Documentation/config.txt: camel-case lineNumber for consistencyTaylor Blau, May 5, 2018
  49. 2/7 grep.c: expose matched column in match_line()Taylor Blau, May 5, 2018
  50. René ScharfeMay 8, 2018
  51. 3/7 grep.[ch]: extend grep_opt to allow showing matched columnTaylor Blau, May 5, 2018
  52. 4/7 grep.c: display column number of first matchTaylor Blau, May 5, 2018
  53. 5/7 builtin/grep.c: add '--column' option to 'git-grep(1)'Taylor Blau, May 5, 2018
  54. Duy NguyenMay 5, 2018
  55. Taylor BlauMay 7, 2018
  56. Phillip WoodMay 6, 2018
  57. Ævar Arnfjörð BjarmasonMay 6, 2018
  58. Taylor BlauMay 7, 2018
  59. Junio C HamanoMay 7, 2018
  60. Taylor BlauMay 8, 2018
  61. 6/7 grep.c: add configuration variables to show matched optionTaylor Blau, May 5, 2018
  62. 7/7 contrib/git-jump/git-jump: jump to match column in addition to lineTaylor Blau, May 5, 2018
  63. Martin ÅgrenMay 6, 2018
  64. Ævar Arnfjörð BjarmasonMay 6, 2018
  65. Taylor BlauMay 7, 2018
  66. 0/7 Teach '--column' to 'git-grep(1)'Taylor Blau, May 9, 2018
  67. 1/7 Documentation/config.txt: camel-case lineNumber for consistencyTaylor Blau, May 9, 2018
  68. 3/7 grep.[ch]: extend grep_opt to allow showing matched columnTaylor Blau, May 9, 2018
  69. 4/7 grep.c: display column number of first matchTaylor Blau, May 9, 2018
  70. 6/7 grep.c: add configuration variables to show matched optionTaylor Blau, May 9, 2018
  71. 7/7 contrib/git-jump/git-jump: jump to match column in addition to lineTaylor Blau, May 9, 2018
  72. 5/7 builtin/grep.c: add '--column' option to 'git-grep(1)'Taylor Blau, May 9, 2018
  73. Phillip WoodMay 9, 2018
  74. Martin ÅgrenMay 9, 2018
  75. Taylor BlauMay 9, 2018
  76. Junio C HamanoMay 10, 2018
  77. René ScharfeMay 10, 2018
  78. Junio C HamanoMay 10, 2018
  79. Taylor BlauMay 12, 2018
  80. Junio C HamanoMay 12, 2018
  81. Taylor BlauMay 12, 2018
  82. Junio C HamanoMay 12, 2018
  83. Taylor BlauMay 18, 2018
  84. Junio C HamanoMay 18, 2018
  85. Taylor BlauMay 18, 2018
  86. Taylor BlauMay 19, 2018
  87. Taylor BlauMay 9, 2018
  88. Duy NguyenMay 9, 2018
  89. Taylor BlauMay 9, 2018
  90. 2/7 grep.c: expose matched column in match_line()Taylor Blau, May 9, 2018
  91. 0/7 Teach '--column' to 'git-grep(1)'Taylor Blau, May 12, 2018
  92. 1/7 Documentation/config.txt: camel-case lineNumber for consistencyTaylor Blau, May 12, 2018
  93. 2/7 grep.c: expose matched column in match_line()Taylor Blau, May 12, 2018
  94. 3/7 grep.[ch]: extend grep_opt to allow showing matched columnTaylor Blau, May 12, 2018
  95. 4/7 grep.c: display column number of first matchTaylor Blau, May 12, 2018
  96. 5/7 builtin/grep.c: add '--column' option to 'git-grep(1)'Taylor Blau, May 12, 2018
  97. 6/7 grep.c: add configuration variables to show matched optionTaylor Blau, May 12, 2018
  98. 7/7 contrib/git-jump/git-jump: jump to match column in addition to lineTaylor Blau, May 12, 2018
  99. 2/6 grep.c: take column number as argument to show_line()Taylor Blau, Apr 21, 2018
  100. 3/6 grep.[ch]: teach columnnum, color_columnno to grep_optTaylor Blau, Apr 21, 2018
  101. Martin ÅgrenApr 21, 2018
  102. 4/6 grep.c: display column number of first matchTaylor Blau, Apr 21, 2018
  103. 5/6 builtin/grep.c: show column numbers via --column-numberTaylor Blau, Apr 21, 2018
  104. Junio C HamanoApr 21, 2018
  105. Junio C HamanoApr 21, 2018
  106. René ScharfeApr 21, 2018
  107. Martin ÅgrenApr 21, 2018
  108. 6/6 contrib/git-jump/git-jump: use column number when grep-ingTaylor Blau, Apr 21, 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.