code: def test_diff_rsync_syntax(path=None):
      # three nested datasets
      ds = Dataset(path).create()
      subds = ds.create("sub")
      subsubds = subds.create(Path("subdir", "deep"))
      justtop = ds.diff(
          fr=PRE_INIT_COMMIT_SHA, path="sub", result_renderer="disabled"
      )
      # we only get a single result, the subdataset in question
      assert_result_count(justtop, 1)
      assert_result_count(justtop, 1, type="dataset", path=subds.path)
      # now with "peak inside the dataset" syntax
      inside = ds.diff(
          fr=PRE_INIT_COMMIT_SHA,
          path="sub" + os.sep,
          result_renderer="disabled",
      )
      # we get both subdatasets, but nothing else inside the nested one
      assert_result_count(inside, 2, type="dataset")
      assert_result_count(inside, 1, type="dataset", path=subds.path)
      assert_result_count(inside, 1, type="dataset", path=subsubds.path)
      assert_result_count(
          inside, 0, type="file", parentds=subsubds.path
      )
      # if we point to the subdir in 'sub' the reporting wrt the subsubds
      # doesn't change. It is merely a path constraint within the queried
      # subds, but because the subsubds is still underneath it, nothing changes
      inside_subdir = ds.diff(
          fr=PRE_INIT_COMMIT_SHA,
          path=op.join("sub", "subdir"),
          result_renderer="disabled",
      )
      assert_result_count(inside_subdir, 2, type="dataset")
      assert_result_count(
          inside_subdir, 1, type="dataset", path=subds.path
      )
      assert_result_count(
          inside_subdir, 1, type="dataset", path=subsubds.path
      )
      assert_result_count(
          inside_subdir, 0, type="file", parentds=subsubds.path
      )
      # but the rest is different (e.g. all the stuff in .datalad is gone)
      neq_(inside, inside_subdir)
      # just for completeness, we get more when going full recursive
      rec = ds.diff(
          fr=PRE_INIT_COMMIT_SHA,
          recursive=True,
          path="sub" + os.sep,
          result_renderer="disabled",
      )
      assert len(inside) < len(rec)
  
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 8 for calling a global function with example usage: test_diff_rsync_syntax(path) without return types