code: def _test_save_all(path, repocls):
      ds = get_convoluted_situation(path, repocls)
      orig_status = ds.repo.status(untracked="all")
      # TODO test the results when the are crafted
      res = ds.repo.save()
      # make sure we get a 'delete' result for each deleted file
      eq_(
          set(r["path"] for r in res if r["action"] == "delete"),
          {
              str(k)
              for k, v in orig_status.items()
              if k.name in ("file_deleted", "file_staged_deleted")
          },
      )
      saved_status = ds.repo.status(untracked="all")
      # we still have an entry for everything that did not get deleted
      # intentionally
      eq_(
          len(
              [
                  f
                  for f, p in orig_status.items()
                  if not f.match("*_deleted")
              ]
          ),
          len(saved_status),
      )
      # everything but subdataset entries that contain untracked content,
      # or modified subsubdatasets is now clean, a repo simply doesn touch
      # other repos' private parts
      for f, p in saved_status.items():
          if p.get("state", None) != "clean":
              assert f.match("subds_modified"), f
  
      # Since we already have rich filetree, now save at dataset level
      # recursively and introspect some known gotchas
      resr = ds.save(recursive=True)
  
      # File within subdataset got committed to git-annex, which was not the
      # case for GitRepo parent https://github.com/datalad/datalad/issues/7351
      assert_in_results(
          resr,
          status="ok",
          path=str(
              ds.pathobj
              / "subds_modified"
              / "someds"
              / "dirtyds"
              / "file_untracked"
          ),
          # if key is None -- was committed to git which should have not happened!
          key="MD5E-s14--2c320e0c56ed653384a926292647f226",
      )
  
      return ds
  
file_path: datalad/datalad/support/tests/test_repo_save.py
imports: import shutil
  from datalad.api import create
  from datalad.distribution.dataset import Dataset
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.gitrepo import GitRepo
  from datalad.tests.utils_pytest import assert_in, assert_in_results, assert_not_in, assert_repo_status, create_tree, eq_, get_annexstatus, get_convoluted_situation, known_failure_windows, slow, with_tempfile
  from datalad.utils import on_windows, rmtree
label_desc: Use image node_id 2 for calling a global function with example usage: _test_save_all(path, repocls) and returns: ds