GNOME Bugzilla – Bug 706455
When inside a path that involves symlinks, the Git plugin highlights the entire file contents as being new
Last modified: 2019-03-23 20:50:17 UTC
Created attachment 252499 [details] screenshot I have yet to find an explanation for this, but Gedit's "git" plugin behaves differently on my two computers. Same OS (Fedora 18 64-bit), same packages (python3 is installed, gedit-plugins installed from the system, all updates applied)... but on my desktop computer, gedit highlights the entire file in green as if all the contents where brand new, where only one line changed (see attached screenshot). How can I troubleshoot this?
mmm, that should only happen if the file is new in the repository. Can you try to add some more debug information on the git plugin and see where it is broken? I've been using the plugin for several months and I never had such problem...
It does that for the whole file, for all files, for all git repositories... as I said, only one of my computers is affected, the other doesn't exhibit this problem. Do you have suggestions of what kind of stuff I should print out, and how to do so? I naively tried to do this in viewactivatable.py: for line_data in diff: + print("line data", line_data[0]) But nothing gets printed by gedit in the terminal I ran it from. I have no idea what I'm doing really :)
Could it have something to do with the file in question being behind symlink (or being a symlink)? I think I can see the similar behavior with files in the symlinked directory.
Hi, I'm having a similar issue, only that it's quite understandable in my case: In gedit 3.12, for all files in a symlinked directory, all files are shown as new. I think the best solution to this would be to get the real path of the file and either – when the real path is outside the git root of the symlink path (which would be weird, but I think shouldn't be asserted to be false) – not showing any changes or otherwise get the changes from git using the real file path. I'll look at the plugin code and if I'm able to, write a patch :)
Okay, I'm not really experienced in Python, also I went unsure if this should really be fixed here; I think it could be considered a bug in Ggit too.
Damn, that must be it! On my desktop computer, ~/pitivi-git/ is a symlink to some other hard drive, whereas on my laptop ~/pitivi-git/ is a regular directory.
I've fixed this and encoding in the patch: https://github.com/JacekPliszka/gedit-plugins/commit/057dd6e70dfc9dac6c6dc47f3285dd9eaf393d72 Could you please add it to the master?
(In reply to Jacek Pliszka from comment #7) > I've fixed this and encoding in the patch: > > https://github.com/JacekPliszka/gedit-plugins/commit/ > 057dd6e70dfc9dac6c6dc47f3285dd9eaf393d72 > > Could you please add it to the master? Would be so kind and attach the patch generated by git format-patch to this bug as an attachment, please? It would allow us to use the internal review tool. Thank you.
Created attachment 316036 [details] [review] Fixes for symlinks and encoding problem It fixes symlink problem. It goves workaround to encoding problem - you can set it in git config gui.encoding
Done, never done this before so excuse me if I did it wrong.
Review of attachment 316036 [details] [review]: ::: plugins/git/git/viewactivatable.py @@ +136,3 @@ + relative_path = os.path.relpath( + os.path.normpath(os.path.realpath(self.location.get_path())), os.path.realpath calls os.path.abspath which in turn calls os.path.normpath so its explicit call is unnecessary. @@ -142,2 +152,2 @@ # Remove the last empty line added by gedit automatically - if len(self.file_contents_list) > 0: + if self.file_contents_list: Why? str.splitlines() always returns list (albeit possibly the empty one).
Review of attachment 316036 [details] [review]: ::: plugins/git/git/viewactivatable.py @@ -148,1 +158,2 @@ except GLib.Error: + print("GLib.Error", sys.exc_info()[0]) This is forgotten debugging print() right?
regarding normpath - removed regarding len - unnecessary regarding print - I removed it but I believe the error handling here is incorrect - I just do not have right skill-time combination at the moment
Created attachment 316801 [details] [review] Corrections after code review
(In reply to Jacek Pliszka from comment #13) > regarding print - I removed it but I believe the error handling here is > incorrect - I just do not have right skill-time combination at the moment What would you hope for? I am not sure where to get a more detailed information. Anyway, I will merge this patch, it works perfectly for me (THANK YOU!) and if you have any further improvements, I am all ears.
Commited as 76c1cb1d213b4ca1f0a1a715e22be8a59aedd835
I am not convinced that GLib.Error is the only one that can happen here.