code: def test_GitRepo_ssh_push(repo_path=None, remote_path=None):
      from datalad import ssh_manager
  
      remote_repo = GitRepo(remote_path, create=True)
      url = _path2localsshurl(remote_path)
      socket_path = op.join(
          str(ssh_manager.socket_dir),
          get_connection_hash("datalad-test"),
      )
      repo = GitRepo(repo_path, create=True)
      repo.add_remote("ssh-remote", url)
  
      # modify local repo:
      repo.checkout("ssh-test", ["-b"])
      with open(op.join(repo.path, "ssh_testfile.dat"), "w") as f:
          f.write("whatever")
      repo.add("ssh_testfile.dat")
      repo.commit("ssh_testfile.dat added.")
  
      # file is not known to the remote yet:
      assert_not_in("ssh_testfile.dat", remote_repo.get_indexed_files())
  
      # push changes:
      pushed = list(repo.push(remote="ssh-remote", refspec="ssh-test"))
      # test PushInfo
      assert_in("refs/heads/ssh-test", [p["from_ref"] for p in pushed])
      assert_in("refs/heads/ssh-test", [p["to_ref"] for p in pushed])
  
      # the connection is known to the SSH manager, since fetch() requested it:
      assert_in(socket_path, list(map(str, ssh_manager._connections)))
      # and socket was created:
      ok_(op.exists(socket_path))
  
      # remote now knows the changes:
      assert_in("ssh-test", remote_repo.get_branches())
      assert_in("ssh_testfile.dat", remote_repo.get_files("ssh-test"))
  
      # amend to make it require "--force":
      repo.commit("amended", options=["--amend"])
      # push without --force should yield an error:
      res = repo.push(remote="ssh-remote", refspec="ssh-test")
      assert_in_results(
          res,
          from_ref="refs/heads/ssh-test",
          to_ref="refs/heads/ssh-test",
          operations=["rejected", "error"],
          note="[rejected] (non-fast-forward)",
          remote="ssh-remote",
      )
      # now push using force:
      repo.push(remote="ssh-remote", refspec="ssh-test", force=True)
      # correct commit message in remote:
      assert_in(
          "amended",
          remote_repo.format_commit(
              "%s",
              list(remote_repo.get_branch_commits_("ssh-test"))[-1],
          ),
      )
  
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 21 for calling a global function with example usage: test_GitRepo_ssh_push(repo_path, remote_path) without return types