Exceptions in file monitor module when running in a git worktree #545

weo opened this Issue Jan 27, 2016 · 0 comments


None yet
1 participant

weo commented Jan 27, 2016

In a worktree, ".git" is not a directory but a file. This causes an exception in the file monitor module because _refresh_watches() collects only directories.

Traceback (most recent call last):
File "/opt/git-cola/share/git-cola/lib/cola/fsmonitor.py", line 152, in run
File "/opt/git-cola/share/git-cola/lib/cola/fsmonitor.py", line 207, in refresh
self._git_dir_wd = self._git_dir_wd_map[self._git_dir]
KeyError: u'/home/weo/Projects/MyProject/.git'

davvid added a commit to davvid/git-cola that referenced this issue Jan 27, 2016

fsmonitor: use the resolved git repository path
git_dir() is the worktree's .git path, but it is not necessarily
the path where refs/ objects/ and friends are found.  When using
submodules, for example, .git is a file that contains the path
to the actual git repository.

The fsmonitor registers the git path so that it can notice
changes.  When doing so it ignores ENOTDIR errors to avoid a
race condition, but it also silently ignores the request to
watch the .git-file.

This later causes an exception when asking for the git path:

	File "cola/fsmonitor.py", line 207, in refresh
	self._git_dir_wd = self._git_dir_wd_map[self._git_dir]
	KeyError: u'/home/david/src/git/.git'

Fix the logic by using git_path() when setting up the monitor so
that the real git repository path is used.

Closes #545
Reported-by: Wolfgang Ocker <weo@reccoware.de>
Signed-off-by: David Aguilar <davvid@gmail.com>

@davvid davvid closed this in #546 Jan 27, 2016

davvid added a commit that referenced this issue Jan 29, 2016

fsmonitor: use git_path() in the win32 implementation too
Apply the same fix to the Win32 monitor as was done in

Related-to: #545
Signed-off-by: David Aguilar <davvid@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment