sds/overcommit · error · RuntimeError
Unable to access git index
Error message
Unable to access git index
What it means
Error "Unable to access git index" thrown in sds/overcommit.
Source
Thrown at lib/overcommit/hook/pre_commit/execute_permissions.rb:58
)
end.compact
end
private
def extract_from_git_tree(file_modes)
result = execute(%w[git ls-tree HEAD --], args: applicable_files)
raise 'Unable to access git tree' unless result.success?
result.stdout.split("\n").each do |line|
mode, _type, _hash, file = line.split(/\s+/, 4)
file_modes[file] = mode
end
end
def extract_from_git_index(file_modes)
result = execute(%w[git diff --raw --cached --no-color --], args: applicable_files)
raise 'Unable to access git index' unless result.success?
result.stdout.split("\n").each do |line|
_old_mode, new_mode, _old_hash, _new_hash, _status, file = line.split(/\s+/, 6)
file_modes[file] = new_mode
end
end
# Check if the 1st bit is toggled, indicating execute permissions.
#
# Git tracks only execute permissions, not individual read/write/execute
# permissions for user, group, and other, since that concept does not exist
# on all operating systems. If any of the user/group/other permissions
# have the executable bit set, they all will. Thus we check the first bit.
def execute_permissions?(mode)
(mode.to_i(8) & 1) == 1
end
end
endView on GitHub (pinned to fee0cd74b2)
Solutions
- Ensure the git index is readable (`.git/index` exists and is not locked); run `git status` to verify repository health.
- Remove a stale `.git/index.lock` left by a crashed git process, then rerun the hook.
When it happens
Trigger: Thrown at lib/overcommit/hook/pre_commit/execute_permissions.rb:58 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of sds/overcommit@fee0cd74b2 (2026-08-23).
Data as JSON: /api/errors/5bd6e6c807fa41f8.
Report an issue: GitHub.