code: def test_GitRepo_dirty(path=None):
      repo = GitRepo(path, create=True)
      ok_(not repo.dirty)
  
      # untracked file
      with open(op.join(path, "file1.txt"), "w") as f:
          f.write("whatever")
      ok_(repo.dirty)
      # staged file
      repo.add("file1.txt")
      ok_(repo.dirty)
      # clean again
      repo.commit("file1.txt added")
      ok_(not repo.dirty)
      # modify to be the same
      with open(op.join(path, "file1.txt"), "w") as f:
          f.write("whatever")
      ok_(not repo.dirty)
      # modified file
      with open(op.join(path, "file1.txt"), "w") as f:
          f.write("something else")
      ok_(repo.dirty)
      # clean again
      repo.add("file1.txt")
      repo.commit("file1.txt modified")
      ok_(not repo.dirty)
  
      # An empty directory doesn't count as dirty.
      os.mkdir(op.join(path, "empty"))
      ok_(not repo.dirty)
      # Neither does an empty directory with an otherwise empty directory.
      os.mkdir(op.join(path, "empty", "empty-again"))
      ok_(not repo.dirty)
  
      subm = GitRepo(repo.pathobj / "subm", create=True)
      (subm.pathobj / "subfile").write_text("")
      subm.save()
      repo.save()
      ok_(not repo.dirty)
      (subm.pathobj / "subfile").write_text("changed")
      ok_(repo.dirty)
  
      # User configuration doesn't affect .dirty's answer.
      repo.config.set("diff.ignoreSubmodules", "all", scope="local")
      ok_(repo.dirty)
      # GitRepo.commit currently can't handle this setting, so remove it for the
      # save() calls below.
      repo.config.unset("diff.ignoreSubmodules", scope="local")
      subm.save()
      repo.save()
      ok_(not repo.dirty)
  
      repo.config.set("status.showUntrackedFiles", "no", scope="local")
      create_tree(repo.path, {"untracked_dir": {"a": "a"}})
      ok_(repo.dirty)
  
imports: import logging
  import os
  import os.path
  import sys
  import pytest
  from datalad import get_encoding_info
  from datalad.cmd import StdOutCapture, StdOutErrCapture, WitlessRunner
  from datalad.support.exceptions import CommandError, FileNotInRepositoryError, InvalidGitRepositoryError, NoSuchPathError, PathKnownToRepositoryError
  from datalad.support.external_versions import external_versions
  from datalad.support.gitrepo import GitRepo, _normalize_path, normalize_paths, to_options
  from datalad.support.sshconnector import get_connection_hash
  from datalad.tests.utils_pytest import DEFAULT_BRANCH, DEFAULT_REMOTE, SkipTest, assert_cwd_unchanged, assert_equal, assert_false, assert_in, assert_in_results, assert_is_instance, assert_not_equal, assert_not_in, assert_raises, assert_repo_status, assert_true, create_tree, eq_, get_most_obscure_supported_name, integration, neq_, ok_, skip_if_no_network, skip_if_on_windows, skip_nomultiplex_ssh, slow, swallow_logs, with_tempfile, with_tree, xfail_buggy_annex_info
  from datalad.utils import Path, chpwd, getpwd, on_windows, rmtree
label_desc: Use image node_id 26 for calling a global function with example usage: test_GitRepo_dirty(path) without return types