Bug 352625

Summary: Dolphin git plugin loses working directory
Product: [Applications] dolphin Reporter: SeeLook <seelook>
Component: plugins: gitAssignee: Sebastian Dörner <sebastian>
Status: RESOLVED FIXED    
Severity: normal CC: dolphin-bugs-null, thepouar
Priority: NOR    
Version First Reported In: 16.12.2   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 15.08.2
Sentry Crash Report:

Description SeeLook 2015-09-12 19:27:01 UTC
Hi!
I though it was fixed with that patch:
https://git.reviewboard.kde.org/r/125054/
but in fact it repaired only said effect of some main problem.
So, git plugin works fine when Dolphin was opened with some git repo as an argument.
Otherwise, when started from home or any other dir, adding or removing files still don't work.

I investigated it as I could, and the problem is that when git process is invoked:
618	 m_process.setWorkingDirectory(m_contextDir); // m_contextDir is empty here
619	 QStringList arguments;
620	arguments << m_command;
621	arguments << m_arguments;
622	if (m_command == "add" && !item.isDir()){
624	 arguments<< QLatin1String("-f");
625	}
626	arguments << item.localPath();
627	m_process.start(QLatin1String("git"), arguments);

This variable is cleared when context menu of some file is invoked in this method:
QList<QAction*> FileViewGitPlugin::contextMenuFilesActions(const KFileItemList& items) const

m_contextItems.clear();
 the working directory is set to null string, so git becomes deaf and blind.

When I changed it to directory of the first KfileItem of KFileItemList& items
It started working even without the patch I mentioned on the beginning.

But this clearing of the m_contextItems is there for a long, before plugin was ported and it was working then.
More over there is another issue of git plugin:
When new file(s) are created in new directory the plugin sees them as tracked,
so maybe this bugs are related with common reason and setting m_contextItems is again fixing another side effect only.

I would be good if someone more experienced with that plugin things take a look at that.



Reproducible: Always

Steps to Reproduce:
Just open context menu of any file in git repo and try to select 'add' or 'remove'.
Comment 1 thepouar 2015-09-14 17:43:50 UTC
well, those bugs are there. I'm not sure if you can fix it by just applying that specific patch to 15.08 or if you need to use the current revision in master.
Comment 2 SeeLook 2015-09-14 20:58:15 UTC
But I'm using master...
In fact less was changed since March - just two my patches more to fix git
Here is my cloned repo:
https://github.com/SeeLook/dolphin-plugins-hg-KF5-port
You are welcome to try...
and this is official one:
https://projects.kde.org/projects/kde/kdesdk/dolphin-plugins/repository/show?rev=master
Comment 3 thepouar 2015-09-16 00:33:42 UTC
Ok, just wondering since I had the same problem but wasn't using master, btw I'm the guy who posted the last bug. I'm not one of the maintainers and probably wouldn't know how to fix it.
Comment 4 SeeLook 2015-09-17 08:32:34 UTC
Seems like maintainers are busy with other things....
But they are right. The truth looks bitter. This plugin seems to be used less, so with all those new things in KF5 there are much serious issues to fix.

This bug with marking unversioned files in directory with only such files, existed before (KDE4) and no one complained.
From user point of view, I prefer mercurial plugin - it is example how this git plugin might look like (and work like). I daresay more: Dolphin mercurial plugin keeps me to using hg over git.

But I made an attempt to fix it - it is working but  I would like to be more concern. I would be good if someone will try it before I will send some patches.
It is already there:
https://github.com/SeeLook/dolphin-plugins-hg-KF5-port.

But it is not all. Dolphin calls this plugin twice per every directory change (in git repo range), so version checking is performed twice....
Comment 5 thepouar 2015-09-17 19:19:32 UTC
Seems to work but I probably tested it about as much as you did.
Comment 6 SeeLook 2015-09-18 10:17:14 UTC
Thanks for feedback. 
I will test it more in next days
Comment 7 Emmanuel Pescosta 2015-09-26 13:25:41 UTC
Git commit 508c031898bd93d44157f11067a0d77ce879247a by Emmanuel Pescosta.
Committed on 26/09/2015 at 13:22.
Pushed by emmanuelp into branch 'master'.

Revert "Fixed adding files in git repository with Dolphin git plugin"

This patch only solved a side effect of the main problem, see bug 352625.

This reverts commit 1195eb03a2959b4f543161acfe7b03f2b5647c42.
CCMAIL: seelook@gmail.com

M  +1    -1    git/fileviewgitplugin.cpp

http://commits.kde.org/dolphin-plugins/508c031898bd93d44157f11067a0d77ce879247a
Comment 8 Emmanuel Pescosta 2015-09-26 13:33:51 UTC
Git commit dffd12f65ca6db3af4a10fe1025a98252812798b by Emmanuel Pescosta, on behalf of Tomasz Bojczuk.
Committed on 26/09/2015 at 13:28.
Pushed by emmanuelp into branch 'master'.

Don't mark untracked items as 'normal'

Also process untracked files (via git status -u) so that Dolphin can properly
display the version of a file/folder.
FIXED-IN: 15.08.2
REVIEW: 125385

M  +1    -1    git/fileviewgitplugin.cpp

http://commits.kde.org/dolphin-plugins/dffd12f65ca6db3af4a10fe1025a98252812798b
Comment 9 Emmanuel Pescosta 2015-09-26 13:43:48 UTC
Git commit c875c04662df56c53b45b58767dcbbf95ff40236 by Emmanuel Pescosta, on behalf of Tomasz Bojczuk.
Committed on 26/09/2015 at 13:37.
Pushed by emmanuelp into branch 'Applications/15.08'.

Don't mark untracked items as 'normal'

Also process untracked files (via git status -u) so that Dolphin can properly
display the version of a file/folder.
FIXED-IN: 15.08.2
REVIEW: 125385

M  +1    -1    git/fileviewgitplugin.cpp

http://commits.kde.org/dolphin-plugins/c875c04662df56c53b45b58767dcbbf95ff40236
Comment 10 Emmanuel Pescosta 2015-09-26 13:43:48 UTC
Git commit f8164b2273b6053e035e386a788f7521eb7c035f by Emmanuel Pescosta.
Committed on 26/09/2015 at 13:38.
Pushed by emmanuelp into branch 'Applications/15.08'.

Revert "Fixed adding files in git repository with Dolphin git plugin"

This patch only solved a side effect of the main problem, see bug 352625.

This reverts commit 1195eb03a2959b4f543161acfe7b03f2b5647c42.
CCMAIL: seelook@gmail.com

M  +1    -1    git/fileviewgitplugin.cpp

http://commits.kde.org/dolphin-plugins/f8164b2273b6053e035e386a788f7521eb7c035f
Comment 11 Emmanuel Pescosta 2015-09-26 18:28:21 UTC
Git commit 012664e2d07b82f9b0b68f4f42812a0e66460359 by Emmanuel Pescosta, on behalf of Tomasz Bojczuk.
Committed on 26/09/2015 at 18:13.
Pushed by emmanuelp into branch 'Applications/15.08'.

Set the working directory instead of clearing it.
REVIEW: 125383
FIXED-IN: 15.08.2

M  +2    -1    git/fileviewgitplugin.cpp

http://commits.kde.org/dolphin-plugins/012664e2d07b82f9b0b68f4f42812a0e66460359