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

Re: git log -S or -G

From
Jeff King <peff@peff.net>
Date
Oct 9, 2018, 03:21 UTC
Message-ID
<20181009032124.GE6250@sigill.intra.peff.net>
In-Reply-To
<xmqq8t38t4r7.fsf@gitster-ct.c.googlers.com>
On Tue, Oct 09, 2018 at 08:09:32AM +0900, Junio C Hamano wrote:
Show 20 quoted lines
> Julia Lawall <julia.lawall@lip6.fr> writes:
> 
> >> Doing the same for -S is much harder at the machinery level, as it
> >> performs its thing without internally running "diff" twice, but just
> >> counts the number of occurrences of 'foo'---that is sufficient for
> >> its intended use, and more efficient.
> >
> > There is still the question of whether the number of occurrences of foo
> > decreases or increases.
> 
> Hmph, taking the changes that makes the number of hits decrease
> would catch a subset of "changes that removes 'foo' only---I am not
> interested in the ones that adds 'foo'".  It will avoid getting
> confused by a change that moves an existing 'foo' to another place
> in the same file (as the number of hits does not change), but at the
> same time, it will miss a change that genuinely removes an existing
> 'foo' and happens to add a 'foo' at a different place in the same
> file that is unrelated to the original 'foo'.  Depending on the
> definition of "I am only interested in removed ones", that may or
> may not be acceptable.

I think that is the best we could do for "-S", though, which is inherently about counting hits.

For "-G", we are literally grepping the diff. It does not seem unreasonable to add the ability to grep only "-" or "+" lines, and the interface for that should be pretty straightforward (a tri-state flag to look in remove, added, or both lines).

-Peff
Previous: Junio C HamanoNext: Jacob Keller
Message 6 of 11 in “git log -S or -G”
  1. Julia LawallOct 6, 2018
  2. Ævar Arnfjörð BjarmasonOct 6, 2018
  3. Junio C HamanoOct 7, 2018
  4. Julia LawallOct 7, 2018
  5. Junio C HamanoOct 8, 2018
  6. Jeff KingOct 9, 2018
  7. Jacob KellerOct 9, 2018
  8. Julia LawallOct 9, 2018
  9. Junio C HamanoOct 9, 2018
  10. Ævar Arnfjörð BjarmasonOct 9, 2018
  11. Julia LawallOct 9, 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.