code: def test_rerun_invalid_merge_run_commit(path=None):
      ds = Dataset(path).create()
      ds.run("echo foo >>foo")
      ds.run("echo invalid >>invalid")
      run_msg = last_commit_msg(ds.repo)
      run_hexsha = ds.repo.get_hexsha()
      ds.repo.call_git(["reset", "--hard", DEFAULT_BRANCH + "~"])
      with open(op.join(ds.path, "non-run"), "w") as nrfh:
          nrfh.write("non-run")
      ds.save()
      # Assign two parents to the invalid run commit.
      commit = ds.repo.call_git_oneline(
          [
              "commit-tree",
              run_hexsha + "^{tree}",
              "-m",
              run_msg,
              "-p",
              run_hexsha + "^",
              "-p",
              ds.repo.get_hexsha(),
          ]
      )
      ds.repo.call_git(["reset", "--hard", commit])
      hexsha_orig = ds.repo.get_hexsha()
      with swallow_logs(new_level=logging.WARN) as cml:
          ds.rerun(since="")
          assert_in(
              "has run information but is a merge commit", cml.out
          )
      eq_(
          len(
              ds.repo.get_revisions(hexsha_orig + ".." + DEFAULT_BRANCH)
          ),
          1,
      )
  
imports: import logging
  import os.path
  import sys
  from io import StringIO
  from os import remove
  import pytest
  from unittest.mock import patch
  from datalad.api import install, run
  from datalad.core.local.run import run_command
  from datalad.core.local.tests.test_run import last_commit_msg
  from datalad.distribution.dataset import Dataset
  from datalad.local.rerun import diff_revision, get_run_info, new_or_modified
  from datalad.support.exceptions import CommandError, IncompleteResultsError
  from datalad.support.gitrepo import GitRepo
  from datalad.tests.utils_pytest import DEFAULT_BRANCH, DEFAULT_REMOTE, SkipTest, assert_dict_equal, assert_false, assert_in, assert_in_results, assert_not_in, assert_not_in_results, assert_raises, assert_repo_status, assert_result_count, assert_status, create_tree, eq_, known_failure_windows, neq_, ok_, ok_exists, ok_file_has_content, ok_file_under_git, skip_if_adjusted_branch, slow, swallow_logs, swallow_outputs, with_tempfile, with_tree
  from datalad.utils import Path, chpwd, on_windows
label_desc: Use image node_id 9 for calling a global function with example usage: test_rerun_invalid_merge_run_commit(path) without return types