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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux