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

log -p hides changes in merge commit

From
PSPhillip Susi <psusi@cfl.rr.com>
Date
Jan 6, 2011, 17:07 UTC
Message-ID
<4D25F6BE.7010300@cfl.rr.com>

git log -p never shows a diff for merge commits. It is nice that it does not show a giant diff that is the sum of all of the changes being merged, but any manual changes made on top of the merge are also lost from view, and this is not good. Here is a reproduction recipe:

git init echo foo > a git add a git commit -m "added a" git branch other git checkout other echo bar > b git add b git commit -m "added b" git checkout master git merge other git log -p

At this point there is no diff shown in the log output. This is fine since there were no changes needed to complete the merge, and the addition of b is already documented in the merged commit. The problem is that if you add --no-merge to the git merge, and then:

echo bart > a git add a git commit

Now in addition to merging b, you have modified a, but git log -p still shows no diff, effectively hiding the fact that you snuck in a modification to a during the merge.

It seems that adding -c or --cc to the log correctly shows the change to a, but why is this not shown by default?

Next: Junio C Hamano
Message 1 of 6 in “log -p hides changes in merge commit”
  1. Phillip SusiJan 6, 2011
  2. Junio C HamanoJan 6, 2011
  3. Phillip SusiJan 6, 2011
  4. Jonathan NiederJan 6, 2011
  5. Phillip SusiJan 7, 2011
  6. Junio C HamanoJan 7, 2011

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.