code: def test_unpushed_state_detection(origpath=None, clonepath=None):
      origds = Dataset(origpath).create()
      # always test in annex mode
      tester = lambda x: _detect_unpushed_revs(x, True)
  
      origrepo = origds.repo
      # this is still a unique repo, all payload branches are
      # unpushed
      eq_([DEFAULT_BRANCH], tester(origrepo))
      origrepo.call_git(["checkout", "-b", "otherbranch"])
      eq_([DEFAULT_BRANCH, "otherbranch"], tester(origrepo))
      # let's advance the state by one
      (origds.pathobj / "file1").write_text("some text")
      origds.save()
      # same picture
      eq_([DEFAULT_BRANCH, "otherbranch"], tester(origrepo))
      # back to original branch
      origrepo.call_git(["checkout", DEFAULT_BRANCH])
  
      # now lets clone
      cloneds = clone(origds, clonepath)
      clonerepo = cloneds.repo
      # right after the clone there will be no unpushed changes
      eq_([], tester(clonerepo))
      # even with more than one branch in the clone
      clonerepo.call_git(
          ["checkout", "-t", f"{DEFAULT_REMOTE}/otherbranch"]
      )
      eq_([], tester(clonerepo))
  
      # let's advance the local state now
      (cloneds.pathobj / "file2").write_text("some other text")
      cloneds.save()
      # only the modified branch is detected
      eq_(["otherbranch"], tester(clonerepo))
      # a push will bring things into the clear
      cloneds.push(to=DEFAULT_REMOTE)
      eq_([], tester(clonerepo))
  
      # now detach HEAD, should work and not somehow require a branch
      cloneds.repo.call_git(["reset", "--hard", "HEAD~1"])
      # we have this state
      eq_([], tester(clonerepo))
  
imports: import os
  import os.path
  from pathlib import Path
  from unittest.mock import patch
  from datalad.api import Dataset, clone, create, drop
  from datalad.distributed.drop import _detect_nondead_annex_at_remotes, _detect_unpushed_revs
  from datalad.support.exceptions import IncompleteResultsError, NoDatasetFound
  from datalad.support.gitrepo import GitRepo
  from datalad.tests.utils_pytest import DEFAULT_BRANCH, DEFAULT_REMOTE, OBSCURE_FILENAME, assert_in, assert_in_results, assert_raises, assert_repo_status, assert_result_count, assert_status, eq_, get_deeply_nested_structure, known_failure_githubci_win, nok_, ok_, with_tempfile
  from datalad.utils import chpwd
label_desc: Use image node_id 5 for calling a global function with example usage: test_unpushed_state_detection(origpath, clonepath) without return types