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

Re: git log -S not finding all commits?

From
Andreas Ericsson <ae@op5.se>
Date
Oct 8, 2009, 09:12 UTC
Message-ID
<4ACDACE6.9060509@op5.se>
In-Reply-To
<7ae12651.522df17b.4acda0f5.21a31@o2.pl>
On 10/08/2009 10:21 AM, Daniel wrote:
Show 19 quoted lines
> Hi,
>
> I did:
>
> $ git version
> git version 1.6.4.4
> $ mkdir a&&  cd a&&  git init
> $ echo "Free data">  a
> $ git add a
> $ git commit -m1
> $ echo "Free data allocated by other function">  a
> $ git commit -a -m2
> $ PAGER=cat git log -S'Free' --oneline
> 2f34241 1
>
> I would expect "git log" to show both 1 and 2 commit, but it prints only 1.
>
> Is it the correct behavior?
>

Yes, it's the correct behaviour. -S finds only lines where what you search for was added or deleted. It counts the number of occurrences of what you specify in each resulting tree and only shows the commits where that number changed. In your case, searching for "Free data " would have printed both commits, since you first introduce that entire string and then remove it.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.
Previous: DanielNext: Daniel
Message 2 of 15 in “git log -S not finding all commits?”
  1. DanielOct 8, 2009
  2. Andreas EricssonOct 8, 2009
  3. DanielOct 8, 2009
  4. Matthieu MoyOct 8, 2009
  5. Matthieu MoyOct 8, 2009
  6. DanielOct 8, 2009
  7. Matthieu MoyOct 8, 2009
  8. Randal L. SchwartzOct 8, 2009
  9. Matthieu MoyOct 9, 2009
  10. Scott WiersdorfOct 9, 2009
  11. Randal L. SchwartzOct 9, 2009
  12. Matthieu MoyOct 9, 2009
  13. Randal L. SchwartzOct 9, 2009
  14. Scott WiersdorfOct 9, 2009
  15. Nanako ShiraishiOct 8, 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.