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

Re: git log -Sfoo ignores indentation (whitespace?) changes...

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 3, 2009, 15:58 UTC
Message-ID
<7vprgyd2db.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<49AD3E78.1050706@sneakemail.com>
"Peter Valdemar Mørch (Lists)"  <4ux6as402@sneakemail.com> writes:
> Commits where only the indentation of 'foo' is changed are not shown
> with "git log -Sfoo". Is there any way to force showing them along
> with other changes involving foo? (E.g. for python, indentation
> matters!)

No. You should be running "git log -p" which spawns "less" and then type /foo to jump to the occurrences of "foo".

The pickaxe -Sfoo looks for a filepair that contains different number of substring "foo". It was designed as a basic building block for a very different kind of Porcelain, whose final shape would look like the tool described in http://article.gmane.org/gmane.comp.version-control.git/217, but not yet written by anybody yet.

And I think it might be the good topic for a SoC project. From some GUI, you let the user grab a block of text, feed it to "log -S<that multi-line string> -1" to find where that block of text last changed, and inspect the commit you have found very carefully using things like "git grep" to find other places in the commit that could be related to the change of the block of text, present all of them to the user. From there you let the user dig deeper in the history by choosing what to look for next, most likely giving the default selection to the block of text that roughly corresponds to the original selection.

To make the iteration fast for this use case, the pickaxe cannot afford to actually run diff and then grep inside the diff output (which is what you would be doing with "log -p | less" and looking for your string in it).

Previous: Jeff King
Message 17 of 17 in “git log -Sfoo ignores indentation (whitespace?) changes...”
  1. Peter Valdemar Mørch (Lists)Mar 3, 2009
  2. Jeff KingMar 3, 2009
  3. doc: clarify how -S worksJeff King, Mar 3, 2009
  4. John TapsellMar 3, 2009
  5. Jeff KingMar 3, 2009
  6. John TapsellMar 3, 2009
  7. Junio C HamanoMar 3, 2009
  8. Jeff KingMar 3, 2009
  9. John TapsellMar 3, 2009
  10. Jeff KingMar 3, 2009
  11. Junio C HamanoMar 3, 2009
  12. Peter Valdemar Mørch (Lists)Mar 3, 2009
  13. Jeff KingMar 3, 2009
  14. Junio C HamanoMar 3, 2009
  15. Michael J GruberMar 3, 2009
  16. Jeff KingMar 3, 2009
  17. Junio C HamanoMar 3, 2009

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.