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

Re: Expected behaviour of 'git log -S' when searching in a merged/deleted file?

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 22, 2010, 18:17 UTC
Message-ID
<7vzkrx4qp6.fsf@alter.siamese.dyndns.org>
In-Reply-To
<AANLkTimXk6ei6EAQfvTTfnMzdBqYHkNoaxkEab+atnHd@mail.gmail.com>
Jonathan del Strother <jdelstrother@gmail.com> writes:
Show 6 quoted lines
> I was trying to find a particular string in my project this morning.
> 'git grep mystring' suggested that the string didn't exist in my repo,
> but 'git log -Smystring' turned up a single commit that had added it.
> It took me a long time to figure out that in the past, a branch had
> added that string to foo.c, but a second branch deleted foo.c, and the
> two branches were later merged (deleting foo.c and ignoring mystring).
This is a typical case of the history simplification in action, isn't it?

"log" will give you one possible and simplest explanation of how the project came into the current shape. Because side branches with changes that were discarded before merging it to the history that lead to the commit you run "log" from do not contribute anything to the end result, "log" will not traverse the entire side branch when it sees the merge.

Try your "log" with --full-history, perhaps?
Previous: Jonathan del StrotherNext: Jonathan del Strother
Message 2 of 5 in “Expected behaviour of 'git log -S' when searching in a merged/deleted file?”
  1. Jonathan del StrotherDec 22, 2010
  2. Junio C HamanoDec 22, 2010
  3. Jonathan del StrotherDec 23, 2010
  4. Junio C HamanoDec 23, 2010
  5. Jonathan del StrotherDec 23, 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.