After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 706455 - When inside a path that involves symlinks, the Git plugin highlights the entire file contents as being new
When inside a path that involves symlinks, the Git plugin highlights the enti...
Status: RESOLVED FIXED
Product: gedit-plugins
Classification: Other
Component: General
3.8.x
Other Linux
: Normal normal
: ---
Assigned To: Gedit maintainers
Gedit maintainers
Depends on:
Blocks:
 
 
Reported: 2013-08-21 01:30 UTC by Jean-François Fortin Tam
Modified: 2019-03-23 20:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
screenshot (43.47 KB, image/png)
2013-08-21 01:30 UTC, Jean-François Fortin Tam
  Details
Fixes for symlinks and encoding problem (2.42 KB, patch)
2015-11-21 23:30 UTC, Jacek Pliszka
needs-work Details | Review
Corrections after code review (1.33 KB, patch)
2015-12-05 10:20 UTC, Jacek Pliszka
none Details | Review

Description Jean-François Fortin Tam 2013-08-21 01:30:07 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?
Comment 1 Ignacio Casal Quinteiro (nacho) 2013-08-21 06:11:04 UTC
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...
Comment 2 Jean-François Fortin Tam 2013-08-22 03:48:49 UTC
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 :)
Comment 3 Matěj Cepl 2013-10-12 10:58:51 UTC
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.
Comment 4 Jonas Platte 2014-05-11 21:30:07 UTC
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 :)
Comment 5 Jonas Platte 2014-05-11 21:43:13 UTC
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.
Comment 6 Jean-François Fortin Tam 2014-05-12 02:03:54 UTC
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.
Comment 7 Jacek Pliszka 2015-11-21 19:35:43 UTC
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?
Comment 8 Matěj Cepl 2015-11-21 23:07:10 UTC
(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.
Comment 9 Jacek Pliszka 2015-11-21 23:30:08 UTC
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
Comment 10 Jacek Pliszka 2015-11-21 23:30:50 UTC
Done, never done this before so excuse me if I did it wrong.
Comment 11 Matěj Cepl 2015-12-03 17:06:04 UTC
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).
Comment 12 Matěj Cepl 2015-12-03 17:09:21 UTC
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?
Comment 13 Jacek Pliszka 2015-12-05 10:15:24 UTC
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
Comment 14 Jacek Pliszka 2015-12-05 10:20:07 UTC
Created attachment 316801 [details] [review]
Corrections after code review
Comment 15 Matěj Cepl 2015-12-05 15:08:12 UTC
(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.
Comment 16 Matěj Cepl 2015-12-05 15:43:51 UTC
Commited as 76c1cb1d213b4ca1f0a1a715e22be8a59aedd835
Comment 17 Jacek Pliszka 2015-12-05 16:01:14 UTC
I am not convinced that GLib.Error is the only one that can happen here.