Bug 581030 - Compare of moved files do not work
Summary: Compare of moved files do not work
Status: RESOLVED FIXED
Alias: None
Product: EGit
Classification: Technology
Component: UI (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 6.4   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-10 10:04 EST by Christoph Laeubrich CLA
Modified: 2022-11-25 00:34 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Laeubrich CLA 2022-11-10 10:04:02 EST
If I move a file from one place to the other it is automatically deleted/added by git to the staging view.

But afterwards comparing do not work anymore the diff view always show it as a new file, this is especially annoying if one has moved the file and then change it to see what (beside the move) was modified.

It would be great if EGit somewhere record the move and then creates a compare with the previous file.
Comment 1 Thomas Wolf CLA 2022-11-10 15:22:57 EST
See also the related bug 580240 in JGit. Similar problem. JGit has no rename detection between the working tree and HEAD, and apparently also not between the index and HEAD.

Index to HEAD might perhaps be easier to implement. Basically before opening the diff, one would need to run a rename detection to determine the path in HEAD to compare against. That would cover the case when the addition is already staged.

Doing the same for unstaged moves would require rename detection between the working tree and the index or HEAD. That's then the same problem as in bug 580240.
Comment 2 Eclipse Genie CLA 2022-11-13 09:24:40 EST
New Gerrit change created: https://git.eclipse.org/r/c/egit/egit/+/196898
Comment 3 Eclipse Genie CLA 2022-11-13 09:24:42 EST
New Gerrit change created: https://git.eclipse.org/r/c/egit/egit/+/196899
Comment 4 Christoph Laeubrich CLA 2022-11-13 09:28:28 EST
@Thomas Wolf I trust you in the technical part and conclusions, I sadly have no deeper knowledge about how (j)git works in regard to moved files, I just notices that afterwards egit seem to show that a file was moved, and also e.g. github tells me that I have "just moved" the file or if I moved and modified it, so it seems that there are some techniques to detect this :-)
Comment 7 Thomas Wolf CLA 2022-11-24 18:03:55 EST
For staged renamed files, I consider this solved. Additionally, there is now a "Compare With Each Other" in the staged and unstaged viewers to compare two staged or two unstaged files.

Renamings between the working tree and index or HEAD are hard, and I'm not sure it can be done in any halfway efficient way. It might involve too many file reads to do comparisons. If at all possible I'd like to handle that as part of bug 580240.
Comment 8 Christoph Laeubrich CLA 2022-11-25 00:34:41 EST
Great I think this is already a good achievement!