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

Re: [PATCH 2/2] diffcore-pickaxe: add --pickaxe-raw-diff for use with -G

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Apr 24, 2019, 15:37 UTC
Message-ID
<87o94vs9cp.fsf@evledraar.gmail.com>
In-Reply-To
<20190424152215.16251-3-avarab@gmail.com>
On Wed, Apr 24 2019, Ævar Arnfjörð Bjarmason wrote:
Show 12 quoted lines
> Add the ability for the -G<regex> pickaxe to search only through added
> or removed lines in the diff, or even through an arbitrary amount of
> context lines when combined with -U<n>.
>
> This has been requested[1][2] a few times in the past, and isn't
> currently possible. Instead users need to do -G<regex> and then write
> their own post-parsing script to see if the <regex> matched added or
> removed lines, or both. There was no way to match the adjacent context
> lines other than running and grepping the equivalent of a "log -p -U<n>".
>
> 1. https://public-inbox.org/git/xmqqwoqrr8y2.fsf@gitster-ct.c.googlers.com/
> 2. https://public-inbox.org/git/20190424102609.GA19697@vmlxhi-102.adit-jv.com/

I see now once I actually read Eugeniu Rosca's E-Mail upthread instead of just knee-jerk sending out patches that this doesn't actually solve his particular problem fully.

I.e. if you want some AND/OR matching support this --pickaxe-raw-diff won't give you that, but it *does* make it much easier to script up such an option. Run it twice with -G"\+<regex>" and -G"-<regex>", "sort | uniq -c" the commit list, and see which things occur once or twice.

Of course that doesn't give you more complex nested and/or cases, but if git-log grew support for that like git-grep has the -G option could use that, although at that point we'd probably want to spend effort on making the underlying machinery smarter to avoid duplicate work.

Furthermore, and quoting Eugeniu upthread:
    In the context of [1], I would like to find all Linux commits which
    replaced:
    	'devm_request_threaded_irq(* IRQF_SHARED *)'
    by:
    	'devm_request_threaded_irq(* IRQF_ONESHOT *)'

Such AND/OR machinery would give you what you wanted *most* of the time, but it would also find removed/added pairs that were "unrelated" as well as "related". Solving *that* problem is more complex, but something the diff machinery could in principle expose.

But the "-G<regex> --pickaxe-raw-diff" feature I have as-is is very useful, I've had at least two people off-list ask me about a problem that would be solved by it just in the last 1/2 year (unrelated to them having seen the WIP patch I sent last October).

It's more general than Junio's suggested --pickaxe-ignore-{add,del} options[1], but those could be implemented in terms of this underlying code if anyone cared to have those as aliases. You'd just take the -G<regex> and prefix the <regex> with "^\+" or "^-" as appropriate and turn on the DIFF_PICKAXE_G_RAW_DIFF flag.

1. https://public-inbox.org/git/xmqqwoqrr8y2.fsf@gitster-ct.c.googlers.com/
Previous: Ævar Arnfjörð BjarmasonNext: Eugeniu Rosca
Message 5 of 14 in “Multi-line 'git log -G<regex>'?”
  1. Eugeniu RoscaApr 24, 2019
  2. 0/2 diffcore-pickaxe: implement --pickaxe-raw-diffÆvar Arnfjörð Bjarmason, Apr 24, 2019
  3. 1/2 diffcore-pickaxe: refactor !one or !two case in diff_grepÆvar Arnfjörð Bjarmason, Apr 24, 2019
  4. 2/2 diffcore-pickaxe: add --pickaxe-raw-diff for use with -GÆvar Arnfjörð Bjarmason, Apr 24, 2019
  5. Ævar Arnfjörð BjarmasonApr 24, 2019
  6. Eugeniu RoscaApr 24, 2019
  7. Ævar Arnfjörð BjarmasonApr 24, 2019
  8. Junio C HamanoApr 25, 2019
  9. Ævar Arnfjörð BjarmasonApr 25, 2019
  10. Eugeniu RoscaMay 3, 2019
  11. Eugeniu RoscaMay 3, 2019
  12. Eugeniu RoscaApr 25, 2019
  13. Ævar Arnfjörð BjarmasonApr 25, 2019
  14. Jeff KingMay 3, 2019

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.