sds/overcommit · error · Overcommit::Exceptions::GitSubmoduleError

Unable to read submodule information from #{ref}:.gitmodules

Error message

Unable to read submodule information from #{ref}:.gitmodules file: #{e.message}

What it means

Error "Unable to read submodule information from #{ref}:.gitmodules file: #{e.message}" thrown in sds/overcommit.

Source

Thrown at lib/overcommit/git_repo.rb:273

      modules = []
      IniParse.parse(`git show #{ref}:.gitmodules 2> #{File::NULL}`).each do |section|
        # git < 1.8.5 does not update the .gitmodules file with submodule
        # changes, so when we are looking at the current state of the work tree,
        # we need to check if the submodule actually exists via another method,
        # since the .gitmodules file we parsed does not represent reality.
        if ref.nil? && GIT_VERSION < '1.8.5'
          result = Overcommit::Utils.execute(%W[
            git submodule status #{section['path']}
          ])
          next unless result.success?
        end

        modules << Submodule.new(section['path'], section['url'])
      end

      modules
    rescue IniParse::IniParseError => e
      raise Overcommit::Exceptions::GitSubmoduleError,
            "Unable to read submodule information from #{ref}:.gitmodules file: #{e.message}"
    end

    # Returns the names of all branches containing the given commit.
    #
    # @param commit_ref [String] git tree ref that resolves to a commit
    # @return [Array<String>] list of branches containing the given commit
    def branches_containing_commit(commit_ref)
      `git branch --column=dense --contains #{commit_ref}`.
        sub(/\((HEAD )?detached (from|at) .*?\)/, ''). # ignore detached HEAD
        split(/\s+/).
        reject { |s| s.empty? || s == '*' }
    end

    # Returns the name of the currently checked out branch.
    # @return [String]
    def current_branch
      `git symbolic-ref --short -q HEAD`.chomp

View on GitHub (pinned to fee0cd74b2)

Solutions

  1. Check that the `.gitmodules` file at the referenced commit exists and is valid git-config/ini syntax.
  2. Fix malformed submodule sections in `.gitmodules` (missing headers, unbalanced quotes, duplicate keys) and commit the correction.
  3. If the ref is wrong or missing, pass a valid ref that contains a .gitmodules file.

When it happens

Trigger: Thrown at lib/overcommit/git_repo.rb:273 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/4d50251ae9feceea. Report an issue: GitHub.