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

Re: [RFC][PATCH] grep: enable threading for context line printing

From
Fredrik Kuivinen <frekui@gmail.com>
Date
Mar 14, 2010, 20:03 UTC
Message-ID
<4c8ef71003141303h474429aegc0a2eb2f97e7ff69@mail.gmail.com>
In-Reply-To
<4B9D2864.9090808@lsrfire.ath.cx>
On Sun, Mar 14, 2010 at 19:18, René Scharfe <rene.scharfe@lsrfire.ath.cx> wrote:
Show 11 quoted lines
> This patch makes work_done() in builtin/grep.c print hunk marks between
> files if threading is used, while show_line() in grep.c still does the
> same in the other case.  The latter is  controlled by the struct grep_opt
> member show_hunk_mark: 0 means show_line() prints no hunk marks between
> files, 1 means it prints them before the next file with matches and 2
> means it prints them before matches from the current file.
>
> Having two places for this is a bit ugly but it enables parallel grep
> for the common -ABC options.  Locking should be fine in add_work().
>
> Comments?

The implementation looks correct. As you say it is a bit ugly, but I think it is worth it anyway. (The solutions I managed to come up with when I wrote the original threaded grep patch were even uglier, that is why I simply disabled the threading in that case.)

Symbolic constants for the magic values 0, 1, and 2 would make the code more readable.

- Fredrik
Previous: René ScharfeNext: René Scharfe
Message 2 of 5 in “grep: enable threading for context line printing”
  1. René ScharfeMar 14, 2010
  2. Fredrik KuivinenMar 14, 2010
  3. René ScharfeMar 15, 2010
  4. Junio C HamanoMar 15, 2010
  5. Fredrik KuivinenMar 20, 2010

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.