sds/overcommit · error · RuntimeError

Unable to access git tree

Error message

Unable to access git tree

What it means

Error "Unable to access git tree" thrown in sds/overcommit.

Source

Thrown at lib/overcommit/hook/pre_commit/line_endings.rb:55

        line.gsub!(/#{config['eol']}/, '')

        # Detect any left over line-ending characters
        next unless line.end_with?("\n", "\r")

        messages_for_file << Overcommit::Hook::Message.new(
          :error,
          file_name,
          file.lineno,
          "#{file_name}:#{file.lineno}:#{line.inspect}"
        )
      end

      messages_for_file
    end

    def offending_files
      result = execute(%w[git ls-files --eol -z --], args: applicable_files)
      raise 'Unable to access git tree' unless result.success?

      result.stdout.split("\0").map do |file_info|
        info, path = file_info.split("\t")
        i = info.split.first
        next if i == 'l/-text' # ignore binary files
        next if i == "l/#{eol}"

        path
      end.compact
    end

    def eol
      @eol ||=  case config['eol']
                when "\n"
                  'lf'
                when "\r\n"
                  'crlf'
                else

View on GitHub (pinned to fee0cd74b2)

Solutions

  1. Ensure the hook runs inside a valid git repository with a readable HEAD tree; run `git ls-tree HEAD` to verify.
  2. If HEAD does not exist yet (no commits), make an initial commit or disable the LineEndings hook until one exists.

When it happens

Trigger: Thrown at lib/overcommit/hook/pre_commit/line_endings.rb:55 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/ef616fb943708bd9. Report an issue: GitHub.