dta
dta

Reputation: 654

Why does this merge commit not show a diff?

In one branch, I added a line of text. In another branch, I modified some lines. I then merged these together, and when fixing the merge conflicts, kept only the changes from the second branch. My question is: Why does removing the line added in 16fcbc7 not appear in the merge commit's diff?

Here is the output of git log --oneline --graph -p. The (empty) diff is the same thing shown for git show 584d05b.

*   584d05b (HEAD, origin/capitalize-lenore) Merge branch 'master' into capitalize-lenore
|\  
| * 16fcbc7 (origin/master) Improve the poem
| | diff --git a/the-raven.txt b/the-raven.txt
| | index adcd9a1..a74559b 100644
| | --- a/the-raven.txt
| | +++ b/the-raven.txt
| | @@ -29,6 +29,7 @@ Darkness there, and nothing more.
| |  Deep into that darkness peering, long I stood there wondering, fearing,
| |  Doubting, dreaming dreams no mortal ever dared to dream before;
| |  But the silence was unbroken, and the darkness gave no token,
| | +and it all was left unspoken, in the vastness of the ocean,
| |  And the only word there spoken was the whispered word, "Lenore!"
| |  This I whispered, and an echo murmured back the word, "Lenore!"
| |  Merely this and nothing more.
* | 6c0160b Capitalize LENORE
|/  
|   diff --git a/the-raven.txt b/the-raven.txt
|   index adcd9a1..a9f39d6 100644
|   --- a/the-raven.txt
|   +++ b/the-raven.txt
|   @@ -8,8 +8,8 @@ Only this, and nothing more."
|    Ah, distinctly I remember it was in the bleak December,
|    And each separate dying ember wrought its ghost upon the floor.
|    Eagerly I wished the morrow:—vainly I had sought to borrow
|   -From my books surcease of sorrow—sorrow for the lost Lenore—
|   -For the rare and radiant maiden whom the angels name Lenore—
|   +From my books surcease of sorrow—sorrow for the lost LENORE—
|   +For the rare and radiant maiden whom the angels name LENORE—
|    Nameless here for evermore.
|    
|    And the silken sad uncertain rustling of each purple curtain
|   @@ -29,8 +29,8 @@ Darkness there, and nothing more.
|    Deep into that darkness peering, long I stood there wondering, fearing,
|    Doubting, dreaming dreams no mortal ever dared to dream before;
|    But the silence was unbroken, and the darkness gave no token,
|   -And the only word there spoken was the whispered word, "Lenore!"
|   -This I whispered, and an echo murmured back the word, "Lenore!"
|   +And the only word there spoken was the whispered word, "LENORE!"
|   +This I whispered, and an echo murmured back the word, "LENORE!"
|    Merely this and nothing more.
|    
|    Back into the chamber turning, all my soul within me burning,
|   @@ -92,8 +92,8 @@ She shall press, ah, nevermore!
|    Then, methought, the air grew denser, perfumed from an unseen censer
|    Swung by seraphim whose foot-falls tinkled on the tufted floor.
|    "Wretch," I cried, "thy God hath lent thee—by these angels he hath sent thee
|   -Respite—respite and nepenthe from thy memories of Lenore!
|   -Quaff, oh quaff this kind nepenthe, and forget this lost Lenore!"
|   +Respite—respite and nepenthe from thy memories of LENORE!
|   +Quaff, oh quaff this kind nepenthe, and forget this lost LENORE!"
|    Quoth the Raven, "Nevermore."
|    
|    "Prophet!" said I, "thing of evil!—prophet still, if bird or devil!—
|   @@ -106,8 +106,8 @@ Quoth the Raven, "Nevermore."
|    "Prophet!" said I, "thing of evil—prophet still, if bird or devil!
|    By that Heaven that bends above, us—by that God we both adore—
|    Tell this soul with sorrow laden if, within the distant Aidenn,
|   -It shall clasp a sainted maiden whom the angels name Lenore—
|   -Clasp a rare and radiant maiden whom the angels name Lenore."
|   +It shall clasp a sainted maiden whom the angels name LENORE—
|   +Clasp a rare and radiant maiden whom the angels name LENORE."
|    Quoth the Raven, "Nevermore."
|    
|    "Be that word our sign of parting, bird or fiend!" I shrieked, upstarting—
* 3c0e072 Add newlines
.
.
.

This question refers to commits in this repository.

Upvotes: 2

Views: 1014

Answers (1)

LeGEC
LeGEC

Reputation: 51830

By default : git log -p does not display any kind of diff for a merge commit.

You can add options to modify that :

  • --cc to get the combined diff format
  • -m to get the full diff format

or explicitly check the diff with either of its parent :

git diff HEAD^ HEAD  # you will see the differences brought in by the second parent
git diff HEAD^2 HEAD # you will see the differences brought in by the first parent

Upvotes: 3

Related Questions