git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Dmitry Nikulin <pastafariant@gmail.com>,
	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: Fri, 30 Aug 2019 11:16:54 +0100	[thread overview]
Message-ID: <9c280a3f-6a1a-61d1-a255-1dcf0671d39c@gmail.com> (raw)
In-Reply-To: <CAH53SymNwjrh_CzXVVtU5xABuGQWMsXhRDYyRzyHEwuxLWA2NQ@mail.gmail.com>

Hi Dmitry

On 29/08/2019 15:36, Dmitry Nikulin wrote:
> Thank you for the reply.
> [...]
> 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). 

When git detects a rename it adds two parameters to the end of the 
argument list for the external diff program. The first extra argument is 
the new name and the second is the header with the similarity 
information[1]. I'm not sure why the last argument is being split in 
your example. It is not split in the example below

$git mv git.c renamed.c
$env GIT_EXTERNAL_DIFF='printf "|%s|\\n"' git diff HEAD
|git.c|
|/tmp/lMQpP8_git.c|
|c1ee7124edcfb0417539134d50212e997dc71c1f|
|100644|
|renamed.c|
|c1ee7124edcfb0417539134d50212e997dc71c1f|
|100644|
|renamed.c|
|similarity index 100%
rename from git.c
rename to renamed.c
|

Best Wishes

Phillip

[1] https://github.com/git/git/blob/master/diff.c#L4204

>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-30 10:17 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
2019-08-30 10:16     ` Phillip Wood [this message]
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=9c280a3f-6a1a-61d1-a255-1dcf0671d39c@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pastafariant@gmail.com \
    --cc=phillip.wood@dunelm.org.uk \
    /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).