parameters: (tree=None)
docstring: Context manager for setting GIT_INDEX_FILE to a temporary file and deleting
    the file afterward.
docstring_summary: Context manager for setting GIT_INDEX_FILE to a temporary file and deleting
    the file afterward.
docstring_tokens: Context manager for setting GIT_INDEX_FILE to a temporary file and deleting the file afterward .
function: def temporary_index_file(tree=None):
      """Context manager for setting GIT_INDEX_FILE to a temporary file and deleting
    the file afterward."""
      index_path = create_temporary_index(tree)
      old_index_path = os.environ.get('GIT_INDEX_FILE')
      os.environ['GIT_INDEX_FILE'] = index_path
      try:
          yield
      finally:
          if old_index_path is None:
              del os.environ['GIT_INDEX_FILE']
          else:
              os.environ['GIT_INDEX_FILE'] = old_index_path
          os.remove(index_path)
function_tokens: def temporary_index_file ( tree = None ) : index_path = create_temporary_index ( tree ) old_index_path = os . environ . get ( 'GIT_INDEX_FILE' ) os . environ [ 'GIT_INDEX_FILE' ] = index_path try : yield finally : if old_index_path is None : del os . environ [ 'GIT_INDEX_FILE' ] else : os . environ [ 'GIT_INDEX_FILE' ] = old_index_path os . remove ( index_path )