module Avm::Git::SubrepoCheck::Parent

def expected_parent_hash_uncached

def expected_parent_hash_uncached
  subrepo.local.rev_parse("#{last_file_change_rev}^")
end

def fix_parent

def fix_parent
  return if parent_result.success?
  info('  Fixing...')
  self.parent_hash = expected_parent_hash
  info_banner
end

def last_file_change_rev

def last_file_change_rev
  subrepo.local.command('log', '-n', '1', '--pretty=format:%H', '--',
                        subrepo.config_relative_path.to_path).execute!.strip
end

def parent_hash

def parent_hash
  subrepo.parent_commit_id
end

def parent_hash=(new_hash)

def parent_hash=(new_hash)
  subrepo.config.parent_commit_id = new_hash
  subrepo.write_config
end

def parent_hash_ok?

def parent_hash_ok?
  return false if expected_parent_hash.blank? || parent_hash.blank?
  expected_parent_hash == parent_hash
end

def parent_result_uncached

def parent_result_uncached
  ::Avm::Result.success_or_error(parent_hash_ok?,
                                 parent_hash.presence || blank_text)
end