Repository navigation
rename file got diff with change_type: R100 #563
Description
Activity
Thanks for letting me know! This seems wrong, as if GitPython as mis-interpreted the information obtained from git.
This issue could be fixed, provided that it can be reproduced with the latest version of GitPython.
Do you think you can provide a bash and/or python script to do that?OK here is the thing @Byron
I'm using git version 2.7.4 and GitPython version 2.1.1test scripts:
some_directory ├── gittest.py └── gittest.sh
gittest.py:
import git repo = git.Repo('.') print('\nchange_type=%s\n' % repo.commit('HEAD~1').diff(repo.head.commit)[0].change_type)
gittest.sh:
#!/bin/sh mkdir test cd test git init touch A git add . git commit -m "added A." git mv A B git status git add . git commit -m "renamed A to B" python3 ../gittest.py cd .. rm -rf test git --version pip3 list | grep Git
output:
$ sh gittest.sh Initialized empty Git repository in /some_directory/test/.git/ [master (root-commit) 9a12c82] added A. 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 A On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) renamed: A -> B [master 43dd423] renamed A to B 1 file changed, 0 insertions(+), 0 deletions(-) rename A => B (100%) change_type=R100 git version 2.7.4 DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning. GitPython (2.1.1)
Awesome! Thanks a lot for making it so easy to reproduce the issue!
I will see if I can convert that into a unit-test and fix it.glad to help :)
any news on this? it also happens with git 2.9.3.
@moshezvi Actually there is no progress and I don't see myself working on GitPython except for the most trivial maintenance tasks. Maybe you can take this issue on yourself, it should be relatively straightforward to create a unit-test to help fix it. Sorry for the bad news.
Hello @Byron, there were already a test with R100 as change_type in git/test/fixtures/diff_rename_raw
I can propose you this commit: LeResKP@4beda47
But before doing a pr I would like to store the score on the Diff object, any objection?
Also after doing a man gitl-diff-tree on git 2.13.6 I saw there are some status change not supported:Possible status letters are: · A: addition of a file · C: copy of a file into a new one · D: deletion of a file · M: modification of the contents or mode of a file · R: renaming of a file · T: change in the type of the file · U: file is unmerged (you must complete the merge before it can be committed) · X: "unknown" change type (most probably a bug, please report it) Status letters C and R are always followed by a score (denoting the percentage of similarity between the source and target of the move or copy). Status letter M may be followed by a score (denoting the percentage of dissimilarity) for file rewrites.I would like to add C and T, I don't think we need to support U & X. Okay with you?
- Hi Aurélien, thanks for digging into this! As it sounds like GitPython is coming out better as before, I would be happy to see the modification in a PR. To me it sounds the changes are backwards compatible, which is a prerequisite. Thanks a lot!…On Tue, Feb 27, 2018 at 8:24 AM Aurélien Matouillot < ***@***.***> wrote: Hello @Byron <https://github.com/byron>, there were already a test with R100 as change_type in git/test/fixtures/diff_rename_raw I can propose you this commit: ***@***.*** <LeResKP@34e357b> But before doing a pr I would like to store the score on the Diff object, any objection? Also after doing a man gitl-diff-tree on git 2.13.6 I saw there are some status change not supported: Possible status letters are: · A: addition of a file · C: copy of a file into a new one · D: deletion of a file · M: modification of the contents or mode of a file · R: renaming of a file · T: change in the type of the file · U: file is unmerged (you must complete the merge before it can be committed) · X: "unknown" change type (most probably a bug, please report it) Status letters C and R are always followed by a score (denoting the percentage of similarity between the source and target of the move or copy). Status letter M may be followed by a score (denoting the percentage of dissimilarity) for file rewrites. I would like to add C and T, I don't think we need to support U & X. Okay with you? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#563 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAD4hq7uAdVfMedP9MWkcZ6cQEXDG1Aoks5tY62vgaJpZM4LWJMM> .
when I renamed file A to B like this
but using gitpython in ipython3 I got this:
is that normal or something went wrong?