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

Re: git-diff passes <rev>:<path> args to GIT_EXTERNAL_DIFF incorrectly?

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 29, 2019, 03:54 UTC
Message-ID
<xmqqtva0zkvu.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<CAH53SykX12SN83=gey8KS_x3cGkXH758sfEieskXnnvos8DMcA@mail.gmail.com>
Dmitry Nikulin <pastafariant@gmail.com> writes:
> $ env GIT_EXTERNAL_DIFF=./print_argv.py git diff
> origin/branch1:file1.txt origin/branch2:file2.txt

I didn't even know external-diff driver is called (and does not even segfaut) in the "compare two blobs" hack codepath.

The syntax <tree-ish>:<path-in-the-tree> you have on the command line resolves to a blob object name. There is no leading directory name, there is no permission bits or executable bit, there is no filename, when "diff" is told to compare two blob objects this way. THe "diff" machinery that drives the external (or internal for that matter) diff will only get two 40-hex blob object names and nothing else. The only pieces of information you can trust among those the external program may receive are the blob object name(s) and the contents stored in the temporary files given to it. The location of these temporary files or their mode bits have no relation to the "files" in some tree in the original repository, as that information is long lost when you write <tree-ish>:<path-in-the-tree> to tell Git to use that as a blob object name.

    $ git diff -M branch1 branch2 -- file1 file2

if file1 and file2 have similar-enough contents, may have a better chance of what you wanted to ask Git (if I am guessing what it is, that is).

Previous: Dmitry NikulinNext: Dmitry Nikulin
Message 3 of 12 in “git-diff passes <rev>:<path> args to GIT_EXTERNAL_DIFF incorrectly?”
  1. Dmitry NikulinAug 27, 2019
  2. Dmitry NikulinAug 27, 2019
  3. Junio C HamanoAug 29, 2019
  4. Dmitry NikulinAug 29, 2019
  5. Phillip WoodAug 30, 2019
  6. Dmitry NikulinAug 30, 2019
  7. Phillip WoodAug 30, 2019
  8. Jeff KingAug 30, 2019
  9. Dmitry NikulinAug 30, 2019
  10. Dmitry NikulinAug 30, 2019
  11. SZEDER GáborAug 30, 2019
  12. Junio C HamanoAug 30, 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.