code: def run_commit_hook(name, index, *args):
      
      hp = hook_path(name, index.repo.git_dir)
      if not os.access(hp, os.X_OK):
          return
  
      env = os.environ.copy()
      env['GIT_INDEX_FILE'] = safe_decode(index.path) if PY3 else safe_encode(index.path)
      env['GIT_EDITOR'] = ':'
      try:
          cmd = subprocess.Popen([hp] + list(args),
                                 env=env,
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE,
                                 cwd=index.repo.working_dir,
                                 close_fds=is_posix,
                                 creationflags=PROC_CREATIONFLAGS,)
      except Exception as ex:
          raise HookExecutionError(hp, ex)
      else:
          stdout = []
          stderr = []
          handle_process_output(cmd, stdout.append, stderr.append, finalize_process)
          stdout = ''.join(stdout)
          stderr = ''.join(stderr)
          if cmd.returncode != 0:
              stdout = force_text(stdout, defenc)
              stderr = force_text(stderr, defenc)
              raise HookExecutionError(hp, cmd.returncode, stderr, stdout)
docs: Run the commit hook of the given name. Silently ignores hooks that do not exist.
      :param name: name of hook, like 'pre-commit'
      :param index: IndexFile instance
      :param args: arguments passed to hook file
      :raises HookExecutionError: