]> git.ipfire.org Git - thirdparty/git.git/commit
gitk: fix MacOS 10.14 "Mojave" crash on launch
authorEric Sunshine <sunshine@sunshineco.com>
Tue, 24 Jul 2018 06:51:20 +0000 (02:51 -0400)
committerJohannes Sixt <j6t@kdbg.org>
Mon, 22 Sep 2025 16:03:04 +0000 (18:03 +0200)
commit9611ef554d17b067195b6fa363bb59add39ab0d2
treecaf1c8603f6c16be643c618a75dc5de615304efe
parentac8fec7d8de265e56441713faaf4e08f11c31469
gitk: fix MacOS 10.14 "Mojave" crash on launch

On MacOS, a "wish" application started from the terminal opens in the
background, thus doesn't match user expectation that a newly-launched
application ought to be placed in the foreground. To address this
shortcoming, both gitk and git-gui use Apple Events to send a message to
"System Events" instructing it to foreground the "wish" application by
PID.

Unfortunately, MacOS 10.14 tightens restrictions on Apple Events,
requiring explicit granting of permission to control applications in
this fashion, and apparently such granting for "Automation" is not
allowed at all[1]. As a consequence gitk crashes outright at launch time
with a "Not authorized to send Apple events to System Events" error,
thus is entirely unusable on "Mojave".

In contrast, git-gui does not crash since it deliberately[2] catches and
ignores Apple Events errors. This does mean that git-gui will not
automatically become the foreground application on "Mojave", which is a
minor inconvenience but far better than crashing outright as gitk does.

Update gitk to catch and ignore Apple Events errors, mirroring git-gui's
behavior, to avoid this crash.

(Finding and implementing an alternate approach to foregrounding the
"wish" application on "Mojave" may be desirable but is outside the scope
of this crash fix.)

[1]: https://lore.kernel.org/git/D295145E-7596-4409-9681-D8ADBB9EBB0C@me.com/
[2]: https://lore.kernel.org/git/CABNJ2G+h3zh+=wLA0KHjUn8TsfhqUK1Kn-1_=6hnXVRJUPhuuA@mail.gmail.com/

Reported-by: Evgeny Cherpak <cherpake@me.com>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
gitk