Bug 363576 - Dolphin constantly recreates .git/index.lock file, effectively breaking git
Summary: Dolphin constantly recreates .git/index.lock file, effectively breaking git
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: plugins: git (show other bugs)
Version: 17.12.1
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Sebastian Dörner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-27 06:51 UTC by Nikita Skovoroda
Modified: 2020-11-02 14:14 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 20.12


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nikita Skovoroda 2016-05-27 06:51:25 UTC
Opening a directory or a subdirectory of some git repository in Dolphin often makes command-line git unusable in that directory, because Dolphin constantly re-creates the git lock for some reason. Removing the lock doesn't help — dolphin creates it again. Only navigating outside of the directory in Dolphin (or closing the directory completely) helps.

Reproducible: Sometimes

Steps to Reproduce:
1. open some git repository in Dolphin
2. LANG=C watch -n 0.1 ls -l --time-style=full-iso .git/index.lock
3. If you don't see .git/index.lock above, try navigating in that repo or opening a larger repo.

Actual Results:  
I observe .git/index.lock being constantly created and updated.

Expected Results:  
I expect no .git/index.lock created by file manager untill user manually performed some git operation with it.
Comment 1 Nikita Skovoroda 2018-01-30 01:28:05 UTC
Still reproducable on 17.12.1. To observe this, the git plugin should be enabled in Dolphin.
Comment 2 Nopeinger 2018-05-26 20:33:50 UTC
I can reproduce the generation of a lockfile but it gets destroyed instantly.

After looking into the code of the plugin, I think the lockfile gets created while searching for the stati of the files, see:
https://github.com/KDE/dolphin-plugins/blob/d69ced47023c52078854e96bcdfa6ec3675251ec/git/fileviewgitplugin.cpp#L176

The git status command generates a lockfile automatically.
So in a way, by changing the folder you "manually" perform a git operation (unconsciously).

git status is locking because it is caching the status in the repository.
It cannot be disabled in git.

We could try to use the workaround number 2 of 
https://stackoverflow.com/questions/27706108/git-do-not-create-index-lock-for-read-only-operations
Comment 3 Justin Zobel 2020-10-26 02:58:34 UTC
(In reply to Nopeinger from comment #2)
> I can reproduce the generation of a lockfile but it gets destroyed instantly.
> 
> After looking into the code of the plugin, I think the lockfile gets created
> while searching for the stati of the files, see:
> https://github.com/KDE/dolphin-plugins/blob/
> d69ced47023c52078854e96bcdfa6ec3675251ec/git/fileviewgitplugin.cpp#L176
> 
> The git status command generates a lockfile automatically.
> So in a way, by changing the folder you "manually" perform a git operation
> (unconsciously).
> 
> git status is locking because it is caching the status in the repository.
> It cannot be disabled in git.
> 
> We could try to use the workaround number 2 of 
> https://stackoverflow.com/questions/27706108/git-do-not-create-index-lock-
> for-read-only-operations

Nopeinger would you care to try your hand at a patch to Dolphin to not use a lock file while doing read-only operations?
Comment 4 Bug Janitor Service 2020-10-27 16:53:29 UTC
A possibly relevant merge request was started @ https://invent.kde.org/sdk/dolphin-plugins/-/merge_requests/19
Comment 5 Elvis Angelaccio 2020-10-31 14:22:50 UTC
Git commit 31f46bf7b2cee0156bd57525b2f5e78d41578d7b by Elvis Angelaccio, on behalf of Sebastian Englbrecht.
Committed on 31/10/2020 at 14:15.
Pushed by elvisangelaccio into branch 'master'.

Git status does not generate index.lock

The git option (Note: not git status) --no-optional-locks prohibits the generation
of the lockfile in read-only operation, thus not blocking other e.g. manually typed commands.

https://bugs.kde.org/show_bug.cgi?id=363576

M  +1    -1    git/fileviewgitplugin.cpp

https://invent.kde.org/sdk/dolphin-plugins/commit/31f46bf7b2cee0156bd57525b2f5e78d41578d7b