diff --git a/pre_commit/resources/hook-tmpl b/pre_commit/resources/hook-tmpl
index cb25ec5..f455ca3 100755
--- a/pre_commit/resources/hook-tmpl
+++ b/pre_commit/resources/hook-tmpl
@@ -123,14 +123,15 @@ def _pre_push(stdin):
         elif remote_sha != Z40 and _rev_exists(remote_sha):
             opts = ('--origin', local_sha, '--source', remote_sha)
         else:
-            # First ancestor not found in remote
-            first_ancestor = subprocess.check_output((
-                'git', 'rev-list', '--max-count=1', '--topo-order',
-                '--reverse', local_sha, '--not', '--remotes={}'.format(remote),
+            # ancestors not found in remote
+            ancestors = subprocess.check_output((
+                'git', 'rev-list', local_sha, '--topo-order', '--reverse',
+                '--not', '--remotes={}'.format(remote),
             )).decode().strip()
-            if not first_ancestor:
+            if not ancestors:
                 continue
             else:
+                first_ancestor = ancestors.splitlines()[0]
                 cmd = ('git', 'rev-list', '--max-parents=0', local_sha)
                 roots = set(subprocess.check_output(cmd).decode().splitlines())
                 if first_ancestor in roots:

Pre-push not getting all relevant files
I seem to experiencing the case where the list of files passed to my hooks pre-push are only from the most recent commit.
diff --git a/tests/commands/install_uninstall_test.py b/tests/commands/install_uninstall_test.py
index 40d9bee..76ab14f 100644
--- a/tests/commands/install_uninstall_test.py
+++ b/tests/commands/install_uninstall_test.py
@@ -527,11 +527,13 @@ def test_pre_push_integration_failing(tempdir_factory, store):
         install(Runner(path, C.CONFIG_FILE), store, hook_type='pre-push')
         # commit succeeds because pre-commit is only installed for pre-push
         assert _get_commit_output(tempdir_factory)[0] == 0
+        assert _get_commit_output(tempdir_factory, touch_file='zzz')[0] == 0
 
         retc, output = _get_push_output(tempdir_factory)
         assert retc == 1
         assert 'Failing hook' in output
         assert 'Failed' in output
+        assert 'foo zzz' in output  # both filenames should be printed
         assert 'hookid: failing_hook' in output
 
 

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest cython distro pytest-cov pytest-xdist pytest-mock pytest-asyncio pytest-bdd pytest-benchmark pytest-randomly responses mock hypothesis freezegun trustme requests-mock requests tomlkit
apt-get update apt-get install -y gcc
3.9
requirements-dev.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
aspy.yaml==1.3.0
attrs==25.3.0
cached-property==2.0.1
certifi==2025.1.31
cffi==1.17.1
cfgv==3.4.0
charset-normalizer==3.4.1
coverage==7.8.0
cryptography==44.0.2
Cython==3.0.12
distlib==0.3.9
distro==1.9.0
exceptiongroup==1.2.2
execnet==2.1.1
filelock==3.18.0
flake8==7.2.0
freezegun==1.5.1
gherkin-official==29.0.0
hypothesis==6.130.5
identify==2.6.9
idna==3.10
importlib_metadata==8.6.1
iniconfig==2.1.0
Mako==1.3.9
MarkupSafe==3.0.2
mccabe==0.7.0
mock==5.2.0
nodeenv==1.9.1
packaging==24.2
parse==1.20.2
parse_type==0.6.4
platformdirs==4.3.7
pluggy==1.5.0
-e git+https://github.com/pre-commit/pre-commit.git@c0b1f2ff25b53efcfa03098f2b4cb90ded905063#egg=pre_commit
py-cpuinfo==9.0.0
pycodestyle==2.13.0
pycparser==2.22
pyflakes==3.3.1
pytest==8.3.5
pytest-asyncio==0.26.0
pytest-bdd==8.1.0
pytest-benchmark==5.1.0
pytest-cov==6.0.0
pytest-env==1.1.5
pytest-mock==3.14.0
pytest-randomly==3.16.0
pytest-xdist==3.6.1
python-dateutil==2.9.0.post0
PyYAML==6.0.2
requests==2.32.3
requests-mock==1.12.1
responses==0.25.7
six==1.17.0
sortedcontainers==2.4.0
toml==0.10.2
tomli==2.2.1
tomlkit==0.13.2
trustme==1.2.1
typing_extensions==4.13.0
urllib3==2.3.0
virtualenv==20.29.3
zipp==3.21.0

name: pre-commit
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - aspy-yaml==1.3.0
      - attrs==25.3.0
      - cached-property==2.0.1
      - certifi==2025.1.31
      - cffi==1.17.1
      - cfgv==3.4.0
      - charset-normalizer==3.4.1
      - coverage==7.8.0
      - cryptography==44.0.2
      - cython==3.0.12
      - distlib==0.3.9
      - distro==1.9.0
      - exceptiongroup==1.2.2
      - execnet==2.1.1
      - filelock==3.18.0
      - flake8==7.2.0
      - freezegun==1.5.1
      - gherkin-official==29.0.0
      - hypothesis==6.130.5
      - identify==2.6.9
      - idna==3.10
      - importlib-metadata==8.6.1
      - iniconfig==2.1.0
      - mako==1.3.9
      - markupsafe==3.0.2
      - mccabe==0.7.0
      - mock==5.2.0
      - nodeenv==1.9.1
      - packaging==24.2
      - parse==1.20.2
      - parse-type==0.6.4
      - platformdirs==4.3.7
      - pluggy==1.5.0
      - py-cpuinfo==9.0.0
      - pycodestyle==2.13.0
      - pycparser==2.22
      - pyflakes==3.3.1
      - pytest==8.3.5
      - pytest-asyncio==0.26.0
      - pytest-bdd==8.1.0
      - pytest-benchmark==5.1.0
      - pytest-cov==6.0.0
      - pytest-env==1.1.5
      - pytest-mock==3.14.0
      - pytest-randomly==3.16.0
      - pytest-xdist==3.6.1
      - python-dateutil==2.9.0.post0
      - pyyaml==6.0.2
      - requests==2.32.3
      - requests-mock==1.12.1
      - responses==0.25.7
      - six==1.17.0
      - sortedcontainers==2.4.0
      - toml==0.10.2
      - tomli==2.2.1
      - tomlkit==0.13.2
      - trustme==1.2.1
      - typing-extensions==4.13.0
      - urllib3==2.3.0
      - virtualenv==20.29.3
      - zipp==3.21.0
prefix: /opt/conda/envs/pre-commit

tests/commands/install_uninstall_test.py::test_pre_push_integration_failing
tests/commands/install_uninstall_test.py::test_environment_not_sourced tests/commands/install_uninstall_test.py::test_install_in_submodule_and_run
tests/commands/install_uninstall_test.py::test_uninstall_restores_legacy_hooks tests/commands/install_uninstall_test.py::test_install_pre_commit_and_run_custom_path tests/commands/install_uninstall_test.py::test_replace_old_commit_script tests/commands/install_uninstall_test.py::test_install_disallow_mising_config tests/commands/install_uninstall_test.py::test_pre_push_new_upstream tests/commands/install_uninstall_test.py::test_commit_msg_legacy tests/commands/install_uninstall_test.py::test_pre_push_integration_accepted tests/commands/install_uninstall_test.py::test_install_overwrite_no_existing_hooks tests/commands/install_uninstall_test.py::test_install_temporarily_allow_mising_config tests/commands/install_uninstall_test.py::test_install_in_worktree_and_run tests/commands/install_uninstall_test.py::test_is_script tests/commands/install_uninstall_test.py::test_uninstall_doesnt_remove_not_our_hooks tests/commands/install_uninstall_test.py::test_install_pre_commit tests/commands/install_uninstall_test.py::test_install_refuses_core_hookspath tests/commands/install_uninstall_test.py::test_failing_hooks_returns_nonzero tests/commands/install_uninstall_test.py::test_install_hooks_directory_not_present tests/commands/install_uninstall_test.py::test_pre_push_force_push_without_fetch tests/commands/install_uninstall_test.py::test_install_hooks_command tests/commands/install_uninstall_test.py::test_install_hooks_dead_symlink tests/commands/install_uninstall_test.py::test_install_existing_hooks_no_overwrite tests/commands/install_uninstall_test.py::test_commit_msg_integration_passing tests/commands/install_uninstall_test.py::test_is_previous_pre_commit tests/commands/install_uninstall_test.py::test_installed_from_venv tests/commands/install_uninstall_test.py::test_install_pre_commit_and_run tests/commands/install_uninstall_test.py::test_is_not_script tests/commands/install_uninstall_test.py::test_pre_push_integration_empty_push tests/commands/install_uninstall_test.py::test_installs_hooks_with_hooks_True tests/commands/install_uninstall_test.py::test_install_existing_hook_no_overwrite_idempotent tests/commands/install_uninstall_test.py::test_uninstall_does_not_blow_up_when_not_there tests/commands/install_uninstall_test.py::test_install_allow_mising_config tests/commands/install_uninstall_test.py::test_install_idempotent tests/commands/install_uninstall_test.py::test_unicode_merge_commit_message tests/commands/install_uninstall_test.py::test_pre_push_legacy tests/commands/install_uninstall_test.py::test_uninstall tests/commands/install_uninstall_test.py::test_install_overwrite tests/commands/install_uninstall_test.py::test_commit_msg_integration_failing tests/commands/install_uninstall_test.py::test_failing_existing_hook_returns_1 tests/commands/install_uninstall_test.py::test_commit_am
pre_commit/resources/hook-tmpl
pre_commit/resources/hook-tmpl