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

Re: git-log on a file, and merges

From
Derrick Stolee <stolee@gmail.com>
Date
Aug 2, 2019, 14:22 UTC
Message-ID
<05c77291-48d1-a592-6296-d8a8bdb16b02@gmail.com>
In-Reply-To
<CAA01Csp=g08N4+S1HKAjV2a12VJNSJU0UYdAU6LW1jGWLD9SLQ@mail.gmail.com>
On 8/2/2019 5:38 AM, Piotr Krukowiecki wrote:
Show 13 quoted lines
> Hi,
> 
> I have merged a branch into master.
> 
> When on master I do "git log -- some/file", it does not show commits
> from merged branch (which I know they changed the file).
> I have to add "--full-history" to see the commits.
> When I run "git log" (without "-- some/file") I can see the commits
> without using "--full-history".
> 
> This seems not logical, and contrary to user expectations. Harmful even ;)
> 
> Am I missing something?
Hi Piotr,

You are falling victim to an issue related to file history simplification [1] and a (probably) bad merge. You can read more about how this can happen at [2].

When git log reaches a merge commit and one of the parents matches that path exactly, only that parent is walked. The other is ignored. In some sense, the other commit did not contribute changes to that file (because we only took changes from the other parent). This makes the history look good and enables some performance boosts.

Basically, someone must have gotten a merge conflict and used "-S ours" to wipe away the changes from the other branch on that file. You can find that merge by running

	git log --full-history --simplify-merges -- some/file

You will see the merge commit that un-did the change somewhere above the commit you are expecting to see in the history.

Thanks, -Stolee

[1] https://git-scm.com/docs/git-log#_history_simplification [2] https://docs.microsoft.com/en-us/azure/devops/repos/git/git-log-history-simplification?view=azure-devops

Previous: Piotr KrukowieckiNext: Piotr Krukowiecki
Message 2 of 5 in “git-log on a file, and merges”
  1. Piotr KrukowieckiAug 2, 2019
  2. Derrick StoleeAug 2, 2019
  3. Piotr KrukowieckiAug 2, 2019
  4. Junio C HamanoAug 2, 2019
  5. Piotr KrukowieckiAug 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.