code: def test_path_diff(_path=None, linkpath=None):
      # do the setup on the real path, not the symlink, to have its
      # bugs not affect this test of status()
      ds = get_deeply_nested_structure(str(_path))
      if has_symlink_capability():
          # make it more complicated by default
          ut.Path(linkpath).symlink_to(_path, target_is_directory=True)
          path = linkpath
      else:
          path = _path
  
      ds = Dataset(path)
      if has_symlink_capability():
          assert ds.pathobj != ds.repo.pathobj
  
      plain_recursive = ds.diff(
          recursive=True, annex="all", result_renderer="disabled"
      )
      # check integrity of individual reports with a focus on how symlinks
      # are reported
      for res in plain_recursive:
          # anything that is an "intended" symlink should be reported
          # as such. In contrast, anything that is a symlink for mere
          # technical reasons (annex using it for something in some mode)
          # should be reported as the thing it is representing (i.e.
          # a file)
          if "link2" in str(res["path"]):
              assert res["type"] == "symlink", res
          else:
              assert res["type"] != "symlink", res
          # every item must report its parent dataset
          assert_in("parentds", res)
  
      # bunch of smoke tests
      # query of '.' is same as no path
      eq_(
          plain_recursive,
          ds.diff(
              path=".",
              recursive=True,
              annex="all",
              result_renderer="disabled",
          ),
      )
      # duplicate paths do not change things
      eq_(
          plain_recursive,
          ds.diff(
              path=[".", "."],
              recursive=True,
              annex="all",
              result_renderer="disabled",
          ),
      )
      # neither do nested paths
      if not "2.24.0" <= ds.repo.git_version < "2.25.0":
          # Release 2.24.0 contained a regression that was fixed with 072a231016
          # (2019-12-10).
          eq_(
              plain_recursive,
              ds.diff(
                  path=[".", "subds_modified"],
                  recursive=True,
                  annex="all",
                  result_renderer="disabled",
              ),
          )
      # when invoked in a subdir of a dataset it still reports on the full thing
      # just like `git status`, as long as there are no paths specified
      with chpwd(op.join(path, "directory_untracked")):
          plain_recursive = diff(
              recursive=True, annex="all", result_renderer="disabled"
          )
      # should be able to take absolute paths and yield the same
      # output
      eq_(
          plain_recursive,
          ds.diff(
              path=ds.path,
              recursive=True,
              annex="all",
              result_renderer="disabled",
          ),
      )
  
      # query for a deeply nested path from the top, should just work with a
      # variety of approaches
      rpath = op.join(
          "subds_modified",
          "subds_lvl1_modified",
          "{}_directory_untracked".format(OBSCURE_FILENAME),
      )
      apathobj = ds.pathobj / rpath
      apath = str(apathobj)
      for p in (rpath, apath, None):
          if p is None:
              # change into the realpath of the dataset and
              # query with an explicit path
              with chpwd(ds.path):
                  res = ds.diff(
                      path=op.join(".", rpath),
                      recursive=True,
                      annex="all",
                      result_renderer="disabled",
                  )
          else:
              res = ds.diff(
                  path=p,
                  recursive=True,
                  annex="all",
                  result_renderer="disabled",
              )
          assert_result_count(
              res,
              1,
              state="untracked",
              type="directory",
              refds=ds.path,
              # path always comes out a full path inside the queried dataset
              path=apath,
          )
  
      assert_result_count(
          ds.diff(recursive=True, result_renderer="disabled"),
          1,
          path=apath,
      )
      # limiting recursion will exclude this particular path
      assert_result_count(
          ds.diff(
              recursive=True,
              recursion_limit=1,
              result_renderer="disabled",
          ),
          0,
          path=apath,
      )
      # negative limit is unlimited limit
      eq_(
          ds.diff(
              recursive=True,
              recursion_limit=-1,
              result_renderer="disabled",
          ),
          ds.diff(recursive=True, result_renderer="disabled"),
      )
  
imports: import os
  import os.path
  from unittest.mock import patch
  import datalad.utils
  from datalad.api import create, diff, save
  from datalad.cmd import GitWitlessRunner, StdOutCapture
  from datalad.consts import PRE_INIT_COMMIT_SHA
  from datalad.distribution.dataset import Dataset
  from datalad.support.exceptions import NoDatasetFound
  from datalad.tests.utils_pytest import DEFAULT_BRANCH, OBSCURE_FILENAME, SkipTest, assert_in, assert_raises, assert_repo_status, assert_result_count, assert_status, chpwd, create_tree, eq_, get_deeply_nested_structure, has_symlink_capability, known_failure_githubci_win, neq_, ok_, with_tempfile
  from datalad.utils import Path
label_desc: Use image node_id 6 for calling a global function with example usage: test_path_diff(_path, linkpath) without return types