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

[BUG] 'diff A...B' fails with multiple merge bases

From
PEPickens, James E <james.e.pickens@intel.com>
Date
Jul 10, 2010, 01:15 UTC
Message-ID
<3BA20DF9B35F384F8B7395B001EC3FB36CF674AE@azsmsx507.amr.corp.intel.com>
Hi,

The command 'git diff A...B' is supposed to be equivalent to 'git diff $(git merge-base A B) B'. But when there are multiple merge bases between A and B, the former gives no output. Here's a recipe to reproduce the problem:

    git init
    git commit --allow-empty -m 1
    git checkout -b A
    touch file1
    git add file1
    git commit -m A
    git checkout master
    touch file2
    git add file2
    git commit -m B
    git checkout -b B
    git merge A
    git checkout A
    git merge master
    git diff A...B
    git diff $(git merge-base A B) B
The diff commands at the end will give different results.  It bisects to:
commit b75271d93a9e4be960d53fc4f955802530e0e733
Author: Matt McCutchen <matt@mattmccutchen.net>
Date:   Fri Oct 10 21:56:15 2008 -0400
    "git diff <tree>{3,}": do not reverse order of arguments
    According to the message of commit 0fe7c1de16f71312e6adac4b85bddf0d62a47168,
    "git diff" with three or more trees expects the merged tree first followed by
    the parents, in order.  However, this command reversed the order of its
    arguments, resulting in confusing diffs.  A comment /* Again, the revs are all
    reverse */ suggested there was a reason for this, but I can't figure out the
    reason, so I removed the reversal of the arguments.  Test case included.

I verified that if I revert that commit, 'diff A...B' works as expected, but test t4013-diff-various.sh fails. The failing command is 'git diff master master^ side'. I don't understand what that command is supposed to do, so I didn't go any further.

Am I right that this is a bug, and if so can someone help to address it?
James
Next: Junio C Hamano
Message 1 of 10 in “[BUG] 'diff A...B' fails with multiple merge bases”
  1. Pickens, James EJul 10, 2010
  2. Junio C HamanoJul 12, 2010
  3. Junio C HamanoJul 13, 2010
  4. Junio C HamanoJul 13, 2010
  5. Sverre RabbelierJul 13, 2010
  6. Junio C HamanoJul 13, 2010
  7. Sverre RabbelierJul 13, 2010
  8. Junio C HamanoJul 13, 2010
  9. Sverre RabbelierJul 13, 2010
  10. Pickens, James EJul 13, 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.