code: def test_gitrepo_push_default_first_kludge(path=None):
      path = Path(path)
      repo_a = GitRepo(path / "a", bare=True)
      repo_b = GitRepo.clone(repo_a.path, str(path / "b"))
  
      (repo_b.pathobj / "foo").write_text("foo")
      repo_b.save()
  
      # push() usually pushes all refspecs in one go.
      with swallow_logs(new_level=logging.DEBUG) as cml:
          res_oneshot = repo_b.push(
              remote=DEFAULT_REMOTE,
              refspec=[
                  DEFAULT_BRANCH + ":b-oneshot",
                  DEFAULT_BRANCH + ":a-oneshot",
                  DEFAULT_BRANCH + ":c-oneshot",
              ],
          )
      cmds_oneshot = [
          ln
          for ln in cml.out.splitlines()
          if "Run" in ln and "push" in ln and DEFAULT_BRANCH in ln
      ]
      eq_(len(cmds_oneshot), 1)
      assert_in(":a-oneshot", cmds_oneshot[0])
      assert_in(":b-oneshot", cmds_oneshot[0])
      assert_in(":c-oneshot", cmds_oneshot[0])
      eq_(len(res_oneshot), 3)
  
      # But if datalad-push-default-first is set...
      cfg_var = f"remote.{DEFAULT_REMOTE}.datalad-push-default-first"
      repo_b.config.set(cfg_var, "true", scope="local")
      with swallow_logs(new_level=logging.DEBUG) as cml:
          res_twoshot = repo_b.push(
              remote=DEFAULT_REMOTE,
              refspec=[
                  DEFAULT_BRANCH + ":b-twoshot",
                  DEFAULT_BRANCH + ":a-twoshot",
                  DEFAULT_BRANCH + ":c-twoshot",
              ],
          )
      cmds_twoshot = [
          ln
          for ln in cml.out.splitlines()
          if "Run" in ln and "push" in ln and DEFAULT_BRANCH in ln
      ]
      # ... there are instead two git-push calls.
      eq_(len(cmds_twoshot), 2)
      # The first is for the first item of the refspec.
      assert_in(":b-twoshot", cmds_twoshot[0])
      assert_not_in(":b-twoshot", cmds_twoshot[1])
      # The remaining items are in the second call.
      assert_in(":a-twoshot", cmds_twoshot[1])
      assert_in(":c-twoshot", cmds_twoshot[1])
      assert_not_in(":c-twoshot", cmds_twoshot[0])
      assert_not_in(":a-twoshot", cmds_twoshot[0])
      # The result returned by push() has the same number of records, though.
      eq_(len(res_twoshot), 3)
      # The configuration variable is removed afterward.
      assert_false(repo_b.config.get(cfg_var))
  
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 49 for calling a global function with example usage: test_gitrepo_push_default_first_kludge(path) without return types