From b285cccb19e00d213cc3147e805084a97b6f4c6b Mon Sep 17 00:00:00 2001 From: Paul Tarjan Date: Fri, 26 Dec 2025 14:57:28 -0700 Subject: [PATCH 01/11] use git cat-file -e instead of git rev-list in _rev_exists fixes #3604 --- pre_commit/commands/hook_impl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pre_commit/commands/hook_impl.py b/pre_commit/commands/hook_impl.py index de5c8f34..ddfac519 100644 --- a/pre_commit/commands/hook_impl.py +++ b/pre_commit/commands/hook_impl.py @@ -111,7 +111,7 @@ def _ns( def _rev_exists(rev: str) -> bool: - return not subprocess.call(('git', 'rev-list', '--quiet', rev)) + return subprocess.call(('git', 'cat-file', '-e', rev)) == 0 def _pre_push_ns( From 5a4235c6f070398f2630c6475aae2ac6a193868a Mon Sep 17 00:00:00 2001 From: Paul Tarjan Date: Fri, 26 Dec 2025 15:09:14 -0700 Subject: [PATCH 02/11] remove == 0 --- pre_commit/commands/hook_impl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pre_commit/commands/hook_impl.py b/pre_commit/commands/hook_impl.py index ddfac519..0c72d8d5 100644 --- a/pre_commit/commands/hook_impl.py +++ b/pre_commit/commands/hook_impl.py @@ -111,7 +111,7 @@ def _ns( def _rev_exists(rev: str) -> bool: - return subprocess.call(('git', 'cat-file', '-e', rev)) == 0 + return subprocess.call(('git', 'cat-file', '-e', rev)) def _pre_push_ns( From a26fb3ba02a00fe7023608ee53fa77436831bef5 Mon Sep 17 00:00:00 2001 From: Paul Tarjan Date: Fri, 26 Dec 2025 15:11:03 -0700 Subject: [PATCH 03/11] Revert "remove == 0" This reverts commit 5a4235c6f070398f2630c6475aae2ac6a193868a. --- pre_commit/commands/hook_impl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pre_commit/commands/hook_impl.py b/pre_commit/commands/hook_impl.py index 0c72d8d5..ddfac519 100644 --- a/pre_commit/commands/hook_impl.py +++ b/pre_commit/commands/hook_impl.py @@ -111,7 +111,7 @@ def _ns( def _rev_exists(rev: str) -> bool: - return subprocess.call(('git', 'cat-file', '-e', rev)) + return subprocess.call(('git', 'cat-file', '-e', rev)) == 0 def _pre_push_ns( From ed0d44b665eb0af6931b7b26fff97f11e70969c2 Mon Sep 17 00:00:00 2001 From: Paul Tarjan Date: Fri, 26 Dec 2025 15:15:34 -0700 Subject: [PATCH 04/11] redirect stderr to devnull --- pre_commit/commands/hook_impl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pre_commit/commands/hook_impl.py b/pre_commit/commands/hook_impl.py index ddfac519..d33fbce2 100644 --- a/pre_commit/commands/hook_impl.py +++ b/pre_commit/commands/hook_impl.py @@ -111,7 +111,7 @@ def _ns( def _rev_exists(rev: str) -> bool: - return subprocess.call(('git', 'cat-file', '-e', rev)) == 0 + return subprocess.call(('git', 'cat-file', '-e', rev), stderr=subprocess.DEVNULL) == 0 def _pre_push_ns( From 7b1d351330b65188e20be905236dcdf48095f536 Mon Sep 17 00:00:00 2001 From: Paul Tarjan Date: Fri, 26 Dec 2025 15:17:13 -0700 Subject: [PATCH 05/11] line length --- pre_commit/commands/hook_impl.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pre_commit/commands/hook_impl.py b/pre_commit/commands/hook_impl.py index d33fbce2..d9849a1c 100644 --- a/pre_commit/commands/hook_impl.py +++ b/pre_commit/commands/hook_impl.py @@ -111,7 +111,10 @@ def _ns( def _rev_exists(rev: str) -> bool: - return subprocess.call(('git', 'cat-file', '-e', rev), stderr=subprocess.DEVNULL) == 0 + return subprocess.call( + ('git', 'cat-file', '-e', rev), + stderr=subprocess.DEVNULL, + ) == 0 def _pre_push_ns( From ade6b69f2f7557f6c9e159d58ee1fbf50f83c146 Mon Sep 17 00:00:00 2001 From: Paul Tarjan Date: Fri, 26 Dec 2025 15:27:50 -0700 Subject: [PATCH 06/11] convert to not not --- pre_commit/commands/hook_impl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pre_commit/commands/hook_impl.py b/pre_commit/commands/hook_impl.py index d9849a1c..e5c26b90 100644 --- a/pre_commit/commands/hook_impl.py +++ b/pre_commit/commands/hook_impl.py @@ -111,10 +111,10 @@ def _ns( def _rev_exists(rev: str) -> bool: - return subprocess.call( + return not not subprocess.call( ('git', 'cat-file', '-e', rev), stderr=subprocess.DEVNULL, - ) == 0 + ) def _pre_push_ns( From 2b39c9075fa2b9fcaafa23e9d2bd48f15678235c Mon Sep 17 00:00:00 2001 From: Paul Tarjan Date: Fri, 26 Dec 2025 15:30:10 -0700 Subject: [PATCH 07/11] maybe parens? --- pre_commit/commands/hook_impl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pre_commit/commands/hook_impl.py b/pre_commit/commands/hook_impl.py index e5c26b90..c2af005c 100644 --- a/pre_commit/commands/hook_impl.py +++ b/pre_commit/commands/hook_impl.py @@ -111,10 +111,10 @@ def _ns( def _rev_exists(rev: str) -> bool: - return not not subprocess.call( + return not (not subprocess.call( ('git', 'cat-file', '-e', rev), stderr=subprocess.DEVNULL, - ) + )) def _pre_push_ns( From 07ad09136345775799ba4867d2d58fcc48cb7072 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 26 Dec 2025 22:30:25 +0000 Subject: [PATCH 08/11] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pre_commit/commands/hook_impl.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pre_commit/commands/hook_impl.py b/pre_commit/commands/hook_impl.py index c2af005c..85517ece 100644 --- a/pre_commit/commands/hook_impl.py +++ b/pre_commit/commands/hook_impl.py @@ -111,10 +111,12 @@ def _ns( def _rev_exists(rev: str) -> bool: - return not (not subprocess.call( - ('git', 'cat-file', '-e', rev), - stderr=subprocess.DEVNULL, - )) + return not ( + not subprocess.call( + ('git', 'cat-file', '-e', rev), + stderr=subprocess.DEVNULL, + ) + ) def _pre_push_ns( From aec205773a27a4b3227e5a581408dd46a3112cdc Mon Sep 17 00:00:00 2001 From: Paul Tarjan Date: Fri, 26 Dec 2025 15:32:13 -0700 Subject: [PATCH 09/11] use bool --- pre_commit/commands/hook_impl.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pre_commit/commands/hook_impl.py b/pre_commit/commands/hook_impl.py index 85517ece..d792cd98 100644 --- a/pre_commit/commands/hook_impl.py +++ b/pre_commit/commands/hook_impl.py @@ -111,12 +111,10 @@ def _ns( def _rev_exists(rev: str) -> bool: - return not ( - not subprocess.call( - ('git', 'cat-file', '-e', rev), - stderr=subprocess.DEVNULL, - ) - ) + return not bool(subprocess.call( + ('git', 'cat-file', '-e', rev), + stderr=subprocess.DEVNULL, + )) def _pre_push_ns( From 58cbea11564e2fa2a19c29c0d7cb2cbf62c87655 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 26 Dec 2025 22:34:08 +0000 Subject: [PATCH 10/11] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pre_commit/commands/hook_impl.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pre_commit/commands/hook_impl.py b/pre_commit/commands/hook_impl.py index d792cd98..dc9666f5 100644 --- a/pre_commit/commands/hook_impl.py +++ b/pre_commit/commands/hook_impl.py @@ -111,10 +111,12 @@ def _ns( def _rev_exists(rev: str) -> bool: - return not bool(subprocess.call( - ('git', 'cat-file', '-e', rev), - stderr=subprocess.DEVNULL, - )) + return not bool( + subprocess.call( + ('git', 'cat-file', '-e', rev), + stderr=subprocess.DEVNULL, + ), + ) def _pre_push_ns( From 3203dd38310982c01a75d8814d0fc72e875659d0 Mon Sep 17 00:00:00 2001 From: Paul Tarjan Date: Fri, 26 Dec 2025 16:09:12 -0700 Subject: [PATCH 11/11] remove bool --- pre_commit/commands/hook_impl.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pre_commit/commands/hook_impl.py b/pre_commit/commands/hook_impl.py index dc9666f5..815b22b2 100644 --- a/pre_commit/commands/hook_impl.py +++ b/pre_commit/commands/hook_impl.py @@ -111,11 +111,9 @@ def _ns( def _rev_exists(rev: str) -> bool: - return not bool( - subprocess.call( - ('git', 'cat-file', '-e', rev), - stderr=subprocess.DEVNULL, - ), + return not subprocess.call( + ('git', 'cat-file', '-e', rev), + stderr=subprocess.DEVNULL, )