code: def git_items(directory, submodules=False):
      """
      Returns list of paths for all files known to git within a `directory`.
  
      Args:
          directory:
              Must be somewhere within a git checkout.
          submodules:
              If true we also include git submodules.
  
      Returns:
          A list of paths for all files known to git within `directory`. Each
          path is relative to `directory`. `directory` must be somewhere within a
          git checkout.
  
      We run a `git ls-files` command internally.
  
      This function can be useful for the `fn_sdist()` callback.
      """
      command = "cd " + directory + " && git ls-files"
      if submodules:
          command += " --recurse-submodules"
      log1(f"Running {command=}")
      text = subprocess.check_output(command, shell=True)
      ret = []
      for path in text.decode("utf8").strip().split("\n"):
          path2 = os.path.join(directory, path)
          # Sometimes git ls-files seems to list empty/non-existant directories
          # within submodules.
          #
          if not os.path.exists(path2):
              log2(
                  f"Ignoring git ls-files item that does not exist: {path2}"
              )
          elif os.path.isdir(path2):
              log2(
                  f"Ignoring git ls-files item that is actually a directory: {path2}"
              )
          else:
              ret.append(path)
      return ret
  
imports: import base64
  import glob
  import hashlib
  import inspect
  import io
  import os
  import platform
  import re
  import shutil
  import site
  import setuptools
  import subprocess
  import sys
  import sysconfig
  import tarfile
  import textwrap
  import time
  import zipfile
  import wdev
label_desc: Use image node_id 4 for calling a global function with example usage: git_items(directory, submodules) and returns: ret