0

Lets say I have a local history like this

----A              master
     \        
      C------D     feature

Where I ran the following commands to create commit B:

git checkout master
git merge feature --no-ff -m "Added new feature"

----A----------B   master
     \        /
      C------D     feature

In gitk with my HEAD at master (commit B), the "Patch" will show a blank diff.

But I'd expect the patch to show the diff between B and A. Similar to what the following commands would show:

git checkout master      //now at B
git diff HEAD^

What options do I have to get gitk work this way?

g19fanatic
  • 10,567
  • 6
  • 33
  • 63
  • If you manually put in the commit it: `git diff sha-id-of-A` – nishantjr Jun 05 '14 at 14:23
  • the sha id is something like `aa9205c100d9ba040f0b3bd44706c612d29a5fd4` or for short ids: `aa9205c` – nishantjr Jun 05 '14 at 14:25
  • @nishantjr, I'm not sure what you mean. I already know how to see the diff on the command line (as shown above) but that same diff isn't what gitk shows for its Patch in the above situation. – g19fanatic Jun 05 '14 at 14:31
  • I'm not sure what you mean. gitk is showing me the diff of the merge commit. Not either of of the parents. (It's empty for me) – nishantjr Jun 05 '14 at 14:35
  • I agree with you. Mine is empty too. That is what i find to be unusual. If i'm on a branch, I'm expecting (possibly incorrectly) that the Patch should show the diff between that branches current location and its ancester (HEAD^). I'm asking how I can get (through command line options, or View options) how to get gitk to show me patches like that. If it cannot work this way, gitk can be essentially useless for more workflows as this is a common one. – g19fanatic Jun 05 '14 at 14:40
  • The patch for the merge commit shows the changes in the merge. Not the patch of either parent. It would be empty unless you resolved conflicts during the merge – nishantjr Jun 05 '14 at 14:42

1 Answers1

0

A bit of speculation here:

Gitk shows the difference between a commit's content and content that was not in any of the parents' commits.

Ordinarily, a commit would change something from it's parent, but in the case of a merge, the actual merge commit does not make any changes.

If the merge made resolved conflicts (changes that aren't in either parent) they would show up in gitk

This post seems to have an answer - with less speculation.

The easiest way to view the full diff between a parent of a merge and the merge commit is to select the parent (normal click) and from the context menu on the merge commit (right/alternate click menu) select "Diff selected -> this".

Community
  • 1
  • 1
nishantjr
  • 1,788
  • 1
  • 15
  • 39