From 15a24d1dc075e1324d396dbc8fcc2261f49f6ff2 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 20 Oct 2026 03:07:48 -0400 Subject: [PATCH] Detect amend aliases with macOS git macOS git's regex library does not support `\s`, so `git config --get-regexp` never matched an alias for `commit --amend` and amendment? returned false. Use the POSIX `[[:space:]]` class, which both git and Ruby understand. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01Wo4FerFK9aaxrGrmVE9ncZ --- lib/overcommit/hook_context/helpers/file_modifications.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/overcommit/hook_context/helpers/file_modifications.rb b/lib/overcommit/hook_context/helpers/file_modifications.rb index 00aaccc8..e0823732 100644 --- a/lib/overcommit/hook_context/helpers/file_modifications.rb +++ b/lib/overcommit/hook_context/helpers/file_modifications.rb @@ -12,7 +12,9 @@ def amendment? cmd = Overcommit::Utils.parent_command return unless cmd - amend_pattern = 'commit(\s.*)?\s--amend(\s|$)' + # POSIX character class rather than `\s`, which macOS git's regex + # library does not support + amend_pattern = 'commit([[:space:]].*)?[[:space:]]--amend([[:space:]]|$)' # Since the ps command can return invalid byte sequences for commands # containing unicode characters, we replace the offending characters,