git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Dmitry Nikulin <pastafariant@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: git-diff passes <rev>:<path> args to GIT_EXTERNAL_DIFF incorrectly?
Date: Thu, 29 Aug 2019 17:36:00 +0300	[thread overview]
Message-ID: <CAH53SymNwjrh_CzXVVtU5xABuGQWMsXhRDYyRzyHEwuxLWA2NQ@mail.gmail.com> (raw)
In-Reply-To: <xmqqtva0zkvu.fsf@gitster-ct.c.googlers.com>

Thank you for the reply.

On Thu, 29 Aug 2019 at 06:54, Junio C Hamano <gitster@pobox.com> wrote:
>     $ 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).

The context here is that I am trying to diff two Jupyter notebooks
using an external tool (git-nbdiffdriver in my case). Therefore, for
me it is crucial to use the external tool, and not Git's internal
machinery.

For the particular command that you suggested as the replacement, on
my demo repository it does not produce anything interesting, as it
does not detect renames and calls my honeypot twice:

$ env GIT_EXTERNAL_DIFF=./print_argv.py git diff -M origin/branch1
origin/branch2 -- file1.txt file2.txt
['./print_argv.py',
 'file1.txt',
 '/tmp/2IEKCw_file1.txt',
 '802b1c4ed7b06162b2ce09b7db72a576695b96e5',
 '100644',
 '/dev/null',
 '.',
 '.']
['./print_argv.py',
 'file2.txt',
 '/dev/null',
 '.',
 '.',
 '/tmp/oAMdDx_file2.txt',
 '076e8e37a712d8a66c0c3d1a103050dc509ca6ff',
 '100644']

However, for the original repository where I first faced this problem
(https://github.com/yandexdataschool/Practical_RL), Git passes a very
weird set of args to the external diff:

$ env GIT_EXTERNAL_DIFF=./print_argv.py git diff -M master coursera --
week02_value_based/seminar_vi.ipynb
week2_model_based/practice_vi.ipynb
['./print_argv.py',
 'week02_value_based/seminar_vi.ipynb',
 '/tmp/amudWz_seminar_vi.ipynb',
 '8f8016963c888b7dd8dd20f60b7d6fdb41b26c1d',
 '100644',
 '/tmp/Ub7zPz_practice_vi.ipynb',
 '21db80f53b632d975a9af0acbaf397eb717cde2c',
 '100644',
 'week2_model_based/practice_vi.ipynb',
 'similarity index 82%\n'
 'rename from week02_value_based/seminar_vi.ipynb\n'
 'rename to week2_model_based/practice_vi.ipynb\n'
 'index 8f80169..21db80f 100644\n']

I would guess that this is a bug. There can clearly be a hotfix (after
all, Git passes all of the information to the external that it should
per the spec, that is, <old|new>-path, <old|new>-hex, <old|new>-mode;
adding, however, some garbage). I do not know though to what extent
this information is correct. You say that this information is lost
when I use the <tree-ish>:<path> notation; however, Git seems to pass
paths and hexes correctly. This only leaves open the question of file
mode. Perhaps it could be preserved at least for some cases, such as
when the blob is retrieved from a path in a tree?

  reply	other threads:[~2019-08-29 14:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-27 18:24 git-diff passes <rev>:<path> args to GIT_EXTERNAL_DIFF incorrectly? Dmitry Nikulin
2019-08-27 22:25 ` Dmitry Nikulin
2019-08-29  3:54 ` Junio C Hamano
2019-08-29 14:36   ` Dmitry Nikulin [this message]
2019-08-30 10:16     ` Phillip Wood
2019-08-30 13:23       ` Dmitry Nikulin
2019-08-30 14:17         ` Phillip Wood
2019-08-30 14:27         ` Jeff King
2019-08-30 15:28           ` Dmitry Nikulin
2019-08-30 15:51             ` Dmitry Nikulin
2019-08-30 14:29         ` SZEDER Gábor
2019-08-30 16:26           ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH53SymNwjrh_CzXVVtU5xABuGQWMsXhRDYyRzyHEwuxLWA2NQ@mail.gmail.com \
    --to=pastafariant@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).