fix(#1720): .git watch only FETCH_HEAD, HEAD, HEAD.lock, config, index (#1732)

* fix(#1720): .git watch only HEAD, config and index

* fix(#1720): .git watch only FETCH_HEAD, HEAD, HEAD.lock, config, index
This commit is contained in:
Alexander Courtis
2022-11-12 14:38:33 +11:00
committed by GitHub
parent 7e892767bd
commit bcb2a5a80d
3 changed files with 20 additions and 7 deletions

View File

@@ -11,6 +11,16 @@ local M = {
cwd_to_project_root = {},
}
-- Files under .git that should result in a reload when changed.
-- Utilities (like watchman) can also write to this directory (often) and aren't useful for us.
local WATCHED_FILES = {
"FETCH_HEAD", -- remote ref
"HEAD", -- local ref
"HEAD.lock", -- HEAD will not always be updated e.g. revert
"config", -- user config
"index", -- staging area
}
function M.reload()
if not M.config.git.enable then
return {}
@@ -149,7 +159,7 @@ function M.load_project_status(cwd)
end)
end
watcher = Watcher:new(utils.path_join { project_root, ".git" }, callback, {
watcher = Watcher:new(utils.path_join { project_root, ".git" }, WATCHED_FILES, callback, {
project_root = project_root,
})
end